• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Algorithms/Querying Algorithms//find |10
2
3find
4====
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        , typename T
14        >
15    struct find
16    {
17        typedef |unspecified| type;
18    };
19
20
21
22Description
23-----------
24
25Returns an iterator to the first occurrence of type ``T`` in a ``Sequence``.
26
27
28Header
29------
30
31.. parsed-literal::
32
33    #include <boost/mpl/find.hpp>
34
35
36
37Parameters
38----------
39
40+---------------+-----------------------+-----------------------------------+
41| Parameter     | Requirement           | Description                       |
42+===============+=======================+===================================+
43| ``Sequence``  | |Forward Sequence|    | A sequence to search in.          |
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 find<s,t>::type i;
58
59
60:Return type:
61    |Forward Iterator|.
62
63:Semantics:
64    Equivalent to
65
66    .. parsed-literal::
67
68        typedef find_if<s, is_same<_,t> >::type i;
69
70
71Complexity
72----------
73
74Linear. At most ``size<s>::value`` comparisons for identity.
75
76
77Example
78-------
79
80.. parsed-literal::
81
82    typedef vector<char,int,unsigned,long,unsigned long> types;
83    typedef find<types,unsigned>::type iter;
84
85    BOOST_MPL_ASSERT(( is_same< deref<iter>::type, unsigned > ));
86    BOOST_MPL_ASSERT_RELATION( iter::pos::value, ==, 2 );
87
88
89See also
90--------
91
92|Querying Algorithms|, |contains|, |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