How to “concatenate” boost::mpl::vectors

前端 未结 3 860
误落风尘
误落风尘 2021-01-17 21:48

I have to different vectors

mpl::vector
mpl::vector

I\'d like to \"concatenate\" them to for

相关标签:
3条回答
  • 2021-01-17 22:20

    The libaray native supported function boost::mpl::joint_view is probably a better choice. It is optimized and lazy-evaluated.

    http://www.boost.org/doc/libs/1_55_0/libs/mpl/doc/refmanual/joint-view.html

    0 讨论(0)
  • 2021-01-17 22:23

    You can use mpl::copy, which uses mpl::fold internally.

    typedef mpl::vector<T0, T1> s0;
    typedef mpl::vector<T2, T3> s1;
    typedef mpl::copy<
        s1,
        mpl::back_inserter<s0>
    >::type concatenated;
    
    BOOST_MPL_ASSERT((
        mpl::equal<
            concatenated,
            mpl::vector<T0, T1, T2, T3>
        >
    ));
    
    0 讨论(0)
  • 2021-01-17 22:35

    Like this:

    // include the appropriate headers
    typedef mpl::vector<Type1, Type2> first_type;
    typedef mpl::vector<Type3, Type4> second_type;
    typedef mpl::copy<first_type::type, mpl::back_inserter<second_type> >::type concat_type;
    
    0 讨论(0)
提交回复
热议问题