1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
15 // template <class... Args>
16 // iterator emplace_hint(const_iterator position, Args&&... args);
21 #include "test_macros.h"
22 #include "../../Emplaceable.h"
23 #include "DefaultOnly.h"
24 #include "min_allocator.h"
29 typedef std::multiset
<DefaultOnly
> M
;
30 typedef M::iterator R
;
32 assert(DefaultOnly::count
== 0);
33 R r
= m
.emplace_hint(m
.cend());
34 assert(r
== m
.begin());
35 assert(m
.size() == 1);
36 assert(*m
.begin() == DefaultOnly());
37 assert(DefaultOnly::count
== 1);
39 r
= m
.emplace_hint(m
.cbegin());
40 assert(r
== m
.begin());
41 assert(m
.size() == 2);
42 assert(*m
.begin() == DefaultOnly());
43 assert(DefaultOnly::count
== 2);
45 assert(DefaultOnly::count
== 0);
47 typedef std::multiset
<Emplaceable
> M
;
48 typedef M::iterator R
;
50 R r
= m
.emplace_hint(m
.cend());
51 assert(r
== m
.begin());
52 assert(m
.size() == 1);
53 assert(*m
.begin() == Emplaceable());
54 r
= m
.emplace_hint(m
.cend(), 2, 3.5);
55 assert(r
== std::next(m
.begin()));
56 assert(m
.size() == 2);
57 assert(*r
== Emplaceable(2, 3.5));
58 r
= m
.emplace_hint(m
.cbegin(), 2, 3.5);
59 assert(r
== std::next(m
.begin()));
60 assert(m
.size() == 3);
61 assert(*r
== Emplaceable(2, 3.5));
64 typedef std::multiset
<int> M
;
65 typedef M::iterator R
;
67 R r
= m
.emplace_hint(m
.cend(), M::value_type(2));
68 assert(r
== m
.begin());
69 assert(m
.size() == 1);
73 typedef std::multiset
<int, std::less
<int>, min_allocator
<int>> M
;
74 typedef M::iterator R
;
76 R r
= m
.emplace_hint(m
.cend(), M::value_type(2));
77 assert(r
== m
.begin());
78 assert(m
.size() == 1);