1.. Algorithms/Querying Algorithms//count |40 2 3count 4===== 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename Sequence 13 , typename T 14 > 15 struct count 16 { 17 typedef |unspecified| type; 18 }; 19 20 21 22Description 23----------- 24 25Returns the number of elements in a ``Sequence`` that are identical to ``T``. 26 27 28Header 29------ 30 31.. parsed-literal:: 32 33 #include <boost/mpl/count.hpp> 34 35 36Parameters 37---------- 38 39+---------------+---------------------------+-----------------------------------+ 40| Parameter | Requirement | Description | 41+===============+===========================+===================================+ 42| ``Sequence`` | |Forward Sequence| | A sequence to be examined. | 43+---------------+---------------------------+-----------------------------------+ 44| ``T`` | Any type | A type to search for. | 45+---------------+---------------------------+-----------------------------------+ 46 47 48Expression semantics 49-------------------- 50 51 52For any |Forward Sequence| ``s`` and arbitrary type ``t``: 53 54 55.. parsed-literal:: 56 57 typedef count<s,t>::type n; 58 59:Return type: 60 |Integral Constant|. 61 62:Semantics: 63 Equivalent to 64 65 .. parsed-literal:: 66 67 typedef count_if< s,is_same<_,T> >::type n; 68 69 70Complexity 71---------- 72 73Linear. Exactly ``size<s>::value`` comparisons for identity. 74 75 76Example 77------- 78 79.. parsed-literal:: 80 81 typedef vector<int,char,long,short,char,short,double,long> types; 82 typedef count<types, short>::type n; 83 84 BOOST_MPL_ASSERT_RELATION( n::value, ==, 2 ); 85 86 87See also 88-------- 89 90|Querying Algorithms|, |count_if|, |find|, |find_if|, |contains|, |lower_bound| 91 92 93.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 94 Distributed under the Boost Software License, Version 1.0. (See accompanying 95 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 96