
AMDG ???? ????? wrote:
typedef boost::mpl::vector< A, B, C > Sequence;
typedef typename Question< Sequence >::type Result;
BOOST_MPL_ASSERT( boost::mpl::is_same< Result, boost::tuple< A, B, C > >); How write Question? I don't want to write specialisation for every dimension of tuple manually. Implementation should be compatible with the last stable Boost release (1.36) Thank you
#include <boost/tuple/tuple.hpp> #include <boost/mpl/vector.hpp> #include <boost/mpl/copy.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/preprocessor/repetition/enum_params.hpp> struct A {}; struct B {}; struct C {}; typedef boost::mpl::vector< A, B, C > Sequence; template<class T, class Tuple> struct tuple_push_front; template<class T, BOOST_PP_ENUM_PARAMS(10, class T)> struct tuple_push_front<T, boost::tuple<BOOST_PP_ENUM_PARAMS(10, T)> > { typedef boost::tuple<T, BOOST_PP_ENUM_PARAMS(9, T)> type; }; template<class Sequence> struct Question { typedef typename boost::mpl::reverse_copy< Sequence, boost::mpl::inserter<boost::tuple<>, tuple_push_front<boost::mpl::_2, boost::mpl::_1> >
::type type; };
typedef Question< Sequence >::type Result; BOOST_MPL_ASSERT((boost::is_same< Result, boost::tuple< A, B, C > >)); In Christ, Steven Watanabe