1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <set>
11
12 // class set
13
14 // set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
15 // set(initializer_list<value_type> il, const allocator_type& a);
16
17 #include <set>
18 #include <cassert>
19 #include "../../../test_compare.h"
20 #include "test_allocator.h"
21
main()22 int main()
23 {
24 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
25 {
26 typedef test_compare<std::less<int> > Cmp;
27 typedef test_allocator<int> A;
28 typedef std::set<int, Cmp, A> C;
29 typedef C::value_type V;
30 C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
31 assert(m.size() == 6);
32 assert(distance(m.begin(), m.end()) == 6);
33 C::const_iterator i = m.cbegin();
34 assert(*i == V(1));
35 assert(*++i == V(2));
36 assert(*++i == V(3));
37 assert(*++i == V(4));
38 assert(*++i == V(5));
39 assert(*++i == V(6));
40 assert(m.key_comp() == Cmp(10));
41 assert(m.get_allocator() == A(4));
42 }
43 #if _LIBCPP_STD_VER > 11
44 {
45 typedef test_compare<std::less<int> > Cmp;
46 typedef test_allocator<int> A;
47 typedef std::set<int, Cmp, A> C;
48 typedef C::value_type V;
49 C m({1, 2, 3, 4, 5, 6}, A(4));
50 assert(m.size() == 6);
51 assert(distance(m.begin(), m.end()) == 6);
52 C::const_iterator i = m.cbegin();
53 assert(*i == V(1));
54 assert(*++i == V(2));
55 assert(*++i == V(3));
56 assert(*++i == V(4));
57 assert(*++i == V(5));
58 assert(*++i == V(6));
59 assert(m.get_allocator() == A(4));
60 }
61 #endif
62 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
63 }
64