• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, const value_type& v);
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "min_allocator.h"
20 
main()21 int main()
22 {
23     {
24         typedef std::set<int> M;
25         typedef M::iterator R;
26         M m;
27         R r = m.insert(m.cend(), M::value_type(2));
28         assert(r == m.begin());
29         assert(m.size() == 1);
30         assert(*r == 2);
31 
32         r = m.insert(m.cend(), M::value_type(1));
33         assert(r == m.begin());
34         assert(m.size() == 2);
35         assert(*r == 1);
36 
37         r = m.insert(m.cend(), M::value_type(3));
38         assert(r == prev(m.end()));
39         assert(m.size() == 3);
40         assert(*r == 3);
41 
42         r = m.insert(m.cend(), M::value_type(3));
43         assert(r == prev(m.end()));
44         assert(m.size() == 3);
45         assert(*r == 3);
46     }
47 #if __cplusplus >= 201103L
48     {
49         typedef std::set<int, std::less<int>, min_allocator<int>> M;
50         typedef M::iterator R;
51         M m;
52         R r = m.insert(m.cend(), M::value_type(2));
53         assert(r == m.begin());
54         assert(m.size() == 1);
55         assert(*r == 2);
56 
57         r = m.insert(m.cend(), M::value_type(1));
58         assert(r == m.begin());
59         assert(m.size() == 2);
60         assert(*r == 1);
61 
62         r = m.insert(m.cend(), M::value_type(3));
63         assert(r == prev(m.end()));
64         assert(m.size() == 3);
65         assert(*r == 3);
66 
67         r = m.insert(m.cend(), M::value_type(3));
68         assert(r == prev(m.end()));
69         assert(m.size() == 3);
70         assert(*r == 3);
71     }
72 #endif
73 }
74