|
Boost Users : |
Subject: Re: [Boost-users] combining mpl sequences
From: Cory Nelson (phrosty_at_[hidden])
Date: 2010-09-05 14:34:46
On Sun, Sep 5, 2010 at 3:10 AM, Karsten Ahnert
<karsten.ahnert_at_[hidden]> wrote:
> Hi,
>
> I have a templatized mpl-vector
>
> template< class T > class containers :
> Â public mpl::vector<
> Â Â std::vector< T > ,
> Â Â std::list< T > ,
> Â Â std::deque< T >
>> { };
>
> and a mpl-vector holding some types:
>
> typedef mpl::vector< float , double , long double >::type my_types;
>
> Is there a simple way to build a mpl vector which contains the elements
> of the first vector with template arguments of the second vector, hence
>
> mpl:vector<
> Â std::vector< float > ,
> Â std::vector< double > ,
> Â std::vector< long double > ,
> Â std::list< float > ,
> Â std::list< double > ,
> Â std::list< long double > ,
> Â std::deque< float > ,
> Â std::deque< double > ,
> Â std::deque< long double >
>>
>
>
> I can do this manually with mpl::insert_range
>
> typedef mpl::insert_range<
> Â mpl::vector0<> ,
> Â mpl::end< mpl::vector0<> >::type ,
> Â containers< mpl::at< my_types , mpl::int_<0> >::type >
>>::type first;
>
> typedef mpl::insert_range<
> Â first ,
> Â mpl::end< first >::type ,
> Â containers< mpl::at< my_types , mpl::int_<1> >::type >
>>::type second;
>
> typedef mpl::insert_range<
> Â second ,
> Â mpl::end< second >::type ,
> Â containers< mpl::at< my_types , mpl::int_<2> >::type >
>>::type all_containers;
>
> But this way is not very elegant. Does some has any hints how to do this
> automatically?
>
Try:
typedef copy<VecB, back_inserter<VecA>> all_containers;
-- Cory Nelson http://int64.org
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