Debian Codegraph @

3rd_party/range-v3/range/v3/algorithm/upper_bound.hpp

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Eric Niebler 2014-present
5 // Copyright Casey Carter 2016
6 //
7 // Use, modification and distribution is subject to the
8 // Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11 //
12 // Project home: https://github.com/ericniebler/range-v3
13 //
14 #ifndef RANGES_V3_ALGORITHM_UPPER_BOUND_HPP
15 #define RANGES_V3_ALGORITHM_UPPER_BOUND_HPP
16
17 #include <range/v3/range_fwd.hpp>
18
19 #include <range/v3/algorithm/aux_/upper_bound_n.hpp>
20 #include <range/v3/algorithm/partition_point.hpp>
21 #include <range/v3/functional/comparisons.hpp>
22 #include <range/v3/functional/identity.hpp>
23 #include <range/v3/iterator/traits.hpp>
24 #include <range/v3/range/concepts.hpp>
25 #include <range/v3/range/dangling.hpp>
26 #include <range/v3/range/traits.hpp>
27 #include <range/v3/utility/static_const.hpp>
28
29 #include <range/v3/detail/prologue.hpp>
30
31 namespace ranges
32 {
33 /// \addtogroup group-algorithms
34 /// @{
35 RANGES_FUNC_BEGIN(upper_bound)
36
37 /// \brief function template \c upper_bound
38 template(typename I,
39 typename S,
40 typename V,
41 typename C = less,
42 typename P = identity)(
43 requires forward_iterator<I> AND sentinel_for<S, I> AND
44 indirect_strict_weak_order<C, V const *, projected<I, P>>)
45 constexpr I RANGES_FUNC(upper_bound)(
46 I first, S last, V const & val, C pred = C{}, P proj = P{}) //
47 {
48 return partition_point(std::move(first),
49 std::move(last),
50 detail::make_upper_bound_predicate(pred, val),
51 std::move(proj));
52 }
53
54 /// \overload
55 template(typename Rng, typename V, typename C = less, typename P = identity)(
56 requires forward_range<Rng> AND
57 indirect_strict_weak_order<C, V const *, projected<iterator_t<Rng>, P>>)
58 constexpr borrowed_iterator_t<Rng> RANGES_FUNC(upper_bound)(
59 Rng && rng, V const & val, C pred = C{}, P proj = P{}) //
60 {
61 return partition_point(
62 rng, detail::make_upper_bound_predicate(pred, val), std::move(proj));
63 }
64
65 RANGES_FUNC_END(upper_bound)
66
67 namespace cpp20
68 {
69 using ranges::upper_bound;
70 }
71 /// @}
72 } // namespace ranges
73
74 #include <range/v3/detail/epilogue.hpp>
75
76 #endif