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// <set>
10
11// class set
12
13// set(const set& m, const allocator_type& a);
14
15#include <set>
16#include <cassert>
17#include <iterator>
18
19#include "test_macros.h"
20#include "../../../test_compare.h"
21#include "test_allocator.h"
22
23int main(int, char**) {
24 typedef int V;
25 V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
26 typedef test_less<int> C;
27 typedef test_allocator<V> A;
28 std::set<int, C, A> mo(ar, ar + sizeof(ar) / sizeof(ar[0]), C(5), A(7));
29 std::set<int, C, A> m(mo, A(3));
30 assert(m.get_allocator() == A(3));
31 assert(m.key_comp() == C(5));
32 assert(m.size() == 3);
33 assert(std::distance(m.begin(), m.end()) == 3);
34 assert(*m.begin() == 1);
35 assert(*std::next(m.begin()) == 2);
36 assert(*std::next(m.begin(), 2) == 3);
37
38 assert(mo.get_allocator() == A(7));
39 assert(mo.key_comp() == C(5));
40 assert(mo.size() == 3);
41 assert(std::distance(mo.begin(), mo.end()) == 3);
42 assert(*mo.begin() == 1);
43 assert(*std::next(mo.begin()) == 2);
44 assert(*std::next(mo.begin(), 2) == 3);
45
46 return 0;
47}
48

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