Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:59:16

0001 //  Copyright Neil Groves 2009. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
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 /// \brief template function adjacent_find
0026 ///
0027 /// range-based version of the adjacent_find std algorithm
0028 ///
0029 /// \pre ForwardRange is a model of the ForwardRangeConcept
0030 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
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 /// \overload
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 /// \overload
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 /// \overload
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 //  range_return overloads
0073 
0074 /// \overload
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 /// \overload
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 /// \overload
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 /// \overload
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     } // namespace range
0122     using range::adjacent_find;
0123 } // namespace boost
0124 
0125 #endif // include guard