• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Sequences/Intrinsic Metafunctions//pop_back
2
3pop_back
4========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        >
14    struct pop_back
15    {
16        typedef |unspecified| type;
17    };
18
19
20Description
21-----------
22
23``pop_back`` performs a removal at the end of the sequence with guaranteed |O(1)|
24complexity.
25
26
27Header
28------
29
30.. parsed-literal::
31
32    #include <boost/mpl/pop_back.hpp>
33
34
35Model of
36--------
37
38|Tag Dispatched Metafunction|
39
40
41Parameters
42----------
43
44+---------------+-------------------------------+-----------------------------------------------+
45| Parameter     | Requirement                   | Description                                   |
46+===============+===============================+===============================================+
47| ``Sequence``  | |Back Extensible Sequence|    | A sequence to erase the last element from.    |
48+---------------+-------------------------------+-----------------------------------------------+
49
50
51Expression semantics
52--------------------
53
54For any |Back Extensible Sequence| ``s``:
55
56.. parsed-literal::
57
58    typedef pop_back<s>::type r;
59
60:Return type:
61    |Back Extensible Sequence|.
62
63:Precondition:
64    ``empty<s>::value == false``.
65
66:Semantics:
67    Equivalent to ``erase<s,end<s>::type>::type;``.
68
69:Postcondition:
70    ``size<r>::value == size<s>::value - 1``.
71
72
73Complexity
74----------
75
76Amortized constant time.
77
78
79Example
80-------
81
82.. parsed-literal::
83
84    typedef vector<long>::type types1;
85    typedef vector<long,int>::type types2;
86    typedef vector<long,int,char>::type types3;
87
88    typedef pop_back<types1>::type result1;
89    typedef pop_back<types2>::type result2;
90    typedef pop_back<types3>::type result3;
91
92    BOOST_MPL_ASSERT_RELATION( size<result1>::value, ==, 0 );
93    BOOST_MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
94    BOOST_MPL_ASSERT_RELATION( size<result3>::value, ==, 2 );
95
96    BOOST_MPL_ASSERT(( is_same< back<result2>::type, long> ));
97    BOOST_MPL_ASSERT(( is_same< back<result3>::type, int > ));
98
99
100See also
101--------
102
103|Back Extensible Sequence|, |erase|, |push_back|, |back|, |pop_front|
104
105
106.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
107   Distributed under the Boost Software License, Version 1.0. (See accompanying
108   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
109