
This may be a little OT but as it applies to metaprogramming and ideas
from the book I thought it the best place to ask.
On pgs 191/2 of the MPL book (section 9.5) is a set of ideas meant to
introduce the inherit_linearly metafunction. There are some things I
want to do that suggested this was actually the better way to go for me.
So I implemented something like the following:
struct empty {};
template < typename FIELD, typename CDR >
struct rec : CDR
{
typename FIELD::type value;
rec() : value() {}
};
template < typename VEC >
struct generate_record
//: boost::mpl::inherit_linearly< VEC, boost::mpl::inherit<
recpl::_2, pl::_1> >::type
: boost::mpl::fold< VEC, empty, rec< pl::_2, pl::_1> >
{};
I implemented a getter function like so:
template < typename FIELD, typename CDR >
typename FIELD::type & get(rec< FIELD, CDR > & r)
{
return r.value;
}
Now, minus the "field" concept this seems to be exactly the same basic
thing. The field concept is something I need for what I'm working on
that currently, for this test, just has a type in it.
I create a "record" like so:
typedef generate_record< boost::mpl::vector
::type test_record;
When I print the type I end up with:
"rec