]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Sequences/Intrinsic Metafunctions//back |
2 | ||
3 | back | |
4 | ==== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | > | |
14 | struct back | |
15 | { | |
16 | typedef |unspecified| type; | |
17 | }; | |
18 | ||
19 | ||
20 | ||
21 | Description | |
22 | ----------- | |
23 | ||
24 | Returns the last element in the sequence. | |
25 | ||
26 | ||
27 | Header | |
28 | ------ | |
29 | ||
30 | .. parsed-literal:: | |
31 | ||
32 | #include <boost/mpl/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`` | |Bidirectional Sequence| | A sequence to be examined. | | |
48 | +---------------+---------------------------+-----------------------------------+ | |
49 | ||
50 | ||
51 | Expression semantics | |
52 | -------------------- | |
53 | ||
54 | For any |Bidirectional Sequence| ``s``: | |
55 | ||
56 | .. parsed-literal:: | |
57 | ||
58 | typedef back<s>::type t; | |
59 | ||
60 | :Return type: | |
61 | A type. | |
62 | ||
63 | :Precondition: | |
64 | ``empty<s>::value == false``. | |
65 | ||
66 | :Semantics: | |
67 | Equivalent to | |
68 | ||
69 | .. parsed-literal:: | |
70 | ||
71 | typedef deref< prior< end<s>::type >::type >::type t; | |
72 | ||
73 | ||
74 | ||
75 | Complexity | |
76 | ---------- | |
77 | ||
78 | Amortized constant time. | |
79 | ||
80 | ||
81 | Example | |
82 | ------- | |
83 | ||
84 | .. parsed-literal:: | |
85 | ||
86 | typedef range_c<int,0,1> range1; | |
87 | typedef range_c<int,0,10> range2; | |
88 | typedef range_c<int,-10,0> range3; | |
89 | ||
90 | BOOST_MPL_ASSERT_RELATION( back<range1>::value, ==, 0 ); | |
91 | BOOST_MPL_ASSERT_RELATION( back<range2>::value, ==, 9 ); | |
92 | BOOST_MPL_ASSERT_RELATION( back<range3>::value, ==, -1 ); | |
93 | ||
94 | ||
95 | See also | |
96 | -------- | |
97 | ||
98 | |Bidirectional Sequence|, |front|, |push_back|, |end|, |deref|, |at| | |
99 | ||
100 | ||
101 |