Chris@16: // Copyright Neil Groves 2009. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: #ifndef BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range Chris@16: { Chris@16: Chris@16: /// \brief template function adjacent_find Chris@16: /// Chris@16: /// range-based version of the adjacent_find std algorithm Chris@16: /// Chris@16: /// \pre ForwardRange is a model of the ForwardRangeConcept Chris@16: /// \pre BinaryPredicate is a model of the BinaryPredicateConcept Chris@16: template< typename ForwardRange > Chris@16: inline typename range_iterator::type Chris@16: adjacent_find(ForwardRange & rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: return std::adjacent_find(boost::begin(rng),boost::end(rng)); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< typename ForwardRange > Chris@16: inline typename range_iterator::type Chris@16: adjacent_find(const ForwardRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: return std::adjacent_find(boost::begin(rng),boost::end(rng)); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< typename ForwardRange, typename BinaryPredicate > Chris@16: inline typename range_iterator::type Chris@16: adjacent_find(ForwardRange & rng, BinaryPredicate pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, Chris@16: typename range_value::type>)); Chris@16: return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< typename ForwardRange, typename BinaryPredicate > Chris@16: inline typename range_iterator::type Chris@16: adjacent_find(const ForwardRange& rng, BinaryPredicate pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, Chris@16: typename range_value::type>)); Chris@16: return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); Chris@16: } Chris@16: Chris@16: // range_return overloads Chris@16: Chris@16: /// \overload Chris@16: template< range_return_value re, typename ForwardRange > Chris@16: inline typename range_return::type Chris@16: adjacent_find(ForwardRange & rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: return range_return:: Chris@16: pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), Chris@16: rng); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< range_return_value re, typename ForwardRange > Chris@16: inline typename range_return::type Chris@16: adjacent_find(const ForwardRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: return range_return:: Chris@16: pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), Chris@16: rng); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< range_return_value re, typename ForwardRange, typename BinaryPredicate > Chris@16: inline typename range_return::type Chris@16: adjacent_find(ForwardRange& rng, BinaryPredicate pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, Chris@16: typename range_value::type>)); Chris@16: return range_return:: Chris@16: pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), Chris@16: rng); Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template< range_return_value re, typename ForwardRange, typename BinaryPredicate > Chris@16: inline typename range_return::type Chris@16: adjacent_find(const ForwardRange& rng, BinaryPredicate pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); Chris@16: return range_return:: Chris@16: pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), Chris@16: rng); Chris@16: } Chris@16: Chris@16: } // namespace range Chris@16: using range::adjacent_find; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard