smallB
smallB

Reputation: 17138

Using boost mpl pop_front

Having:

#include <typeinfo>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/pop_front.hpp>
int main()
{
    typedef boost::mpl::vector<char,short,int,long,long long> v;
    typedef typename pop_front<v>::type poped;
}

the problem is that poped is not equal to boost::mpl::vector< short,int,long,long long > but to: boost::mpl::v_mask< boost::mpl::vector< char,short,int,long,long long>>

How shall I make it to return vector without first element?

Upvotes: 0

Views: 329

Answers (2)

Madera
Madera

Reputation: 324

Maybe mpl::equal can help you clarify why this doesn't really matter at all.

Just make sure it's equal, but not necessarily the same.

BOOST_MPL_ASSERT((mpl::equal<
    typename pop_front<v>::type,
    mpl::vector<short,int,long,long long>
>));

That is all you really need ;-)

Upvotes: 1

Luc Touraille
Luc Touraille

Reputation: 82171

I am not sure this is possible using MPL features. Even if you tried copying poped into a vector using copy and a back_inserter, you would once again obtain a type which is not really a vector. This is by design: like in Boost.Fusion, MPL's algorithms and metafunctions return views over the original sequence, providing lazy evaluation. These views can be used like the original sequences, so you should not worry about what their actual types are and simply use them as if they were vector (or lists, or maps, etc.).

Upvotes: 0

Related Questions