Boost logo

Boost Users :

Subject: [Boost-users] MPL - what rule am I breaking?
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2009-03-06 14:00:51


Version A (works):

template < typename FIELD >
struct rec
{
   typename FIELD::type value;
   rec() : value() {}

protected:
   typename FIELD::type & ref() { return value; }
};

template < typename VEC >
struct generate_record
   : boost::mpl::inherit_linearly< VEC, boost::mpl::inherit<
rec<pl::_2>, pl::_1> >::type
{
   typedef VEC fields;
};

Version B (fails):

template < typename FIELD, bool Writable >
struct rec
{
   typename FIELD::type value; // failure point
   rec() : value() {}

protected:
   typename FIELD::type & ref() { return value; }
};

template < typename VEC >
struct generate_record
   : boost::mpl::inherit_linearly< VEC, boost::mpl::inherit< rec<pl::_2,
true>, pl::_1> >::type
{
   typedef VEC fields;
};

The error I get:

'type' : is not a member of 'boost::mpl::arg<2>'

I think I know what's going on, rec<pl::_2, true> is getting immediately
instantiated while rec<pl::_2> does not. What I don't know is why or
how to fix it.

Thanks.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net