
Zitat von Larry Evans <cppljevans@suddenlink.net>:
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/in...
could be replaced with that here:
https://svn.boost.org/trac/boost/browser/sandbox/variadic_templates/boost/io...
thanks for pointing this out. I did search boost, but only the release. I'll only use released libraries as dependencies for now.