MPL - what rule am I breaking?

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.

Noah Roberts wrote:
template < typename FIELD, bool Writable > struct rec <snip>
template < typename VEC > struct generate_record : boost::mpl::inherit_linearly< VEC, boost::mpl::inherit< rec<pl::_2, true>, pl::_1> >::type <snip>
The problem is the "bool Writable" non-type template parameter. The MPL lambda expression evaluator can't handle that. Change it to this: template<typename Field, typename Writable> struct rec and then template < typename VEC > struct generate_record : boost::mpl::inherit_linearly< VEC, boost::mpl::inherit< rec<pl::_2, mpl::true_>, pl::_1> >::type HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
Noah Roberts wrote:
template < typename FIELD, bool Writable > struct rec <snip>
template < typename VEC > struct generate_record : boost::mpl::inherit_linearly< VEC, boost::mpl::inherit< rec<pl::_2, true>, pl::_1> >::type <snip>
The problem is the "bool Writable" non-type template parameter. The MPL lambda expression evaluator can't handle that.
Thanks.
participants (2)
-
Eric Niebler
-
Noah Roberts