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