Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Front Page / Sequences / Intrinsic Metafunctions / pop_front



      typename Sequence
struct pop_front
    typedef unspecified type;


pop_front performs a removal at the beginning of the sequence with guaranteed O(1) complexity.


#include <boost/mpl/pop_front.hpp>

Model of

Tag Dispatched Metafunction


Parameter Requirement Description
Sequence Front Extensible Sequence A sequence to erase the first element from.

Expression semantics

For any Front Extensible Sequence s:

typedef pop_front<s>::type r;
Return type:Front Extensible Sequence.
Precondition:empty<s>::value == false.
Semantics:Equivalent to erase<s,begin<s>::type>::type;.
Postcondition:size<r>::value == size<s>::value - 1.


Amortized constant time.


typedef vector<long>::type types1;
typedef vector<int,long>::type types2;
typedef vector<char,int,long>::type types3;

typedef pop_front<types1>::type result1;
typedef pop_front<types2>::type result2;
typedef pop_front<types3>::type result3;

BOOST_MPL_ASSERT_RELATION( size<result1>::value, ==, 0 );
BOOST_MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
BOOST_MPL_ASSERT_RELATION( size<result3>::value, ==, 2 );

BOOST_MPL_ASSERT(( is_same< front<result2>::type, long > ));
BOOST_MPL_ASSERT(( is_same< front<result3>::type, int > ));

See also

Front Extensible Sequence, erase, push_front, front, pop_back