| 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 | #include <forward_list> |
| 20 | #include <iterator> |
| 21 | #include <algorithm> |
| 22 | #include <cassert> |
| 23 | |
| 24 | #include "test_macros.h" |
| 25 | #include "min_allocator.h" |
| 26 | |
| 27 | template <class C> |
| 28 | TEST_CONSTEXPR_CXX26 void test(int N, int M) { |
| 29 | C c1; |
| 30 | for (int i = 0; i < N; ++i) |
| 31 | c1.push_front(i); |
| 32 | C c2; |
| 33 | for (int i = 0; i < M; ++i) |
| 34 | c2.push_front(i); |
| 35 | if (N == M) |
| 36 | assert(c1 == c2); |
| 37 | else |
| 38 | assert(c1 != c2); |
| 39 | c2 = c1; |
| 40 | assert(c1 == c2); |
| 41 | if (N > 0) { |
| 42 | c2.front() = N + 1; |
| 43 | assert(c1 != c2); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | TEST_CONSTEXPR_CXX26 bool test() { |
| 48 | for (int i = 0; i < 10; ++i) |
| 49 | for (int j = 0; j < 10; ++j) |
| 50 | test<std::forward_list<int> >(i, j); |
| 51 | #if TEST_STD_VER >= 11 |
| 52 | for (int i = 0; i < 10; ++i) |
| 53 | for (int j = 0; j < 10; ++j) |
| 54 | test<std::forward_list<int, min_allocator<int>> >(i, j); |
| 55 | #endif |
| 56 | |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | int main(int, char**) { |
| 61 | assert(test()); |
| 62 | #if TEST_STD_VER >= 26 |
| 63 | static_assert(test()); |
| 64 | #endif |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |