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_UPPER_BOUND_N_HPP
0015 #define RANGES_V3_ALGORITHM_AUX_UPPER_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 upper_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_, val_, static_cast<T &&>(t));
0044 }
0045 };
0046
0047 template<typename Pred, typename Val>
0048 constexpr upper_bound_predicate<Pred, Val> make_upper_bound_predicate(Pred & pred,
0049 Val & val)
0050 {
0051 return {pred, val};
0052 }
0053 }
0054
0055
0056 namespace aux
0057 {
0058 struct upper_bound_n_fn
0059 {
0060
0061
0062
0063
0064
0065 template(typename I, typename V, typename C = less, typename P = identity)(
0066 requires forward_iterator<I> AND
0067 indirect_strict_weak_order<C, V const *, projected<I, P>>)
0068 constexpr I operator()(I first,
0069 iter_difference_t<I> d,
0070 V const & val,
0071 C pred = C{},
0072 P proj = P{}) const
0073 {
0074 return partition_point_n(std::move(first),
0075 d,
0076 detail::make_upper_bound_predicate(pred, val),
0077 std::move(proj));
0078 }
0079 };
0080
0081 RANGES_INLINE_VARIABLE(upper_bound_n_fn, upper_bound_n)
0082 }
0083 }
0084
0085 #include <range/v3/detail/epilogue.hpp>
0086
0087 #endif