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 | // void insert(initializer_list<value_type> il); |
16 | |
17 | #include <set> |
18 | #include <cassert> |
19 | #include <cstddef> |
20 | |
21 | #include "test_macros.h" |
22 | #include "min_allocator.h" |
23 | |
24 | int main(int, char**) |
25 | { |
26 | { |
27 | typedef std::set<int> C; |
28 | typedef C::value_type V; |
29 | C m = {10, 8}; |
30 | m.insert(l: {1, 2, 3, 4, 5, 6}); |
31 | assert(m.size() == 8); |
32 | assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size()); |
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(*++i == V(8)); |
41 | assert(*++i == V(10)); |
42 | } |
43 | { |
44 | typedef std::set<int, std::less<int>, min_allocator<int>> C; |
45 | typedef C::value_type V; |
46 | C m = {10, 8}; |
47 | m.insert({1, 2, 3, 4, 5, 6}); |
48 | assert(m.size() == 8); |
49 | assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size()); |
50 | C::const_iterator i = m.cbegin(); |
51 | assert(*i == V(1)); |
52 | assert(*++i == V(2)); |
53 | assert(*++i == V(3)); |
54 | assert(*++i == V(4)); |
55 | assert(*++i == V(5)); |
56 | assert(*++i == V(6)); |
57 | assert(*++i == V(8)); |
58 | assert(*++i == V(10)); |
59 | } |
60 | |
61 | return 0; |
62 | } |
63 | |