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