#include #include #include #include #include #include #include #include template class variable_list_member { public: T& get() {return t;} const T& get()const{return t;} private: T t; }; template class variable_list_seq: protected boost::mpl::fold< Sequence, boost::mpl::empty_base, boost::mpl::inherit< boost::mpl::_1, variable_list_member > >::type { public: template T& get() { return static_cast&>(*this).get(); } template const T& get()const { return static_cast&>(*this).get(); } }; /* front end to variable_list_seq hiding the use of MPL sequences */ #define VARIABLE_LIST_TEMPLATE_PARM(z,n,var) \ typename BOOST_PP_CAT(var,n) BOOST_PP_EXPR_IF(n,=boost::mpl::na) template class variable_list: public variable_list_seq > { }; #undef VARIABLE_LIST_TEMPLATE_PARM /**************** testing ****************/ #include #include int main() { typedef variable_list vl_type; vl_type v; const vl_type& vc=v; v.get()=5; v.get()='a'; v.get()=1.0; std::cout<<"v.get()=="<()<()=="<()<()=="<()<