Subject: Re: [boost] [Boost-interest] C++ library for runtime-concepts (type-erasure)
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2011-02-17 04:41:13
On Tue, Feb 15, 2011 at 10:58 AM, GermÃ¡n Diago <germandiago_at_[hidden]> wrote:
> Ok. The correct way is to reuse libraries as much as possible so that bugs can
> be corrected always in the same place. But at the same time I would
> like a syntax
> that avoids macros as much as possible. For example, my std::tuple
> inside MyClass
> uses a macro, but a very obvious one. The rest is understandable. There
> are many ways to write complicated macros, so I try to avoid them except when
> there is no other practical way.
I've added two new templates to Mirror that replace the type reflection macros:
So now instead of using MIRRORED_TYPE(X), MIRRORED_CLASS(X), ...
you can use either the mirror::reflected_type<X> or the
Thell be available in the next release or you can get the current
version via GIT.
mirror::reflected_type<X> *is a* type conforming to the MetaType concept
and mirror::reflected<X>::type *returns a* type conforming to the
More precisely these templates provide you with types conforming
to either MetaType, MetaClass or MetaEnum, depending on how
the type X was registered with Mirror.
You can use the categorize_meta_object() function or the meta_object_category<>
template to get a tag type for tag dispatching between there concepts.
See the following three examples for comparison:
I'll add a few more or update the existing examples in the near future.
This way you can avoid using macros when reflecting types. I still believe
that using macros for the registering is the right thing to do, even with all
the problems of preprocessor macros.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk