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 // <set>
11 
12 // class set
13 
14 // iterator insert(const_iterator position, value_type&& v);
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "MoveOnly.h"
20 #include "min_allocator.h"
21 
main()22 int main()
23 {
24 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
25     {
26         typedef std::set<MoveOnly> M;
27         typedef M::iterator R;
28         M m;
29         R r = m.insert(m.cend(), M::value_type(2));
30         assert(r == m.begin());
31         assert(m.size() == 1);
32         assert(*r == 2);
33 
34         r = m.insert(m.cend(), M::value_type(1));
35         assert(r == m.begin());
36         assert(m.size() == 2);
37         assert(*r == 1);
38 
39         r = m.insert(m.cend(), 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.cend(), M::value_type(3));
45         assert(r == prev(m.end()));
46         assert(m.size() == 3);
47         assert(*r == 3);
48     }
49 #if __cplusplus >= 201103L
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 #endif
75 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
76 }
77