PageRenderTime 31ms CodeModel.GetById 20ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/range/algorithm/lower_bound.hpp

http://hadesmem.googlecode.com/
C++ Header | 124 lines | 92 code | 12 blank | 20 comment | 0 complexity | a9055711d714ea65e5905682af53fd76 MD5 | raw file
  1//  Copyright Neil Groves 2009. Use, modification and
  2//  distribution is subject to the Boost Software License, Version
  3//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4//  http://www.boost.org/LICENSE_1_0.txt)
  5//
  6//
  7// For more information, see http://www.boost.org/libs/range/
  8//
  9#ifndef BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
 10#define BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
 11
 12#include <boost/concept_check.hpp>
 13#include <boost/range/begin.hpp>
 14#include <boost/range/end.hpp>
 15#include <boost/range/concepts.hpp>
 16#include <boost/range/detail/range_return.hpp>
 17#include <algorithm>
 18
 19namespace boost
 20{
 21    namespace range
 22    {
 23
 24/// \brief template function lower_bound
 25///
 26/// range-based version of the lower_bound std algorithm
 27///
 28/// \pre ForwardRange is a model of the ForwardRangeConcept
 29template< class ForwardRange, class Value >
 30inline BOOST_DEDUCED_TYPENAME disable_if<
 31    is_const<ForwardRange>,
 32    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
 33>::type
 34lower_bound( ForwardRange& rng, Value val )
 35{
 36    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
 37    return std::lower_bound(boost::begin(rng), boost::end(rng), val);
 38}
 39
 40/// \overload
 41template< class ForwardRange, class Value >
 42inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
 43lower_bound( const ForwardRange& rng, Value val )
 44{
 45    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
 46    return std::lower_bound(boost::begin(rng), boost::end(rng), val);
 47}
 48
 49/// \overload
 50template< class ForwardRange, class Value, class SortPredicate >
 51inline BOOST_DEDUCED_TYPENAME disable_if<
 52    is_const<ForwardRange>,
 53    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
 54>::type
 55lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
 56{
 57    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
 58    return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
 59}
 60
 61/// \overload
 62template< class ForwardRange, class Value, class SortPredicate >
 63inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
 64lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
 65{
 66    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
 67    return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
 68}
 69
 70/// \overload
 71template< range_return_value re, class ForwardRange, class Value >
 72inline BOOST_DEDUCED_TYPENAME disable_if<
 73    is_const<ForwardRange>,
 74    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
 75>::type
 76lower_bound( ForwardRange& rng, Value val )
 77{
 78    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
 79    return range_return<ForwardRange,re>::
 80        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
 81             rng);
 82}
 83
 84/// \overload
 85template< range_return_value re, class ForwardRange, class Value >
 86inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
 87lower_bound( const ForwardRange& rng, Value val )
 88{
 89    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
 90    return range_return<const ForwardRange,re>::
 91        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
 92             rng);
 93}
 94
 95/// \overload
 96template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
 97inline BOOST_DEDUCED_TYPENAME disable_if<
 98    is_const<ForwardRange>,
 99    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
100>::type
101lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
102{
103    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
104    return range_return<ForwardRange,re>::
105        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
106             rng);
107}
108
109/// \overload
110template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
111inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
112lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
113{
114    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
115    return range_return<const ForwardRange,re>::
116        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
117             rng);
118}
119
120    } // namespace range
121    using range::lower_bound;
122} // namespace boost
123
124#endif // include guard