Debian Codegraph @

3rd_party/range-v3/range/v3/algorithm/lower_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_LOWER_BOUND_HPP
15 #define RANGES_V3_ALGORITHM_LOWER_BOUND_HPP
16
17 #include <range/v3/range_fwd.hpp>
18
19 #include <range/v3/algorithm/aux_/lower_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/operations.hpp>
24 #include <range/v3/iterator/traits.hpp>
25 #include <range/v3/range/access.hpp>
26 #include <range/v3/range/concepts.hpp>
27 #include <range/v3/range/dangling.hpp>
28 #include <range/v3/range/traits.hpp>
29 #include <range/v3/utility/static_const.hpp>
30
31 #include <range/v3/detail/prologue.hpp>
32
33 namespace ranges
34 {
35 /// \addtogroup group-algorithms
36 /// @{
37 RANGES_FUNC_BEGIN(lower_bound)
38
39 /// \brief function template \c lower_bound
40 template(typename I,
41 typename S,
42 typename V,
43 typename C = less,
44 typename P = identity)(
45 requires forward_iterator<I> AND sentinel_for<S, I> AND
46 indirect_strict_weak_order<C, V const *, projected<I, P>>)
47 constexpr I RANGES_FUNC(lower_bound)(I first,
48 S last,
49 V const & val,
50 C pred = C{},
51 P proj = P{})
52 {
53 return partition_point(std::move(first),
54 std::move(last),
55 detail::make_lower_bound_predicate(pred, val),
56 std::move(proj));
57 }
58
59 /// \overload
60 template(typename Rng, typename V, typename C = less, typename P = identity)(
61 requires forward_range<Rng> AND
62 indirect_strict_weak_order<C, V const *, projected<iterator_t<Rng>, P>>)
63 constexpr borrowed_iterator_t<Rng> //
64 RANGES_FUNC(lower_bound)(Rng && rng, V const & val, C pred = C{}, P proj = P{})
65 {
66 return partition_point(
67 rng, detail::make_lower_bound_predicate(pred, val), std::move(proj));
68 }
69
70 RANGES_FUNC_END(lower_bound)
71
72 namespace cpp20
73 {
74 using ranges::lower_bound;
75 }
76 /// @}
77 } // namespace ranges
78
79 #include <range/v3/detail/epilogue.hpp>
80
81 #endif