llvm-project
77 строк · 2.0 Кб
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{
28typedef std::set<MoveOnly> M;
29typedef M::iterator R;
30M m;
31R r = m.insert(m.cend(), M::value_type(2));
32assert(r == m.begin());
33assert(m.size() == 1);
34assert(*r == 2);
35
36r = m.insert(m.cend(), M::value_type(1));
37assert(r == m.begin());
38assert(m.size() == 2);
39assert(*r == 1);
40
41r = m.insert(m.cend(), M::value_type(3));
42assert(r == std::prev(m.end()));
43assert(m.size() == 3);
44assert(*r == 3);
45
46r = m.insert(m.cend(), M::value_type(3));
47assert(r == std::prev(m.end()));
48assert(m.size() == 3);
49assert(*r == 3);
50}
51{
52typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
53typedef M::iterator R;
54M m;
55R r = m.insert(m.cend(), M::value_type(2));
56assert(r == m.begin());
57assert(m.size() == 1);
58assert(*r == 2);
59
60r = m.insert(m.cend(), M::value_type(1));
61assert(r == m.begin());
62assert(m.size() == 2);
63assert(*r == 1);
64
65r = m.insert(m.cend(), M::value_type(3));
66assert(r == std::prev(m.end()));
67assert(m.size() == 3);
68assert(*r == 3);
69
70r = m.insert(m.cend(), M::value_type(3));
71assert(r == std::prev(m.end()));
72assert(m.size() == 3);
73assert(*r == 3);
74}
75
76return 0;
77}
78