Skip to content

Commit 97b00cd

Browse files
pass map.modifiers/emplace.pass.cpp
1 parent 1270c3e commit 97b00cd

File tree

4 files changed

+67
-59
lines changed

4 files changed

+67
-59
lines changed

libcxx/include/__tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ public:
682682
_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
683683
// _LIBCPP_HIDE_FROM_ABI static _Tp& __get_value_static(__tree_node * foo) { return (foo->__value_); }
684684

685-
template <typename... Args>
685+
template <class... Args>
686686
constexpr __tree_node(Args&&... args) : __value_{std::forward<Args>(args)...} {}
687687
// TODO: libcxx26
688688
// _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node(__node_value_type && args): __value_{args} { }

libcxx/include/map

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ public:
857857
template <typename... Args>
858858
_LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type(Args&&... args) : __cc_{std::forward<Args>(args)...} {}
859859
// constexpr __value_type(value_type && args): __cc_{args} { }
860-
__value_type() = delete;
860+
__value_type() = default;
861861
~__value_type() = default;
862862
__value_type(const __value_type&) = delete;
863863
__value_type(__value_type&&) = delete;

libcxx/test/std/containers/Emplaceable.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ class Emplaceable {
2222
double double_;
2323

2424
public:
25-
Emplaceable() : int_(0), double_(0) {}
26-
Emplaceable(int i, double d) : int_(i), double_(d) {}
27-
Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
25+
TEST_CONSTEXPR_CXX26 Emplaceable() : int_(0), double_(0) {}
26+
TEST_CONSTEXPR_CXX26 Emplaceable(int i, double d) : int_(i), double_(d) {}
27+
TEST_CONSTEXPR_CXX26 Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
2828
x.int_ = 0;
2929
x.double_ = 0;
3030
}
31-
Emplaceable& operator=(Emplaceable&& x) {
31+
TEST_CONSTEXPR_CXX26 Emplaceable& operator=(Emplaceable&& x) {
3232
int_ = x.int_;
3333
x.int_ = 0;
3434
double_ = x.double_;
3535
x.double_ = 0;
3636
return *this;
3737
}
3838

39-
bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
40-
bool operator<(const Emplaceable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
39+
TEST_CONSTEXPR_CXX26 bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
40+
TEST_CONSTEXPR_CXX26 bool operator<(const Emplaceable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
4141

42-
int get() const { return int_; }
42+
TEST_CONSTEXPR_CXX26 int get() const { return int_; }
4343
};
4444

4545
template <>

libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,37 @@
2525
#include "min_allocator.h"
2626

2727
TEST_CONSTEXPR_CXX26 bool test() {
28+
if(!TEST_IS_CONSTANT_EVALUATED)
2829
{
29-
typedef std::map<int, DefaultOnly> M;
30-
typedef std::pair<M::iterator, bool> R;
31-
M m;
30+
{
31+
typedef std::map<int, DefaultOnly> M;
32+
typedef std::pair<M::iterator, bool> R;
33+
M m;
34+
assert(DefaultOnly::count == 0);
35+
R r = m.emplace();
36+
assert(r.second);
37+
assert(r.first == m.begin());
38+
assert(m.size() == 1);
39+
assert(m.begin()->first == 0);
40+
assert(m.begin()->second == DefaultOnly());
41+
assert(DefaultOnly::count == 1);
42+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
43+
assert(r.second);
44+
assert(r.first == std::next(m.begin()));
45+
assert(m.size() == 2);
46+
assert(std::next(m.begin())->first == 1);
47+
assert(std::next(m.begin())->second == DefaultOnly());
48+
assert(DefaultOnly::count == 2);
49+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
50+
assert(!r.second);
51+
assert(r.first == std::next(m.begin()));
52+
assert(m.size() == 2);
53+
assert(std::next(m.begin())->first == 1);
54+
assert(std::next(m.begin())->second == DefaultOnly());
55+
assert(DefaultOnly::count == 2);
56+
}
3257
assert(DefaultOnly::count == 0);
33-
R r = m.emplace();
34-
assert(r.second);
35-
assert(r.first == m.begin());
36-
assert(m.size() == 1);
37-
assert(m.begin()->first == 0);
38-
assert(m.begin()->second == DefaultOnly());
39-
assert(DefaultOnly::count == 1);
40-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
41-
assert(r.second);
42-
assert(r.first == std::next(m.begin()));
43-
assert(m.size() == 2);
44-
assert(std::next(m.begin())->first == 1);
45-
assert(std::next(m.begin())->second == DefaultOnly());
46-
assert(DefaultOnly::count == 2);
47-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
48-
assert(!r.second);
49-
assert(r.first == std::next(m.begin()));
50-
assert(m.size() == 2);
51-
assert(std::next(m.begin())->first == 1);
52-
assert(std::next(m.begin())->second == DefaultOnly());
53-
assert(DefaultOnly::count == 2);
5458
}
55-
assert(DefaultOnly::count == 0);
5659
{
5760
typedef std::map<int, Emplaceable> M;
5861
typedef std::pair<M::iterator, bool> R;
@@ -87,34 +90,39 @@ TEST_CONSTEXPR_CXX26 bool test() {
8790
assert(m.begin()->first == 2);
8891
assert(m.begin()->second == 3.5);
8992
}
93+
94+
if(!TEST_IS_CONSTANT_EVALUATED)
9095
{
91-
typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
92-
typedef std::pair<M::iterator, bool> R;
93-
M m;
96+
{
97+
typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
98+
typedef std::pair<M::iterator, bool> R;
99+
M m;
100+
assert(DefaultOnly::count == 0);
101+
R r = m.emplace();
102+
assert(r.second);
103+
assert(r.first == m.begin());
104+
assert(m.size() == 1);
105+
assert(m.begin()->first == 0);
106+
assert(m.begin()->second == DefaultOnly());
107+
assert(DefaultOnly::count == 1);
108+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
109+
assert(r.second);
110+
assert(r.first == std::next(m.begin()));
111+
assert(m.size() == 2);
112+
assert(std::next(m.begin())->first == 1);
113+
assert(std::next(m.begin())->second == DefaultOnly());
114+
assert(DefaultOnly::count == 2);
115+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
116+
assert(!r.second);
117+
assert(r.first == std::next(m.begin()));
118+
assert(m.size() == 2);
119+
assert(std::next(m.begin())->first == 1);
120+
assert(std::next(m.begin())->second == DefaultOnly());
121+
assert(DefaultOnly::count == 2);
122+
}
94123
assert(DefaultOnly::count == 0);
95-
R r = m.emplace();
96-
assert(r.second);
97-
assert(r.first == m.begin());
98-
assert(m.size() == 1);
99-
assert(m.begin()->first == 0);
100-
assert(m.begin()->second == DefaultOnly());
101-
assert(DefaultOnly::count == 1);
102-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
103-
assert(r.second);
104-
assert(r.first == std::next(m.begin()));
105-
assert(m.size() == 2);
106-
assert(std::next(m.begin())->first == 1);
107-
assert(std::next(m.begin())->second == DefaultOnly());
108-
assert(DefaultOnly::count == 2);
109-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
110-
assert(!r.second);
111-
assert(r.first == std::next(m.begin()));
112-
assert(m.size() == 2);
113-
assert(std::next(m.begin())->first == 1);
114-
assert(std::next(m.begin())->second == DefaultOnly());
115-
assert(DefaultOnly::count == 2);
116124
}
117-
assert(DefaultOnly::count == 0);
125+
118126
{
119127
typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
120128
typedef std::pair<M::iterator, bool> R;

0 commit comments

Comments
 (0)