PageRenderTime 48ms CodeModel.GetById 42ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/range/algorithm/find.hpp

http://hadesmem.googlecode.com/
C++ Header | 80 lines | 54 code | 9 blank | 17 comment | 0 complexity | 70fa86607a308f1ac62704f44a03587f MD5 | raw file
 1//  Copyright Neil Groves 2009. Use, modification and
 2//  distribution is subject to the Boost Software License, Version
 3//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
 4//  http://www.boost.org/LICENSE_1_0.txt)
 5//
 6//
 7// For more information, see http://www.boost.org/libs/range/
 8//
 9#ifndef BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
10#define BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
11
12#include <boost/concept_check.hpp>
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15#include <boost/range/concepts.hpp>
16#include <boost/range/detail/range_return.hpp>
17#include <algorithm>
18
19namespace boost
20{
21    namespace range
22    {
23
24/// \brief template function find
25///
26/// range-based version of the find std algorithm
27///
28/// \pre SinglePassRange is a model of the SinglePassRangeConcept
29template< class SinglePassRange, class Value >
30inline BOOST_DEDUCED_TYPENAME disable_if<
31    is_const<SinglePassRange>,
32    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type
33>::type
34find( SinglePassRange& rng, const Value& val )
35{
36    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
37    return std::find(boost::begin(rng), boost::end(rng), val);
38}
39
40/// \overload
41template< class SinglePassRange, class Value >
42inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type
43find( const SinglePassRange& rng, const Value& val )
44{
45    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
46    return std::find(boost::begin(rng), boost::end(rng), val);
47}
48
49// range_return overloads
50
51/// \overload
52template< range_return_value re, class SinglePassRange, class Value >
53inline BOOST_DEDUCED_TYPENAME disable_if<
54    is_const<SinglePassRange>,
55    BOOST_DEDUCED_TYPENAME range_return<SinglePassRange,re>::type
56>::type
57find( SinglePassRange& rng, const Value& val )
58{
59    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
60    return range_return<SinglePassRange,re>::
61        pack(std::find(boost::begin(rng), boost::end(rng), val),
62             rng);
63}
64
65/// \overload
66template< range_return_value re, class SinglePassRange, class Value >
67inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange,re>::type
68find( const SinglePassRange& rng, const Value& val )
69{
70    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
71    return range_return<const SinglePassRange,re>::
72        pack(std::find(boost::begin(rng), boost::end(rng), val),
73             rng);
74}
75
76    } // namespace range
77    using range::find;
78}
79
80#endif // include guard