Horizon
Loading...
Searching...
No Matches
upper_bound_n.hpp
Go to the documentation of this file.
1
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_AUX_UPPER_BOUND_N_HPP
15#define RANGES_V3_ALGORITHM_AUX_UPPER_BOUND_N_HPP
16
18
24#include <range/v3/utility/static_const.hpp>
25
26#include <range/v3/detail/prologue.hpp>
27
28namespace ranges
29{
31 namespace detail
32 {
33 // [&](auto&& i){ return !invoke(pred, val, i); }
34 template<typename Pred, typename Val>
35 struct upper_bound_predicate
36 {
37 Pred & pred_;
38 Val & val_;
39
40 template<typename T>
41 constexpr bool operator()(T && t) const
42 {
43 return !invoke(pred_, val_, static_cast<T &&>(t));
44 }
45 };
46
47 template<typename Pred, typename Val>
48 constexpr upper_bound_predicate<Pred, Val> make_upper_bound_predicate(Pred & pred,
49 Val & val)
50 {
51 return {pred, val};
52 }
53 } // namespace detail
55
56 namespace aux
57 {
59 {
65 template(typename I, typename V, typename C = less, typename P = identity)(
66 requires forward_iterator<I> AND
67 indirect_strict_weak_order<C, V const *, projected<I, P>>)
68 constexpr I operator()(I first,
69 iter_difference_t<I> d,
70 V const & val,
71 C pred = C{},
72 P proj = P{}) const
73 {
74 return partition_point_n(std::move(first),
75 d,
76 detail::make_upper_bound_predicate(pred, val),
77 std::move(proj));
78 }
79 };
80
81 RANGES_INLINE_VARIABLE(upper_bound_n_fn, upper_bound_n)
82 } // namespace aux
83} // namespace ranges
84
85#include <range/v3/detail/epilogue.hpp>
86
87#endif
The forward_iterator concept.
The indirect_strict_weak_order concept.
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
Definition upper_bound_n.hpp:59
Definition identity.hpp:25
Definition comparisons.hpp:50