Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:56

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2014-present
0005 //  Copyright Casey Carter 2016
0006 //
0007 //  Use, modification and distribution is subject to the
0008 //  Boost Software License, Version 1.0. (See accompanying
0009 //  file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // Project home: https://github.com/ericniebler/range-v3
0013 //
0014 #ifndef RANGES_V3_ALGORITHM_UPPER_BOUND_HPP
0015 #define RANGES_V3_ALGORITHM_UPPER_BOUND_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/algorithm/aux_/upper_bound_n.hpp>
0020 #include <range/v3/algorithm/partition_point.hpp>
0021 #include <range/v3/functional/comparisons.hpp>
0022 #include <range/v3/functional/identity.hpp>
0023 #include <range/v3/iterator/traits.hpp>
0024 #include <range/v3/range/concepts.hpp>
0025 #include <range/v3/range/dangling.hpp>
0026 #include <range/v3/range/traits.hpp>
0027 #include <range/v3/utility/static_const.hpp>
0028 
0029 #include <range/v3/detail/prologue.hpp>
0030 
0031 namespace ranges
0032 {
0033     /// \addtogroup group-algorithms
0034     /// @{
0035     RANGES_FUNC_BEGIN(upper_bound)
0036 
0037         /// \brief function template \c upper_bound
0038         template(typename I,
0039                  typename S,
0040                  typename V,
0041                  typename C = less,
0042                  typename P = identity)(
0043             requires forward_iterator<I> AND sentinel_for<S, I> AND
0044                 indirect_strict_weak_order<C, V const *, projected<I, P>>)
0045         constexpr I RANGES_FUNC(upper_bound)(
0046             I first, S last, V const & val, C pred = C{}, P proj = P{}) //
0047         {
0048             return partition_point(std::move(first),
0049                                    std::move(last),
0050                                    detail::make_upper_bound_predicate(pred, val),
0051                                    std::move(proj));
0052         }
0053 
0054         /// \overload
0055         template(typename Rng, typename V, typename C = less, typename P = identity)(
0056             requires forward_range<Rng> AND
0057                 indirect_strict_weak_order<C, V const *, projected<iterator_t<Rng>, P>>)
0058         constexpr borrowed_iterator_t<Rng> RANGES_FUNC(upper_bound)(
0059             Rng && rng, V const & val, C pred = C{}, P proj = P{}) //
0060         {
0061             return partition_point(
0062                 rng, detail::make_upper_bound_predicate(pred, val), std::move(proj));
0063         }
0064 
0065     RANGES_FUNC_END(upper_bound)
0066 
0067     namespace cpp20
0068     {
0069         using ranges::upper_bound;
0070     }
0071     /// @}
0072 } // namespace ranges
0073 
0074 #include <range/v3/detail/epilogue.hpp>
0075 
0076 #endif