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_EQUAL_RANGE_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_EQUAL_RANGE_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 <algorithm>
0017 
0018 namespace boost
0019 {
0020     namespace range
0021     {
0022 
0023 /// \brief template function equal_range
0024 ///
0025 /// range-based version of the equal_range std algorithm
0026 ///
0027 /// \pre ForwardRange is a model of the ForwardRangeConcept
0028 /// \pre SortPredicate is a model of the BinaryPredicateConcept
0029 template<class ForwardRange, class Value>
0030 inline std::pair<
0031         BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
0032         BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
0033        >
0034 equal_range(ForwardRange& rng, const Value& val)
0035 {
0036     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0037     return std::equal_range(boost::begin(rng), boost::end(rng), val);
0038 }
0039 
0040 /// \overload
0041 template<class ForwardRange, class Value>
0042 inline std::pair<
0043         BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
0044         BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
0045        >
0046 equal_range(const ForwardRange& rng, const Value& val)
0047 {
0048     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0049     return std::equal_range(boost::begin(rng), boost::end(rng), val);
0050 }
0051 
0052 /// \overload
0053 template<class ForwardRange, class Value, class SortPredicate>
0054 inline std::pair<
0055         BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
0056         BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
0057        >
0058 equal_range(ForwardRange& rng, const Value& val, SortPredicate pred)
0059 {
0060     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0061     return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
0062 }
0063 
0064 /// \overload
0065 template<class ForwardRange, class Value, class SortPredicate>
0066 inline std::pair<
0067         BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
0068         BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
0069        >
0070 equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred)
0071 {
0072     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0073     return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
0074 }
0075 
0076     } // namespace range
0077     using range::equal_range;
0078 } // namespace boost
0079 
0080 #endif // include guard