• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Sequences/Intrinsic Metafunctions//empty
2
3empty
4=====
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        >
14    struct empty
15    {
16        typedef |unspecified| type;
17    };
18
19
20
21Description
22-----------
23
24Returns an |Integral Constant| ``c`` such that ``c::value == true`` if
25and only if the sequence is empty.
26
27
28Header
29------
30
31.. parsed-literal::
32
33    #include <boost/mpl/empty.hpp>
34
35
36Model of
37--------
38
39|Tag Dispatched Metafunction|
40
41
42Parameters
43----------
44
45+---------------+-----------------------+-----------------------------------+
46| Parameter     | Requirement           | Description                       |
47+===============+=======================+===================================+
48| ``Sequence``  | |Forward Sequence|    | A sequence to test.               |
49+---------------+-----------------------+-----------------------------------+
50
51
52Expression semantics
53--------------------
54
55For 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
73Complexity
74----------
75
76Amortized constant time.
77
78
79Example
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
91See also
92--------
93
94|Forward Sequence|, |Integral Constant|, |size|, |begin| / |end|
95
96
97.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
98   Distributed under the Boost Software License, Version 1.0. (See accompanying
99   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
100