File indexing completed on 2025-12-16 10:27:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef RANGES_V3_ALGORITHM_AUX_LOWER_BOUND_N_HPP
0015 #define RANGES_V3_ALGORITHM_AUX_LOWER_BOUND_N_HPP
0016
0017 #include <range/v3/range_fwd.hpp>
0018
0019 #include <range/v3/algorithm/aux_/partition_point_n.hpp>
0020 #include <range/v3/functional/comparisons.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/iterator/traits.hpp>
0024 #include <range/v3/utility/static_const.hpp>
0025
0026 #include <range/v3/detail/prologue.hpp>
0027
0028 namespace ranges
0029 {
0030
0031 namespace detail
0032 {
0033
0034 template<typename Pred, typename Val>
0035 struct lower_bound_predicate
0036 {
0037 Pred & pred_;
0038 Val & val_;
0039
0040 template<typename T>
0041 constexpr bool operator()(T && t) const
0042 {
0043 return invoke(pred_, static_cast<T &&>(t), val_);
0044 }
0045 };
0046
0047 template<typename Pred, typename Val>
0048 constexpr lower_bound_predicate<Pred, Val> make_lower_bound_predicate(Pred & pred,
0049 Val & val)
0050 {
0051 return {pred, val};
0052 }
0053 }
0054
0055
0056 namespace aux
0057 {
0058 struct lower_bound_n_fn
0059 {
0060 template(typename I, typename V, typename C = less, typename P = identity)(
0061 requires forward_iterator<I> AND
0062 indirect_strict_weak_order<C, V const *, projected<I, P>>)
0063 constexpr I operator()(I first,
0064 iter_difference_t<I> d,
0065 V const & val,
0066 C pred = C{},
0067 P proj = P{}) const
0068 {
0069 return partition_point_n(std::move(first),
0070 d,
0071 detail::make_lower_bound_predicate(pred, val),
0072 std::move(proj));
0073 }
0074 };
0075
0076 RANGES_INLINE_VARIABLE(lower_bound_n_fn, lower_bound_n)
0077 }
0078 }
0079
0080 #include <range/v3/detail/epilogue.hpp>
0081
0082 #endif