1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // void unique(); // before C++20
12 // size_type unique(); // C++20 and later
17 #include "test_macros.h"
18 #include "min_allocator.h"
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]));
28 ASSERT_SAME_TYPE(L::size_type
, decltype(c
.unique()));
29 assert(c
.unique() == 5);
31 ASSERT_SAME_TYPE(void, decltype(c
.unique()));
34 assert(c
== std::list
<int>(a2
, a2
+4));
36 #if TEST_STD_VER >= 11
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]));
42 assert(c
.unique() == 5);
46 assert((c
== std::list
<int, min_allocator
<int>>(a2
, a2
+4)));