Skip to content

Commit 731a987

Browse files
merge.pass.cpp
1 parent fd62583 commit 731a987

File tree

1 file changed

+19
-7
lines changed
  • libcxx/test/std/containers/associative/map/map.modifiers

1 file changed

+19
-7
lines changed

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "Counter.h"
2828

2929
template <class Map>
30-
bool map_equal(const Map& map, Map other) {
30+
TEST_CONSTEXPR_CXX26 bool map_equal(const Map& map, Map other) {
3131
return map == other;
3232
}
3333

@@ -46,7 +46,8 @@ struct throw_comparator {
4646
};
4747
#endif
4848

49-
int main(int, char**) {
49+
TEST_CONSTEXPR_CXX26
50+
bool test() {
5051
{
5152
std::map<int, int> src{{1, 0}, {3, 0}, {5, 0}};
5253
std::map<int, int> dst{{2, 0}, {4, 0}, {5, 0}};
@@ -56,7 +57,7 @@ int main(int, char**) {
5657
}
5758

5859
#ifndef TEST_HAS_NO_EXCEPTIONS
59-
{
60+
if (!TEST_IS_CONSTANT_EVALUATED) {
6061
bool do_throw = false;
6162
typedef std::map<Counter<int>, int, throw_comparator> map_type;
6263
map_type src({{1, 0}, {3, 0}, {5, 0}}, throw_comparator(do_throw));
@@ -75,13 +76,14 @@ int main(int, char**) {
7576
assert(map_equal(dst, map_type({{2, 0}, {4, 0}, {5, 0}}, throw_comparator(do_throw))));
7677
}
7778
#endif
78-
assert(Counter_base::gConstructed == 0);
79+
if (!TEST_IS_CONSTANT_EVALUATED)
80+
assert(Counter_base::gConstructed == 0);
7981
struct comparator {
8082
comparator() = default;
8183

8284
bool operator()(const Counter<int>& lhs, const Counter<int>& rhs) const { return lhs < rhs; }
8385
};
84-
{
86+
if (!TEST_IS_CONSTANT_EVALUATED) {
8587
typedef std::map<Counter<int>, int, std::less<Counter<int>>> first_map_type;
8688
typedef std::map<Counter<int>, int, comparator> second_map_type;
8789
typedef std::multimap<Counter<int>, int, comparator> third_map_type;
@@ -121,19 +123,29 @@ int main(int, char**) {
121123
}
122124
assert(Counter_base::gConstructed == 0);
123125
}
124-
assert(Counter_base::gConstructed == 0);
126+
if (!TEST_IS_CONSTANT_EVALUATED)
127+
assert(Counter_base::gConstructed == 0);
125128
{
126129
std::map<int, int> first;
127130
{
128131
std::map<int, int> second;
129132
first.merge(second);
130133
first.merge(std::move(second));
131134
}
132-
{
135+
if (!TEST_IS_CONSTANT_EVALUATED) {
133136
std::multimap<int, int> second;
134137
first.merge(second);
135138
first.merge(std::move(second));
136139
}
137140
}
141+
return true;
142+
}
143+
144+
int main(int, char**) {
145+
test();
146+
#if TEST_STD_VER >= 26
147+
static_assert(test());
148+
#endif
149+
138150
return 0;
139151
}

0 commit comments

Comments
 (0)