Back to home page

EIC code displayed by LXR

 
 

    


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

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_UPPER_BOUND_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_UPPER_BOUND_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 /// \brief template function upper_bound
0025 ///
0026 /// range-based version of the upper_bound std algorithm
0027 ///
0028 /// \pre ForwardRange is a model of the ForwardRangeConcept
0029 template< class ForwardRange, class Value >
0030 inline
0031 BOOST_DEDUCED_TYPENAME disable_if<
0032     is_const<ForwardRange>,
0033     BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
0034 >::type
0035 upper_bound( ForwardRange& rng, const Value& val )
0036 {
0037     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0038     return std::upper_bound(boost::begin(rng), boost::end(rng), val);
0039 }
0040 
0041 /// \overload
0042 template< class ForwardRange, class Value >
0043 BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
0044 upper_bound( const ForwardRange& rng, const Value& val )
0045 {
0046     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0047     return std::upper_bound(boost::begin(rng), boost::end(rng), val);
0048 }
0049 
0050 /// \overload
0051 template< class ForwardRange, class Value, class SortPredicate >
0052 inline BOOST_DEDUCED_TYPENAME disable_if<
0053     is_const<ForwardRange>,
0054     BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
0055 >::type
0056 upper_bound( ForwardRange& rng, const Value& val, SortPredicate pred )
0057 {
0058     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0059     return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
0060 }
0061 
0062 /// \overload
0063 template< class ForwardRange, class Value, class SortPredicate >
0064 inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
0065 upper_bound( const ForwardRange& rng, const Value& val, SortPredicate pred )
0066 {
0067     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0068     return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
0069 }
0070 
0071 /// \overload
0072 template< range_return_value re, class ForwardRange, class Value >
0073 inline BOOST_DEDUCED_TYPENAME disable_if<
0074     is_const<ForwardRange>,
0075     BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
0076 >::type
0077 upper_bound( ForwardRange& rng, const Value& val )
0078 {
0079     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0080     return range_return<ForwardRange,re>::
0081         pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
0082              rng);
0083 }
0084 
0085 /// \overload
0086 template< range_return_value re, class ForwardRange, class Value >
0087 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
0088 upper_bound( const ForwardRange& rng, const Value& val )
0089 {
0090     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0091     return range_return<const ForwardRange,re>::
0092         pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
0093              rng);
0094 }
0095 
0096 /// \overload
0097 template< range_return_value re, class ForwardRange, class Value,
0098           class SortPredicate >
0099 inline BOOST_DEDUCED_TYPENAME disable_if<
0100     is_const<ForwardRange>,
0101     BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
0102 >::type
0103 upper_bound( ForwardRange& rng, const Value& val, SortPredicate pred )
0104 {
0105     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
0106     return range_return<ForwardRange,re>::
0107         pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
0108              rng);
0109 }
0110 
0111 /// \overload
0112 template< range_return_value re, class ForwardRange, class Value,
0113           class SortPredicate >
0114 inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
0115 upper_bound( const ForwardRange& rng, const Value& val, SortPredicate pred )
0116 {
0117     BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
0118     return range_return<const ForwardRange,re>::
0119         pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
0120              rng);
0121 }
0122 
0123     } // namespace range
0124     using range::upper_bound;
0125 } // namespace boost
0126 
0127 #endif // include guard