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