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

source code of libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp