]>
Commit | Line | Data |
---|---|---|
1 | .. Sequences/Intrinsic Metafunctions//empty | |
2 | ||
3 | empty | |
4 | ===== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | > | |
14 | struct empty | |
15 | { | |
16 | typedef |unspecified| type; | |
17 | }; | |
18 | ||
19 | ||
20 | ||
21 | Description | |
22 | ----------- | |
23 | ||
24 | Returns an |Integral Constant| ``c`` such that ``c::value == true`` if | |
25 | and only if the sequence is empty. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/empty.hpp> | |
34 | ||
35 | ||
36 | Model of | |
37 | -------- | |
38 | ||
39 | |Tag Dispatched Metafunction| | |
40 | ||
41 | ||
42 | Parameters | |
43 | ---------- | |
44 | ||
45 | +---------------+-----------------------+-----------------------------------+ | |
46 | | Parameter | Requirement | Description | | |
47 | +===============+=======================+===================================+ | |
48 | | ``Sequence`` | |Forward Sequence| | A sequence to test. | | |
49 | +---------------+-----------------------+-----------------------------------+ | |
50 | ||
51 | ||
52 | Expression semantics | |
53 | -------------------- | |
54 | ||
55 | For any |Forward Sequence| ``s``: | |
56 | ||
57 | ||
58 | .. parsed-literal:: | |
59 | ||
60 | typedef empty<s>::type c; | |
61 | ||
62 | :Return type: | |
63 | Boolean |Integral Constant|. | |
64 | ||
65 | :Semantics: | |
66 | Equivalent to ``typedef is_same< begin<s>::type,end<s>::type >::type c;``. | |
67 | ||
68 | :Postcondition: | |
69 | ``empty<s>::value == ( size<s>::value == 0 )``. | |
70 | ||
71 | ||
72 | ||
73 | Complexity | |
74 | ---------- | |
75 | ||
76 | Amortized constant time. | |
77 | ||
78 | ||
79 | Example | |
80 | ------- | |
81 | ||
82 | .. parsed-literal:: | |
83 | ||
84 | typedef range_c<int,0,0> empty_range; | |
85 | typedef vector<long,float,double> types; | |
86 | ||
87 | BOOST_MPL_ASSERT( empty<empty_range> ); | |
88 | BOOST_MPL_ASSERT_NOT( empty<types> ); | |
89 | ||
90 | ||
91 | See also | |
92 | -------- | |
93 | ||
94 | |Forward Sequence|, |Integral Constant|, |size|, |begin| / |end| | |
95 | ||
96 | ||
97 |