1 .. Sequences/Intrinsic Metafunctions//size
16 typedef |unspecified| type;
24 ``size`` returns the number of elements in the sequence, that is, the number of elements
25 in the range [``begin<Sequence>::type``, ``end<Sequence>::type``).
33 #include <boost/mpl/size.hpp>
40 |Tag Dispatched Metafunction|
46 +---------------+-----------------------+-----------------------------------------------+
47 | Parameter | Requirement | Description |
48 +===============+=======================+===============================================+
49 | ``Sequence`` | |Forward Sequence| | A sequence to query. |
50 +---------------+-----------------------+-----------------------------------------------+
57 For any |Forward Sequence| ``s``:
62 typedef size<s>::type n;
72 typedef distance< begin<s>::type,end<s>::type >::type n;
83 The complexity of the ``size`` metafunction directly depends on the implementation of
84 the particular sequence it is applied to. In the worst case, ``size`` guarantees a
87 If the ``s`` is a |Random Access Sequence|, ``size<s>::type`` is an |O(1)| operation.
88 The opposite is not necessarily true |--| for example, a sequence class that models
89 |Forward Sequence| might still give us an |O(1)| ``size`` implementation.
97 typedef list0<> empty_list;
98 typedef vector_c<int,0,1,2,3,4,5> numbers;
99 typedef range_c<int,0,100> more_numbers;
101 BOOST_MPL_ASSERT_RELATION( size<list>::value, ==, 0 );
102 BOOST_MPL_ASSERT_RELATION( size<numbers>::value, ==, 5 );
103 BOOST_MPL_ASSERT_RELATION( size<more_numbers>::value, ==, 100 );
109 |Forward Sequence|, |Random Access Sequence|, |empty|, |begin|, |end|, |distance|
112 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
113 Distributed under the Boost Software License, Version 1.0. (See accompanying
114 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)