| 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 | // <list> |
| 10 | |
| 11 | // void unique(); // before C++20 |
| 12 | // size_type unique(); // C++20 and later |
| 13 | |
| 14 | #include <list> |
| 15 | #include <cassert> |
| 16 | |
| 17 | #include "test_macros.h" |
| 18 | #include "min_allocator.h" |
| 19 | |
| 20 | int main(int, char**) { |
| 21 | { |
| 22 | int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; |
| 23 | int a2[] = {2, 1, 4, 3}; |
| 24 | typedef std::list<int> L; |
| 25 | L c(a1, a1 + sizeof(a1) / sizeof(a1[0])); |
| 26 | #if TEST_STD_VER > 17 |
| 27 | ASSERT_SAME_TYPE(L::size_type, decltype(c.unique())); |
| 28 | assert(c.unique() == 5); |
| 29 | #else |
| 30 | ASSERT_SAME_TYPE(void, decltype(c.unique())); |
| 31 | c.unique(); |
| 32 | #endif |
| 33 | assert(c == std::list<int>(a2, a2 + 4)); |
| 34 | } |
| 35 | #if TEST_STD_VER >= 11 |
| 36 | { |
| 37 | int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; |
| 38 | int a2[] = {2, 1, 4, 3}; |
| 39 | std::list<int, min_allocator<int>> c(a1, a1 + sizeof(a1) / sizeof(a1[0])); |
| 40 | # if TEST_STD_VER > 17 |
| 41 | assert(c.unique() == 5); |
| 42 | # else |
| 43 | c.unique(); |
| 44 | # endif |
| 45 | assert((c == std::list<int, min_allocator<int>>(a2, a2 + 4))); |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |