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++98, c++03
10 
11 // <set>
12 
13 // class multiset
14 
15 // iterator insert(value_type&& v);
16 
17 #include <set>
18 #include <cassert>
19 
20 #include "MoveOnly.h"
21 #include "min_allocator.h"
22 
23 int main(int, char**)
24 {
25     {
26         typedef std::multiset<MoveOnly> M;
27         typedef M::iterator R;
28         M m;
29         R r = m.insert(M::value_type(2));
30         assert(r == m.begin());
31         assert(m.size() == 1);
32         assert(*r == 2);
33 
34         r = m.insert(M::value_type(1));
35         assert(r == m.begin());
36         assert(m.size() == 2);
37         assert(*r == 1);
38 
39         r = m.insert(M::value_type(3));
40         assert(r == prev(m.end()));
41         assert(m.size() == 3);
42         assert(*r == 3);
43 
44         r = m.insert(M::value_type(3));
45         assert(r == prev(m.end()));
46         assert(m.size() == 4);
47         assert(*r == 3);
48     }
49     {
50         typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
51         typedef M::iterator R;
52         M m;
53         R r = m.insert(M::value_type(2));
54         assert(r == m.begin());
55         assert(m.size() == 1);
56         assert(*r == 2);
57 
58         r = m.insert(M::value_type(1));
59         assert(r == m.begin());
60         assert(m.size() == 2);
61         assert(*r == 1);
62 
63         r = m.insert(M::value_type(3));
64         assert(r == prev(m.end()));
65         assert(m.size() == 3);
66         assert(*r == 3);
67 
68         r = m.insert(M::value_type(3));
69         assert(r == prev(m.end()));
70         assert(m.size() == 4);
71         assert(*r == 3);
72     }
73 
74   return 0;
75 }
76