1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <algorithm> |
10 | |
11 | #include <algorithm> |
12 | #include <functional> |
13 | |
14 | #include "test_macros.h" |
15 | |
16 | struct A { |
17 | int i = 0; |
18 | TEST_CONSTEXPR bool operator<(const A& rhs) const { return i < rhs.i; } |
19 | static TEST_CONSTEXPR bool isEven(const A& a) { return a.i % 2 == 0; } |
20 | }; |
21 | |
22 | void *operator new(std::size_t, A*) = delete; |
23 | |
24 | TEST_CONSTEXPR_CXX20 bool test() { |
25 | A a[4] = {}; |
26 | std::sort(first: a, last: a + 4); |
27 | std::sort(first: a, last: a + 4, comp: std::less<A>()); |
28 | std::partition(a, a + 4, A::isEven); |
29 | if (TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED) { |
30 | std::stable_sort(first: a, last: a + 4); |
31 | std::stable_sort(first: a, last: a + 4, comp: std::less<A>()); |
32 | std::stable_partition(a, a + 4, A::isEven); |
33 | std::inplace_merge(first: a, middle: a + 2, last: a + 4); |
34 | std::inplace_merge(first: a, middle: a + 2, last: a + 4, comp: std::less<A>()); |
35 | } |
36 | |
37 | return true; |
38 | } |
39 | |
40 | int main(int, char**) { |
41 | test(); |
42 | #if TEST_STD_VER >= 20 |
43 | static_assert(test()); |
44 | #endif |
45 | |
46 | return 0; |
47 | } |
48 |