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 | { |
23 | int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; |
24 | int a2[] = {2, 1, 4, 3}; |
25 | typedef std::list<int> L; |
26 | L c(a1, a1+sizeof(a1)/sizeof(a1[0])); |
27 | #if TEST_STD_VER > 17 |
28 | ASSERT_SAME_TYPE(L::size_type, decltype(c.unique())); |
29 | assert(c.unique() == 5); |
30 | #else |
31 | ASSERT_SAME_TYPE(void, decltype(c.unique())); |
32 | c.unique(); |
33 | #endif |
34 | assert(c == std::list<int>(a2, a2+4)); |
35 | } |
36 | #if TEST_STD_VER >= 11 |
37 | { |
38 | int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; |
39 | int a2[] = {2, 1, 4, 3}; |
40 | std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0])); |
41 | #if TEST_STD_VER > 17 |
42 | assert(c.unique() == 5); |
43 | #else |
44 | c.unique(); |
45 | #endif |
46 | assert((c == std::list<int, min_allocator<int>>(a2, a2+4))); |
47 | } |
48 | #endif |
49 | |
50 | return 0; |
51 | } |
52 | |