Skip to content

Commit 417ed1a

Browse files
committed
modifiers
1 parent 241ea9e commit 417ed1a

21 files changed

+243
-74
lines changed

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/clear.pass.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static_assert(NoExceptClear<std::flat_multiset<int, std::less<int>, ThrowOnMoveC
3838
#endif
3939

4040
template <class KeyContainer>
41-
void test_one() {
41+
constexpr void test_one() {
4242
using Key = typename KeyContainer::value_type;
4343
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
4444
{
@@ -58,17 +58,25 @@ void test_one() {
5858
}
5959
}
6060

61-
void test() {
61+
constexpr bool test() {
6262
test_one<std::vector<int>>();
6363
test_one<std::vector<int>>();
64-
test_one<std::deque<int>>();
64+
#ifndef __cpp_lib_constexpr_deque
65+
if (!TEST_IS_CONSTANT_EVALUATED)
66+
#endif
67+
test_one<std::deque<int>>();
6568
test_one<MinSequenceContainer<int>>();
6669
test_one<std::vector<int, min_allocator<int>>>();
6770
test_one<std::vector<int, min_allocator<int>>>();
71+
72+
return true;
6873
}
6974

7075
int main(int, char**) {
7176
test();
77+
#if TEST_STD_VER >= 26
78+
static_assert(test());
79+
#endif
7280

7381
return 0;
7482
}

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace.pass.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "min_allocator.h"
2929

3030
template <class KeyContainer>
31-
void test_one() {
31+
constexpr void test_one() {
3232
using Key = typename KeyContainer::value_type;
3333
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
3434
using R = typename M::iterator;
@@ -91,7 +91,7 @@ void test_one() {
9191
}
9292

9393
template <class KeyContainer>
94-
void test_emplaceable() {
94+
constexpr void test_emplaceable() {
9595
using M = std::flat_multiset<Emplaceable, std::less<Emplaceable>, KeyContainer>;
9696
using R = typename M::iterator;
9797

@@ -111,16 +111,24 @@ void test_emplaceable() {
111111
assert(*r == Emplaceable(1, 3.5));
112112
}
113113

114-
void test() {
114+
constexpr bool test() {
115115
test_one<std::vector<int>>();
116-
test_one<std::deque<int>>();
116+
#ifndef __cpp_lib_constexpr_deque
117+
if (!TEST_IS_CONSTANT_EVALUATED)
118+
#endif
119+
test_one<std::deque<int>>();
117120
test_one<MinSequenceContainer<int>>();
118121
test_one<std::vector<int, min_allocator<int>>>();
119122

120123
test_emplaceable<std::vector<Emplaceable>>();
121-
test_emplaceable<std::deque<Emplaceable>>();
124+
#ifndef __cpp_lib_constexpr_deque
125+
if (!TEST_IS_CONSTANT_EVALUATED)
126+
#endif
127+
test_emplaceable<std::deque<Emplaceable>>();
122128
test_emplaceable<MinSequenceContainer<Emplaceable>>();
123129
test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
130+
131+
return true;
124132
}
125133

126134
void test_exception() {
@@ -130,6 +138,9 @@ void test_exception() {
130138

131139
int main(int, char**) {
132140
test();
141+
#if TEST_STD_VER >= 26
142+
static_assert(test());
143+
#endif
133144
test_exception();
134145

135146
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace_hint.pass.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
#include "../helpers.h"
2828

2929
struct CompareTensDigit {
30-
bool operator()(auto lhs, auto rhs) const { return (lhs / 10) < (rhs / 10); }
30+
constexpr bool operator()(auto lhs, auto rhs) const { return (lhs / 10) < (rhs / 10); }
3131
};
3232

3333
template <class KeyContainer>
34-
void test_one() {
34+
constexpr void test_one() {
3535
using Key = typename KeyContainer::value_type;
3636
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
3737
using R = M::iterator;
@@ -179,7 +179,6 @@ void test_one() {
179179
assert(r == m.begin() + 2);
180180
assert(m.size() == 7);
181181
assert(*r == 23);
182-
assert(*std::next(r) == 20);
183182
}
184183
{
185184
// hint incorrect and after the last duplicate
@@ -196,7 +195,7 @@ void test_one() {
196195
}
197196

198197
template <class KeyContainer>
199-
void test_emplaceable() {
198+
constexpr void test_emplaceable() {
200199
using M = std::flat_multiset<Emplaceable, std::less<Emplaceable>, KeyContainer>;
201200
using R = M::iterator;
202201

@@ -216,16 +215,21 @@ void test_emplaceable() {
216215
assert(*r == Emplaceable(1, 3.5));
217216
}
218217

219-
void test() {
218+
constexpr bool test() {
220219
test_one<std::vector<int>>();
221-
test_one<std::deque<int>>();
220+
#ifndef __cpp_lib_constexpr_deque
221+
if (!TEST_IS_CONSTANT_EVALUATED)
222+
#endif
223+
test_one<std::deque<int>>();
222224
test_one<MinSequenceContainer<int>>();
223225
test_one<std::vector<int, min_allocator<int>>>();
224226

225227
test_emplaceable<std::vector<Emplaceable>>();
226228
test_emplaceable<std::vector<Emplaceable>>();
227229
test_emplaceable<MinSequenceContainer<Emplaceable>>();
228230
test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
231+
232+
return true;
229233
}
230234

231235
void test_exception() {
@@ -235,6 +239,9 @@ void test_exception() {
235239

236240
int main(int, char**) {
237241
test();
242+
#if TEST_STD_VER >= 26
243+
static_assert(test());
244+
#endif
238245
test_exception();
239246

240247
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter.pass.cpp

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

2929
template <class KeyContainer>
30-
void test_one() {
30+
constexpr void test_one() {
3131
using Key = typename KeyContainer::value_type;
3232
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
3333
using I = M::iterator;
@@ -94,11 +94,16 @@ void test_one() {
9494
assert(i8 == m.end());
9595
}
9696

97-
void test() {
97+
constexpr bool test() {
9898
test_one<std::vector<int>>();
99-
test_one<std::deque<int>>();
99+
#ifndef __cpp_lib_constexpr_deque
100+
if (!TEST_IS_CONSTANT_EVALUATED)
101+
#endif
102+
test_one<std::deque<int>>();
100103
test_one<MinSequenceContainer<int>>();
101104
test_one<std::vector<int, min_allocator<int>>>();
105+
106+
return true;
102107
}
103108

104109
void test_exception() {
@@ -108,6 +113,9 @@ void test_exception() {
108113

109114
int main(int, char**) {
110115
test();
116+
#if TEST_STD_VER >= 26
117+
static_assert(test());
118+
#endif
111119
test_exception();
112120

113121
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter_iter.pass.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "min_allocator.h"
2727

2828
template <class KeyContainer>
29-
void test_one() {
29+
constexpr void test_one() {
3030
using Key = typename KeyContainer::value_type;
3131
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
3232
using I = M::iterator;
@@ -78,11 +78,16 @@ void test_one() {
7878
assert(i5 == m.end());
7979
}
8080

81-
void test() {
81+
constexpr bool test() {
8282
test_one<std::vector<int>>();
83-
test_one<std::deque<int>>();
83+
#ifndef __cpp_lib_constexpr_deque
84+
if (!TEST_IS_CONSTANT_EVALUATED)
85+
#endif
86+
test_one<std::deque<int>>();
8487
test_one<MinSequenceContainer<int>>();
8588
test_one<std::vector<int, min_allocator<int>>>();
89+
90+
return true;
8691
}
8792

8893
void test_exception() {
@@ -92,6 +97,9 @@ void test_exception() {
9297

9398
int main(int, char**) {
9499
test();
100+
#if TEST_STD_VER >= 26
101+
static_assert(test());
102+
#endif
95103
test_exception();
96104

97105
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key.pass.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "min_allocator.h"
2727

2828
template <class KeyContainer, class Compare = std::less<>>
29-
void test_one() {
29+
constexpr void test_one() {
3030
using M = std::flat_multiset<int, Compare, KeyContainer>;
3131

3232
auto make = [](std::initializer_list<int> il) {
@@ -74,12 +74,17 @@ void test_one() {
7474
assert(m.empty());
7575
}
7676

77-
void test() {
77+
constexpr bool test() {
7878
test_one<std::vector<int>>();
7979
test_one<std::vector<int>, std::greater<>>();
80-
test_one<std::deque<int>>();
80+
#ifndef __cpp_lib_constexpr_deque
81+
if (!TEST_IS_CONSTANT_EVALUATED)
82+
#endif
83+
test_one<std::deque<int>>();
8184
test_one<MinSequenceContainer<int>>();
8285
test_one<std::vector<int, min_allocator<int>>>();
86+
87+
return true;
8388
}
8489

8590
void test_exception() {
@@ -94,6 +99,9 @@ void test_exception() {
9499

95100
int main(int, char**) {
96101
test();
102+
#if TEST_STD_VER >= 26
103+
static_assert(test());
104+
#endif
97105
test_exception();
98106

99107
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key_transparent.pass.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ static_assert(!CanErase<const NonTransparentSet>);
3838

3939
template <class Key, class It>
4040
struct HeterogeneousKey {
41-
explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
42-
operator It() && { return it_; }
43-
auto operator<=>(Key key) const { return key_ <=> key; }
44-
friend bool operator<(const HeterogeneousKey&, const HeterogeneousKey&) {
41+
constexpr explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
42+
constexpr operator It() && { return it_; }
43+
constexpr auto operator<=>(Key key) const { return key_ <=> key; }
44+
constexpr friend bool operator<(const HeterogeneousKey&, const HeterogeneousKey&) {
4545
assert(false);
4646
return false;
4747
}
@@ -50,7 +50,7 @@ struct HeterogeneousKey {
5050
};
5151

5252
template <class KeyContainer>
53-
void test_one() {
53+
constexpr void test_one() {
5454
using Key = typename KeyContainer::value_type;
5555
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
5656

@@ -70,7 +70,7 @@ void test_one() {
7070
}
7171

7272
template <class KeyContainer>
73-
void test_transparent_comparator() {
73+
constexpr void test_transparent_comparator() {
7474
using M = std::flat_multiset<std::string, TransparentComparator, KeyContainer>;
7575
{
7676
M m = {"alpha", "beta", "beta", "epsilon", "epsilon", "epsilon", "eta", "eta", "gamma"};
@@ -95,14 +95,20 @@ void test_transparent_comparator() {
9595
}
9696
}
9797

98-
void test() {
98+
constexpr bool test() {
9999
test_one<std::vector<int>>();
100-
test_one<std::deque<int>>();
100+
#ifndef __cpp_lib_constexpr_deque
101+
if (!TEST_IS_CONSTANT_EVALUATED)
102+
#endif
103+
test_one<std::deque<int>>();
101104
test_one<MinSequenceContainer<int>>();
102105
test_one<std::vector<int, min_allocator<int>>>();
103106

104107
test_transparent_comparator<std::vector<std::string>>();
105-
test_transparent_comparator<std::deque<std::string>>();
108+
#ifndef __cpp_lib_constexpr_deque
109+
if (!TEST_IS_CONSTANT_EVALUATED)
110+
#endif
111+
test_transparent_comparator<std::deque<std::string>>();
106112
test_transparent_comparator<MinSequenceContainer<std::string>>();
107113
test_transparent_comparator<std::vector<std::string, min_allocator<std::string>>>();
108114

@@ -146,6 +152,8 @@ void test() {
146152
assert(n == 2);
147153
assert((m == M{"alpha", "epsilon", "eta", "gamma"}));
148154
}
155+
156+
return true;
149157
}
150158

151159
void test_exception() {
@@ -159,6 +167,9 @@ void test_exception() {
159167

160168
int main(int, char**) {
161169
test();
170+
#if TEST_STD_VER >= 26
171+
static_assert(test());
172+
#endif
162173
test_exception();
163174

164175
return 0;

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/extract.pass.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static_assert(!CanExtract<std::flat_multiset<int> const&>);
3333
static_assert(!CanExtract<std::flat_multiset<int> const&&>);
3434

3535
template <class KeyContainer>
36-
void test_one() {
36+
constexpr void test_one() {
3737
using M = std::flat_multiset<int, std::less<int>, KeyContainer>;
3838
{
3939
M m = M({1, 1, 3});
@@ -55,9 +55,12 @@ void test_one() {
5555
}
5656
}
5757

58-
void test() {
58+
constexpr bool test() {
5959
test_one<std::vector<int>>();
60-
test_one<std::deque<int>>();
60+
#ifndef __cpp_lib_constexpr_deque
61+
if (!TEST_IS_CONSTANT_EVALUATED)
62+
#endif
63+
test_one<std::deque<int>>();
6164
test_one<MinSequenceContainer<int>>();
6265
test_one<std::vector<int, min_allocator<int>>>();
6366

@@ -70,6 +73,8 @@ void test() {
7073
check_invariant(m);
7174
LIBCPP_ASSERT(m.empty());
7275
}
76+
77+
return true;
7378
}
7479

7580
void test_exception() {
@@ -96,6 +101,9 @@ void test_exception() {
96101

97102
int main(int, char**) {
98103
test();
104+
#if TEST_STD_VER >= 26
105+
static_assert(test());
106+
#endif
99107
test_exception();
100108

101109
return 0;

0 commit comments

Comments
 (0)