File indexing completed on 2025-12-16 10:27:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef RANGES_V3_ALGORITHM_IS_SORTED_UNTIL_HPP
0017 #define RANGES_V3_ALGORITHM_IS_SORTED_UNTIL_HPP
0018
0019 #include <range/v3/range_fwd.hpp>
0020
0021 #include <range/v3/functional/comparisons.hpp>
0022 #include <range/v3/functional/identity.hpp>
0023 #include <range/v3/functional/invoke.hpp>
0024 #include <range/v3/iterator/concepts.hpp>
0025 #include <range/v3/range/access.hpp>
0026 #include <range/v3/range/concepts.hpp>
0027 #include <range/v3/range/dangling.hpp>
0028 #include <range/v3/range/traits.hpp>
0029 #include <range/v3/utility/static_const.hpp>
0030
0031 #include <range/v3/detail/prologue.hpp>
0032
0033 namespace ranges
0034 {
0035
0036
0037 RANGES_FUNC_BEGIN(is_sorted_until)
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 template(typename I, typename S, typename R = less, typename P = identity)(
0051 requires forward_iterator<I> AND sentinel_for<S, I> AND
0052 indirect_strict_weak_order<R, projected<I, P>>)
0053 constexpr I RANGES_FUNC(is_sorted_until)(I first, S last, R pred = R{}, P proj = P{})
0054 {
0055 auto i = first;
0056 if(first != last)
0057 {
0058 while(++i != last)
0059 {
0060 if(invoke(pred, invoke(proj, *i), invoke(proj, *first)))
0061 return i;
0062 first = i;
0063 }
0064 }
0065 return i;
0066 }
0067
0068
0069 template(typename Rng, typename R = less, typename P = identity)(
0070 requires forward_range<Rng> AND
0071 indirect_strict_weak_order<R, projected<iterator_t<Rng>, P>>)
0072 constexpr borrowed_iterator_t<Rng>
0073 RANGES_FUNC(is_sorted_until)(Rng && rng, R pred = R{}, P proj = P{})
0074 {
0075 return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
0076 }
0077
0078 RANGES_FUNC_END(is_sorted_until)
0079
0080 namespace cpp20
0081 {
0082 using ranges::is_sorted_until;
0083 }
0084
0085 }
0086
0087 #include <range/v3/detail/epilogue.hpp>
0088
0089 #endif