| 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 = key_compare()); |
| 16 | |
| 17 | #include <set> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | #include "min_allocator.h" |
| 22 | |
| 23 | int main(int, char**) { |
| 24 | { |
| 25 | typedef std::set<int> C; |
| 26 | typedef C::value_type V; |
| 27 | C m = {1, 2, 3, 4, 5, 6}; |
| 28 | assert(m.size() == 6); |
| 29 | assert(std::distance(m.begin(), m.end()) == 6); |
| 30 | C::const_iterator i = m.cbegin(); |
| 31 | assert(*i == V(1)); |
| 32 | assert(*++i == V(2)); |
| 33 | assert(*++i == V(3)); |
| 34 | assert(*++i == V(4)); |
| 35 | assert(*++i == V(5)); |
| 36 | assert(*++i == V(6)); |
| 37 | } |
| 38 | { |
| 39 | typedef std::set<int, std::less<int>, min_allocator<int>> C; |
| 40 | typedef C::value_type V; |
| 41 | C m = {1, 2, 3, 4, 5, 6}; |
| 42 | assert(m.size() == 6); |
| 43 | assert(std::distance(m.begin(), m.end()) == 6); |
| 44 | C::const_iterator i = m.cbegin(); |
| 45 | assert(*i == V(1)); |
| 46 | assert(*++i == V(2)); |
| 47 | assert(*++i == V(3)); |
| 48 | assert(*++i == V(4)); |
| 49 | assert(*++i == V(5)); |
| 50 | assert(*++i == V(6)); |
| 51 | } |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |