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 multiset
14
15// multiset& operator=(multiset&& s);
16
17#include <set>
18#include <cassert>
19
20#include "test_macros.h"
21#include "MoveOnly.h"
22#include "../../../test_compare.h"
23#include "test_allocator.h"
24#include "min_allocator.h"
25
26int main(int, char**) {
27 {
28 typedef MoveOnly V;
29 typedef test_less<MoveOnly> C;
30 typedef test_allocator<V> A;
31 typedef std::multiset<MoveOnly, C, A> M;
32 typedef std::move_iterator<V*> I;
33 V a1[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
34 M m1(I(a1), I(a1 + sizeof(a1) / sizeof(a1[0])), C(5), A(7));
35 V a2[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
36 M m2(I(a2), I(a2 + sizeof(a2) / sizeof(a2[0])), C(5), A(7));
37 M m3(C(3), A(7));
38 m3 = std::move(m1);
39 assert(m3 == m2);
40 assert(m3.get_allocator() == A(7));
41 assert(m3.key_comp() == C(5));
42 assert(m1.empty());
43 }
44 {
45 typedef MoveOnly V;
46 typedef test_less<MoveOnly> C;
47 typedef test_allocator<V> A;
48 typedef std::multiset<MoveOnly, C, A> M;
49 typedef std::move_iterator<V*> I;
50 V a1[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
51 M m1(I(a1), I(a1 + sizeof(a1) / sizeof(a1[0])), C(5), A(7));
52 V a2[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
53 M m2(I(a2), I(a2 + sizeof(a2) / sizeof(a2[0])), C(5), A(7));
54 M m3(C(3), A(5));
55 m3 = std::move(m1);
56 assert(m3 == m2);
57 assert(m3.get_allocator() == A(5));
58 assert(m3.key_comp() == C(5));
59 LIBCPP_ASSERT(m1.empty());
60 }
61 {
62 typedef MoveOnly V;
63 typedef test_less<MoveOnly> C;
64 typedef other_allocator<V> A;
65 typedef std::multiset<MoveOnly, C, A> M;
66 typedef std::move_iterator<V*> I;
67 V a1[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
68 M m1(I(a1), I(a1 + sizeof(a1) / sizeof(a1[0])), C(5), A(7));
69 V a2[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
70 M m2(I(a2), I(a2 + sizeof(a2) / sizeof(a2[0])), C(5), A(7));
71 M m3(C(3), A(5));
72 m3 = std::move(m1);
73 assert(m3 == m2);
74 assert(m3.get_allocator() == A(7));
75 assert(m3.key_comp() == C(5));
76 assert(m1.empty());
77 }
78 {
79 typedef MoveOnly V;
80 typedef test_less<MoveOnly> C;
81 typedef min_allocator<V> A;
82 typedef std::multiset<MoveOnly, C, A> M;
83 typedef std::move_iterator<V*> I;
84 V a1[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
85 M m1(I(a1), I(a1 + sizeof(a1) / sizeof(a1[0])), C(5), A());
86 V a2[] = {V(1), V(1), V(1), V(2), V(2), V(2), V(3), V(3), V(3)};
87 M m2(I(a2), I(a2 + sizeof(a2) / sizeof(a2[0])), C(5), A());
88 M m3(C(3), A());
89 m3 = std::move(m1);
90 assert(m3 == m2);
91 assert(m3.get_allocator() == A());
92 assert(m3.key_comp() == C(5));
93 assert(m1.empty());
94 }
95
96 return 0;
97}
98

source code of libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp