| 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 | // <forward_list> |
| 10 | |
| 11 | // template <class T, class Allocator> |
| 12 | // bool operator< (const forward_list<T, Allocator>& x, |
| 13 | // const forward_list<T, Allocator>& y); // constexpr since C++26 |
| 14 | // |
| 15 | // template <class T, class Allocator> |
| 16 | // bool operator> (const forward_list<T, Allocator>& x, |
| 17 | // const forward_list<T, Allocator>& y); // constexpr since C++26 |
| 18 | // |
| 19 | // template <class T, class Allocator> |
| 20 | // bool operator>=(const forward_list<T, Allocator>& x, |
| 21 | // const forward_list<T, Allocator>& y); // constexpr since C++26 |
| 22 | // |
| 23 | // template <class T, class Allocator> |
| 24 | // bool operator<=(const forward_list<T, Allocator>& x, |
| 25 | // const forward_list<T, Allocator>& y); // constexpr since C++26 |
| 26 | |
| 27 | #include <forward_list> |
| 28 | #include <iterator> |
| 29 | #include <algorithm> |
| 30 | #include <cassert> |
| 31 | |
| 32 | #include "test_macros.h" |
| 33 | #include "min_allocator.h" |
| 34 | |
| 35 | template <class C> |
| 36 | TEST_CONSTEXPR_CXX26 void test(int N, int M) { |
| 37 | C c1; |
| 38 | for (int i = 0; i < N; ++i) |
| 39 | c1.push_front(i); |
| 40 | C c2; |
| 41 | for (int i = 0; i < M; ++i) |
| 42 | c2.push_front(i); |
| 43 | if (N < M) |
| 44 | assert(c1 < c2); |
| 45 | if (N <= M) |
| 46 | assert(c1 <= c2); |
| 47 | if (N >= M) |
| 48 | assert(c1 >= c2); |
| 49 | if (N > M) |
| 50 | assert(c1 > c2); |
| 51 | } |
| 52 | |
| 53 | TEST_CONSTEXPR_CXX26 bool test() { |
| 54 | for (int i = 0; i < 10; ++i) |
| 55 | for (int j = 0; j < 10; ++j) |
| 56 | test<std::forward_list<int> >(i, j); |
| 57 | #if TEST_STD_VER >= 11 |
| 58 | for (int i = 0; i < 10; ++i) |
| 59 | for (int j = 0; j < 10; ++j) |
| 60 | test<std::forward_list<int, min_allocator<int>> >(i, j); |
| 61 | #endif |
| 62 | |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | int main(int, char**) { |
| 67 | assert(test()); |
| 68 | #if TEST_STD_VER >= 26 |
| 69 | static_assert(test()); |
| 70 | #endif |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |