Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-07-07 12:24:24


"Joel de Guzman" <djowel_at_[hidden]> writes:

> Alexander Nasonov <alnsn-mycop_at_[hidden]> wrote:
>
>>> From user point of view it's easy. Every class is described using intuitive
>> class-decl-like style:
>>
>> void describe_Driver(descriptor<Driver>& class_)
>> {
>> class_("Driver").derived_from<Person>()
>> [
>> member(&Driver::licence_id, "licence_id"), // note comma operator
>> member(&Driver::licence_issue_date, "licence_issue_date")
>> ];
>> }
>
> Cool syntax! Hmmm.... Reminds me of Boost.Python, luabind and ahem... Phoenix ;-)

A problem with this is that the introspection information is only
available at runtime. A more-flexible system would use GCC-XML output
to generate something like:

     template <>
     struct class_<Driver>
     {
         typedef mpl::vector<Person> bases;

         typedef mpl::vector<
              member<int Driver::*, &Driver::licence_id>
            , member<Date Driver::*, &Driver::licence_issue_date>
            , member<void (Driver::*)(), &Driver::accelerate>
> members;

         ...
     };

So all the introspection information could be available at
compile-time.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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