]>
Commit | Line | Data |
---|---|---|
1 | .. Sequences/Intrinsic Metafunctions//pop_back | |
2 | ||
3 | pop_back | |
4 | ======== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | > | |
14 | struct pop_back | |
15 | { | |
16 | typedef |unspecified| type; | |
17 | }; | |
18 | ||
19 | ||
20 | Description | |
21 | ----------- | |
22 | ||
23 | ``pop_back`` performs a removal at the end of the sequence with guaranteed |O(1)| | |
24 | complexity. | |
25 | ||
26 | ||
27 | Header | |
28 | ------ | |
29 | ||
30 | .. parsed-literal:: | |
31 | ||
32 | #include <boost/mpl/pop_back.hpp> | |
33 | ||
34 | ||
35 | Model of | |
36 | -------- | |
37 | ||
38 | |Tag Dispatched Metafunction| | |
39 | ||
40 | ||
41 | Parameters | |
42 | ---------- | |
43 | ||
44 | +---------------+-------------------------------+-----------------------------------------------+ | |
45 | | Parameter | Requirement | Description | | |
46 | +===============+===============================+===============================================+ | |
47 | | ``Sequence`` | |Back Extensible Sequence| | A sequence to erase the last element from. | | |
48 | +---------------+-------------------------------+-----------------------------------------------+ | |
49 | ||
50 | ||
51 | Expression semantics | |
52 | -------------------- | |
53 | ||
54 | For 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 | ||
73 | Complexity | |
74 | ---------- | |
75 | ||
76 | Amortized constant time. | |
77 | ||
78 | ||
79 | Example | |
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 | ||
100 | See also | |
101 | -------- | |
102 | ||
103 | |Back Extensible Sequence|, |erase|, |push_back|, |back|, |pop_front| | |
104 | ||
105 | ||
106 |