tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
sort.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_SORT_HPP
5#define TETL_ALGORITHM_SORT_HPP
6
7#include <etl/_algorithm/insertion_sort.hpp>
8
9namespace etl {
10
11/// \ingroup algorithm
12/// @{
13
14/// Sorts the elements in the range `[first, last)` in non-descending
15/// order. The order of equal elements is not guaranteed to be preserved.
16///
17/// https://en.cppreference.com/w/cpp/algorithm/sort
18template <typename RandomIt, typename Compare>
19constexpr auto sort(RandomIt first, RandomIt last, Compare comp) -> void
20{
21 etl::insertion_sort(first, last, comp);
22}
23
24template <typename RandomIt>
25constexpr auto sort(RandomIt first, RandomIt last) -> void
26{
27 etl::sort(first, last, etl::less());
28}
29
30/// @}
31
32} // namespace etl
33
34#endif // TETL_ALGORITHM_SORT_HPP
constexpr auto sort(RandomIt first, RandomIt last) -> void
Definition sort.hpp:25
constexpr auto sort(RandomIt first, RandomIt last, Compare comp) -> void
Definition sort.hpp:19
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15