File indexing completed on 2025-01-30 09:59:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
0011
0012 #include <boost/concept_check.hpp>
0013 #include <boost/range/begin.hpp>
0014 #include <boost/range/end.hpp>
0015 #include <boost/range/concepts.hpp>
0016 #include <boost/range/detail/range_return.hpp>
0017 #include <algorithm>
0018
0019 namespace boost
0020 {
0021 namespace range
0022 {
0023
0024
0025
0026
0027
0028
0029
0030
0031 template< class ForwardRange1, class ForwardRange2 >
0032 inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
0033 search(ForwardRange1& rng1, const ForwardRange2& rng2)
0034 {
0035 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0036 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0037 return std::search(boost::begin(rng1),boost::end(rng1),
0038 boost::begin(rng2),boost::end(rng2));
0039 }
0040
0041
0042 template< class ForwardRange1, class ForwardRange2 >
0043 inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
0044 search(const ForwardRange1& rng1, const ForwardRange2& rng2)
0045 {
0046 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0047 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0048 return std::search(boost::begin(rng1), boost::end(rng1),
0049 boost::begin(rng2), boost::end(rng2));
0050 }
0051
0052
0053 template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
0054 inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
0055 search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0056 {
0057 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0058 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0059 return std::search(boost::begin(rng1),boost::end(rng1),
0060 boost::begin(rng2),boost::end(rng2),pred);
0061 }
0062
0063
0064 template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
0065 inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
0066 search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0067 {
0068 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0069 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0070 return std::search(boost::begin(rng1), boost::end(rng1),
0071 boost::begin(rng2), boost::end(rng2), pred);
0072 }
0073
0074
0075
0076
0077 template< range_return_value re, class ForwardRange1, class ForwardRange2 >
0078 inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
0079 search(ForwardRange1& rng1, const ForwardRange2& rng2)
0080 {
0081 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0082 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0083 return range_return<ForwardRange1,re>::
0084 pack(std::search(boost::begin(rng1),boost::end(rng1),
0085 boost::begin(rng2),boost::end(rng2)),
0086 rng1);
0087 }
0088
0089
0090 template< range_return_value re, class ForwardRange1, class ForwardRange2 >
0091 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
0092 search(const ForwardRange1& rng1, const ForwardRange2& rng2)
0093 {
0094 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0095 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0096 return range_return<const ForwardRange1,re>::
0097 pack(std::search(boost::begin(rng1),boost::end(rng1),
0098 boost::begin(rng2),boost::end(rng2)),
0099 rng1);
0100 }
0101
0102
0103 template< range_return_value re, class ForwardRange1, class ForwardRange2,
0104 class BinaryPredicate >
0105 inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
0106 search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0107 {
0108 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
0109 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0110 return range_return<ForwardRange1,re>::
0111 pack(std::search(boost::begin(rng1),boost::end(rng1),
0112 boost::begin(rng2),boost::end(rng2),pred),
0113 rng1);
0114 }
0115
0116
0117 template< range_return_value re, class ForwardRange1, class ForwardRange2,
0118 class BinaryPredicate >
0119 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
0120 search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
0121 {
0122 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
0123 BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
0124 return range_return<const ForwardRange1,re>::
0125 pack(std::search(boost::begin(rng1),boost::end(rng1),
0126 boost::begin(rng2),boost::end(rng2),pred),
0127 rng1);
0128 }
0129
0130 }
0131 using range::search;
0132 }
0133
0134 #endif