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