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 // pair<iterator, bool> emplace(Args&&... args);
21 #include "test_macros.h"
22 #include "../../Emplaceable.h"
23 #include "DefaultOnly.h"
24 #include "min_allocator.h"
29 typedef std::set
<DefaultOnly
> M
;
30 typedef std::pair
<M::iterator
, bool> R
;
32 assert(DefaultOnly::count
== 0);
35 assert(r
.first
== m
.begin());
36 assert(m
.size() == 1);
37 assert(*m
.begin() == DefaultOnly());
38 assert(DefaultOnly::count
== 1);
42 assert(r
.first
== m
.begin());
43 assert(m
.size() == 1);
44 assert(*m
.begin() == DefaultOnly());
45 assert(DefaultOnly::count
== 1);
47 assert(DefaultOnly::count
== 0);
49 typedef std::set
<Emplaceable
> M
;
50 typedef std::pair
<M::iterator
, bool> R
;
54 assert(r
.first
== m
.begin());
55 assert(m
.size() == 1);
56 assert(*m
.begin() == Emplaceable());
57 r
= m
.emplace(2, 3.5);
59 assert(r
.first
== std::next(m
.begin()));
60 assert(m
.size() == 2);
61 assert(*r
.first
== Emplaceable(2, 3.5));
62 r
= m
.emplace(2, 3.5);
64 assert(r
.first
== std::next(m
.begin()));
65 assert(m
.size() == 2);
66 assert(*r
.first
== Emplaceable(2, 3.5));
69 typedef std::set
<int> M
;
70 typedef std::pair
<M::iterator
, bool> R
;
72 R r
= m
.emplace(M::value_type(2));
74 assert(r
.first
== m
.begin());
75 assert(m
.size() == 1);
76 assert(*r
.first
== 2);
79 typedef std::set
<int, std::less
<int>, min_allocator
<int>> M
;
80 typedef std::pair
<M::iterator
, bool> R
;
82 R r
= m
.emplace(M::value_type(2));
84 assert(r
.first
== m
.begin());
85 assert(m
.size() == 1);
86 assert(*r
.first
== 2);