Subject: Re: [boost] [intro] Preview: Introspection library
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-06-28 10:57:41


Zitat von Larry Evans <cppljevans_at_[hidden]>:

> On 06/28/10 07:00, Stefan Strasser wrote:
> Could this library be used to implement a class metafunction template:
>
<snip>
>
> where gcptr_offsets would contain the offsets from the start of
> a T to the location of all the:
>
> template<typename S> struct gcptr;
>
> contained within T? gcptr<S> might be, for instance, a smart
> pointer to an S. This would be useful for garbage collection.

in principle, yes. one of my use cases is similar to this.
however, I would not recommend implementing this as a metafunction, as
it is much easier to use the "apply_members" algorithm when building
your GC reference graph.

struct functor{
   template<class T,class Semantics>
   void operator()(T &,Semantics){}
   template<class T,class Semantics>
   void operator()(gc_ptr<T> &ptr,Semantics){
     //do something with ptr
   }
};

intro::apply_members(functor(),obj);

this generates no code with an optimizing compiler (except your own).

>
>
> BTW, based on just the class name, the code:
>
> https://svn.boost.org/trac/boost/browser/sandbox/intro/boost/intro/detail/indent_streambuf.hpp
>
> could be replaced with that here:
>
> https://svn.boost.org/trac/boost/browser/sandbox/variadic_templates/boost/iostreams/utility/indent_scoped_ostreambuf.hpp
>

thanks for pointing this out. I did search boost, but only the
release. I'll only use released libraries as dependencies for now.