Horizon
Loading...
Searching...
No Matches
is_sorted.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2013-present
5// Copyright Gonzalo Brito Gadeschi 2014
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// Implementation based on the code in libc++
15// http://http://libcxx.llvm.org/
16#ifndef RANGES_V3_ALGORITHM_IS_SORTED_HPP
17#define RANGES_V3_ALGORITHM_IS_SORTED_HPP
18
19#include <utility>
20
22
27#include <range/v3/utility/static_const.hpp>
28
29#include <range/v3/detail/prologue.hpp>
30
31namespace ranges
32{
35 RANGES_FUNC_BEGIN(is_sorted)
48 template(typename I, typename S, typename R = less, typename P = identity)(
49 requires forward_iterator<I> AND sentinel_for<S, I> AND
50 indirect_strict_weak_order<R, projected<I, P>>)
51 constexpr bool RANGES_FUNC(is_sorted)(I first, S last, R rel = R{}, P proj = P{})
52 {
53 return is_sorted_until(
54 std::move(first), last, std::move(rel), std::move(proj)) == last;
55 }
56
58 template(typename Rng, typename R = less, typename P = identity)(
59 requires forward_range<Rng> AND
60 indirect_strict_weak_order<R, projected<iterator_t<Rng>, P>>)
61 constexpr bool RANGES_FUNC(is_sorted)(Rng && rng, R rel = R{}, P proj = P{}) //
62 {
63 return (*this)(begin(rng), end(rng), std::move(rel), std::move(proj));
64 }
65
66 RANGES_FUNC_END(is_sorted)
67
68 namespace cpp20
69 {
70 using ranges::is_sorted;
71 }
73} // namespace ranges
74
75#include <range/v3/detail/epilogue.hpp>
76
77#endif
front< Pair > first
Retrieve the first element of the pair Pair.
Definition meta.hpp:2251
bool_<(T::type::value< U::type::value)> less
A Boolean integral constant wrapper around true if T::type::value is less than U::type::value; false,...
Definition meta.hpp:255