]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Querying Algorithms//contains |30 |
2 | ||
3 | contains | |
4 | ======== | |
5 | ||
6 | Synopsis | |
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 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns a true-valued |Integral Constant| if one or more elements in ``Sequence`` | |
26 | are identical to ``T``. | |
27 | ||
28 | ||
29 | Header | |
30 | ------ | |
31 | ||
32 | .. parsed-literal:: | |
33 | ||
34 | #include <boost/mpl/contains.hpp> | |
35 | ||
36 | ||
37 | Parameters | |
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 | ||
49 | Expression semantics | |
50 | -------------------- | |
51 | ||
52 | For 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 | ||
74 | Complexity | |
75 | ---------- | |
76 | ||
77 | Linear. At most ``size<s>::value`` comparisons for identity. | |
78 | ||
79 | ||
80 | Example | |
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 | ||
89 | See also | |
90 | -------- | |
91 | ||
92 | |Querying Algorithms|, |find|, |find_if|, |count|, |lower_bound| | |
93 | ||
94 | ||
95 |