2013-10-24 5 views
8

를 내가 그들을 형성하기 위해 서로 다른 벡터부스트 : : MPL : : 벡터를

mpl::vector<Type1, Type2...> 
mpl::vector<Type3, Type4...> 
내가 "연결할"하고 싶은

에있는 "연결하여"방법 :

mpl::vector<Type1, Type2, Type3, Type4...> 

이 날 수있는 것 벡터 템플릿을 준비하고 나중에 다시 사용하십시오. 내 문제에는 여러 가지 해결책이 있지만이 접근법이 나에게 가장 적합하다고 보입니다.

감사합니다 ...이처럼

답변

3

:

// 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

확실하지 않지만 first_type과 second_type이 전환되었다고 생각합니다. 내가 틀렸다면 vector 를 얻을 것이다. – llonesmiz

+0

@cv_and_he [Right] (http://www.boost.org/doc/libs/1_54_0/libs/mpl/doc/refmanual/back-inserter.html), 형식의 순서를 중요하게 생각하지 않았습니다. . –

+0

감사합니다.이 코드는 작업을 수행합니다. 비록 내 경우에는이 방법은 컴파일 시간에 엄청난 양의 메모리를 소비하지만 ... – Kikosha

2

당신은 MPL을 사용할 수 있습니다 : MPL은 내부적으로 접어 :: 사용, 복사,.

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

대답 해 주셔서 감사합니다.이 작품은 – Kikosha

+0

온라인 데모 : http://coliru.stacked-crooked.com/a/50d3d9b6707cd457 –

관련 문제