tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_sorted.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_ALGORITHM_IS_SORTED_HPP
5#define TETL_ALGORITHM_IS_SORTED_HPP
6
7#include <etl/_algorithm/is_sorted_until.hpp>
8
9namespace etl {
10
11/// \brief Checks if the elements in range `[first, last)` are sorted in non-descending order.
12/// \ingroup algorithm
13template <typename ForwardIt>
14[[nodiscard]] constexpr auto is_sorted(ForwardIt first, ForwardIt last) -> bool
15{
16 return etl::is_sorted_until(first, last) == last;
17}
18
19/// \ingroup algorithm
20template <typename ForwardIt, typename Compare>
21[[nodiscard]] constexpr auto is_sorted(ForwardIt first, ForwardIt last, Compare comp) -> bool
22{
23 return etl::is_sorted_until(first, last, comp) == last;
24}
25
26} // namespace etl
27
28#endif // TETL_ALGORITHM_IS_SORTED_HPP
constexpr auto is_sorted(ForwardIt first, ForwardIt last) -> bool
Checks if the elements in range [first, last) are sorted in non-descending order.
Definition is_sorted.hpp:14
constexpr auto is_sorted(ForwardIt first, ForwardIt last, Compare comp) -> bool
Definition is_sorted.hpp:21
Definition adjacent_find.hpp:9