PageRenderTime 91ms CodeModel.GetById 77ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://hadesmem.googlecode.com/
C++ Header | 134 lines | 98 code | 13 blank | 23 comment | 0 complexity | 52a5385188ac1ca1cd47b44485ccb8c3 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_SEARCH_HPP_INCLUDED
 10#define BOOST_RANGE_ALGORITHM_SEARCH_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 search
 25///
 26/// range-based version of the search std algorithm
 27///
 28/// \pre ForwardRange1 is a model of the ForwardRangeConcept
 29/// \pre ForwardRange2 is a model of the ForwardRangeConcept
 30/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
 31template< class ForwardRange1, class ForwardRange2 >
 32inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
 33search(ForwardRange1& rng1, const ForwardRange2& rng2)
 34{
 35    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
 36    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 37    return std::search(boost::begin(rng1),boost::end(rng1),
 38                       boost::begin(rng2),boost::end(rng2));
 39}
 40
 41/// \overload
 42template< class ForwardRange1, class ForwardRange2 >
 43inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
 44search(const ForwardRange1& rng1, const ForwardRange2& rng2)
 45{
 46    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
 47    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 48    return std::search(boost::begin(rng1), boost::end(rng1),
 49                       boost::begin(rng2), boost::end(rng2));
 50}
 51
 52/// \overload
 53template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
 54inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
 55search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
 56{
 57    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
 58    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 59    return std::search(boost::begin(rng1),boost::end(rng1),
 60                       boost::begin(rng2),boost::end(rng2),pred);
 61}
 62
 63/// \overload
 64template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
 65inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
 66search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
 67{
 68    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
 69    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 70    return std::search(boost::begin(rng1), boost::end(rng1),
 71                       boost::begin(rng2), boost::end(rng2), pred);
 72}
 73
 74// range_return overloads
 75
 76/// \overload
 77template< range_return_value re, class ForwardRange1, class ForwardRange2 >
 78inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
 79search(ForwardRange1& rng1, const ForwardRange2& rng2)
 80{
 81    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
 82    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 83    return range_return<ForwardRange1,re>::
 84        pack(std::search(boost::begin(rng1),boost::end(rng1),
 85                         boost::begin(rng2),boost::end(rng2)),
 86             rng1);
 87}
 88
 89/// \overload
 90template< range_return_value re, class ForwardRange1, class ForwardRange2 >
 91inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
 92search(const ForwardRange1& rng1, const ForwardRange2& rng2)
 93{
 94    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
 95    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
 96    return range_return<const ForwardRange1,re>::
 97        pack(std::search(boost::begin(rng1),boost::end(rng1),
 98                         boost::begin(rng2),boost::end(rng2)),
 99             rng1);
100}
101
102/// \overload
103template< range_return_value re, class ForwardRange1, class ForwardRange2,
104          class BinaryPredicate >
105inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
106search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
107{
108    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
109    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
110    return range_return<ForwardRange1,re>::
111        pack(std::search(boost::begin(rng1),boost::end(rng1),
112                         boost::begin(rng2),boost::end(rng2),pred),
113             rng1);
114}
115
116/// \overload
117template< range_return_value re, class ForwardRange1, class ForwardRange2,
118          class BinaryPredicate >
119inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
120search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
121{
122    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
123    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
124    return range_return<const ForwardRange1,re>::
125        pack(std::search(boost::begin(rng1),boost::end(rng1),
126                         boost::begin(rng2),boost::end(rng2),pred),
127             rng1);
128}
129
130    } // namespace range
131    using range::search;
132} // namespace boost
133
134#endif // include guard