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// UNSUPPORTED: c++03
10
11// <set>
12
13// class set
14
15// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
16// set(initializer_list<value_type> il, const allocator_type& a);
17
18#include <set>
19#include <cassert>
20#include <iterator>
21
22#include "test_macros.h"
23#include "../../../test_compare.h"
24#include "test_allocator.h"
25
26int main(int, char**) {
27 {
28 typedef test_less<int> Cmp;
29 typedef test_allocator<int> A;
30 typedef std::set<int, Cmp, A> C;
31 typedef C::value_type V;
32 C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
33 assert(m.size() == 6);
34 assert(std::distance(m.begin(), m.end()) == 6);
35 C::const_iterator i = m.cbegin();
36 assert(*i == V(1));
37 assert(*++i == V(2));
38 assert(*++i == V(3));
39 assert(*++i == V(4));
40 assert(*++i == V(5));
41 assert(*++i == V(6));
42 assert(m.key_comp() == Cmp(10));
43 assert(m.get_allocator() == A(4));
44 }
45 {
46 typedef test_less<int> Cmp;
47 typedef test_allocator<int> A;
48 typedef std::set<int, Cmp, A> C;
49 typedef C::value_type V;
50 C m({1, 2, 3, 4, 5, 6}, A(4));
51 assert(m.size() == 6);
52 assert(std::distance(m.begin(), m.end()) == 6);
53 C::const_iterator i = m.cbegin();
54 assert(*i == V(1));
55 assert(*++i == V(2));
56 assert(*++i == V(3));
57 assert(*++i == V(4));
58 assert(*++i == V(5));
59 assert(*++i == V(6));
60 assert(m.get_allocator() == A(4));
61 }
62
63 return 0;
64}
65

source code of libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp