Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.MPL.Vector -> Boost.Tuple
From: ïÌÅÇ ãÁÒÅ× (zabivator_at_[hidden])
Date: 2008-09-08 02:40:06


Thank you, it's very nice solution! Great!

2008/9/5 Steven Watanabe <watanabesj_at_[hidden]>

> 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
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
ó Õ×ÁÖÅÎÉÅÍ, ãÁÒÅ× ïÌÅÇ


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