1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03
11
12 // <set>
13
14 // class set
15
16 // iterator insert(const_iterator position, value_type&& v);
17
18 #include <set>
19 #include <cassert>
20
21 #include "MoveOnly.h"
22 #include "min_allocator.h"
23
main()24 int main()
25 {
26 {
27 typedef std::set<MoveOnly> M;
28 typedef M::iterator R;
29 M m;
30 R r = m.insert(m.cend(), M::value_type(2));
31 assert(r == m.begin());
32 assert(m.size() == 1);
33 assert(*r == 2);
34
35 r = m.insert(m.cend(), M::value_type(1));
36 assert(r == m.begin());
37 assert(m.size() == 2);
38 assert(*r == 1);
39
40 r = m.insert(m.cend(), M::value_type(3));
41 assert(r == prev(m.end()));
42 assert(m.size() == 3);
43 assert(*r == 3);
44
45 r = m.insert(m.cend(), M::value_type(3));
46 assert(r == prev(m.end()));
47 assert(m.size() == 3);
48 assert(*r == 3);
49 }
50 {
51 typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
52 typedef M::iterator R;
53 M m;
54 R r = m.insert(m.cend(), M::value_type(2));
55 assert(r == m.begin());
56 assert(m.size() == 1);
57 assert(*r == 2);
58
59 r = m.insert(m.cend(), M::value_type(1));
60 assert(r == m.begin());
61 assert(m.size() == 2);
62 assert(*r == 1);
63
64 r = m.insert(m.cend(), M::value_type(3));
65 assert(r == prev(m.end()));
66 assert(m.size() == 3);
67 assert(*r == 3);
68
69 r = m.insert(m.cend(), M::value_type(3));
70 assert(r == prev(m.end()));
71 assert(m.size() == 3);
72 assert(*r == 3);
73 }
74 }
75