# pop_back

### Synopsis

    template<
          typename Sequence
        >
    struct pop_back
    {
        typedef unspecified type;
    };

### Description

`pop_back` performs a removal at the end of the sequence. The algorithm returns a new sequence which contains all the elements in the range `[begin<Sequence>::type, prior< end<Sequence>::type >::type)`. The result sequence preserves all the functional and performance characteristics of the original `Sequence`, except its size and identity.

### Definition

    #include "boost/mpl/pop_back.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | A model of Extensible Sequence | A sequence to handle the erase operation

### Expression semantics

Expression | Expression type | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typedef pop_back<Sequence>::type s;` | A model of Extensible Sequence | `empty<Sequence>::type::value == false` | Equivalent to `typedef erase< Sequence, prior< end<Sequence>::type >::type >::type s;` | `size<s>::type::value == size<Sequence>::type::value - 1`

### Complexity

Amortized constant time [1].

### Example

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

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

    BOOST_STATIC_ASSERT(size<result1>::type::value == 0);
    BOOST_STATIC_ASSERT(size<result2>::type::value == 1);
    BOOST_STATIC_ASSERT(size<result3>::type::value == 2);

    BOOST_MPL_ASSERT_IS_SAME(back<result2>::type, long);
    BOOST_MPL_ASSERT_IS_SAME(back<result3>::type, int);

### Notes

[1] The algorithm is provided only if the sequence can meet the stated complexity requirements.

### See also

Extensible Sequence, `erase`, `push_back`, `back`, `pop_front`

Table of Content | Reference
Last edited July 17, 2002 3:56 am