15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
95a83710eSEric Fiselier // <list>
105a83710eSEric Fiselier
11*1ab3fe8aSMarshall Clow // void unique(); // before C++20
12*1ab3fe8aSMarshall Clow // size_type unique(); // C++20 and later
135a83710eSEric Fiselier
145a83710eSEric Fiselier #include <list>
155a83710eSEric Fiselier #include <cassert>
165a83710eSEric Fiselier
177fc6a556SMarshall Clow #include "test_macros.h"
185a83710eSEric Fiselier #include "min_allocator.h"
195a83710eSEric Fiselier
main(int,char **)202df59c50SJF Bastien int main(int, char**)
215a83710eSEric Fiselier {
225a83710eSEric Fiselier {
235a83710eSEric Fiselier int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
245a83710eSEric Fiselier int a2[] = {2, 1, 4, 3};
25*1ab3fe8aSMarshall Clow typedef std::list<int> L;
26*1ab3fe8aSMarshall Clow L c(a1, a1+sizeof(a1)/sizeof(a1[0]));
27*1ab3fe8aSMarshall Clow #if TEST_STD_VER > 17
28*1ab3fe8aSMarshall Clow ASSERT_SAME_TYPE(L::size_type, decltype(c.unique()));
2924edf8efSMarshall Clow assert(c.unique() == 5);
30*1ab3fe8aSMarshall Clow #else
31*1ab3fe8aSMarshall Clow ASSERT_SAME_TYPE(void, decltype(c.unique()));
32*1ab3fe8aSMarshall Clow c.unique();
33*1ab3fe8aSMarshall Clow #endif
345a83710eSEric Fiselier assert(c == std::list<int>(a2, a2+4));
355a83710eSEric Fiselier }
36f2f2a639SEric Fiselier #if TEST_STD_VER >= 11
375a83710eSEric Fiselier {
385a83710eSEric Fiselier int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
395a83710eSEric Fiselier int a2[] = {2, 1, 4, 3};
405a83710eSEric Fiselier std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
41*1ab3fe8aSMarshall Clow #if TEST_STD_VER > 17
4224edf8efSMarshall Clow assert(c.unique() == 5);
43*1ab3fe8aSMarshall Clow #else
44*1ab3fe8aSMarshall Clow c.unique();
45*1ab3fe8aSMarshall Clow #endif
465a83710eSEric Fiselier assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
475a83710eSEric Fiselier }
485a83710eSEric Fiselier #endif
492df59c50SJF Bastien
502df59c50SJF Bastien return 0;
515a83710eSEric Fiselier }
52