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