Boost logo

Boost :

Subject: Re: [boost] [mirror] automatic reflection / boost.mirror still in development?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-08-23 08:22:31


Am Saturday 22 August 2009 14:00:36 schrieb John B. Turpish:
> ROSE can do similar things too.
>
> The thing is, this seems to me to be more the job of a build tool and
> less the job of a library. You don't want meta information you're not
> using to end up in the executable, right?

right. the metainformation generated would be compile-time constants only.

for the example below, something like:
namespace reflection{
  struct myclass{
    struct myvar{
      typedef int type;
    };
    ...

if there is a "bloat" issue it is probably compilation time. to be able to map
a type to its reflection type (also shown below, with a ::type missing),
you'd end up with very large MPL sequences, but you could limit reflection to
a desired namespace or some types avoid that.

> >> test.cpp:
> >> //include result of GCC plugin of test.cpp:
> >> #include "test.rpp"
> >>
> >> class myclass{
> >>        int myvar;
> >>        double myfunction();
> >> };
> >>
> >> int main(){
> >>        typedef reflection::myclass::myvar::type ret;
> >>        BOOST_STATIC_ASSERT(is_same<ret,int>::value);
> >>        typedef reflecton::myclass::myfunction::type::return_type ret;
> >>        BOOST_STATIC_ASSERT(is_same<ret,double>::value);
> >> }
> >>
> >> //or, lookup in MPL map:
> >> template<class T>
> >> char const *lookup_name(){
> >>        return reflection::type<T>::name;
> >> }
> >>
> >> or anything else you can do with MPL sequences, like iterating over
> >> class members.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk