Skip to content

Commit 30ec57c

Browse files
Modify all tests to have TEST_CONSTEXPR_CXX26 and without
1 parent 7d73d59 commit 30ec57c

File tree

65 files changed

+595
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+595
-147
lines changed

libcxx/test/std/containers/associative/map/compare.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// template <class Key, class T, class Compare = less<Key>,
1212
// class Allocator = allocator<pair<const Key, T>>>
13-
// class map
13+
// class map // constexpr since C++26
1414

1515
// https://llvm.org/PR16538
1616
// https://llvm.org/PR16549
@@ -27,7 +27,7 @@ struct Key {
2727
bool operator<(const Key&) const { return false; }
2828
};
2929

30-
int main(int, char**) {
30+
TEST_CONSTEXPR_CXX26 bool test() {
3131
typedef std::map<Key, int> MapT;
3232
typedef MapT::iterator Iter;
3333
typedef std::pair<Iter, bool> IterBool;
@@ -50,6 +50,13 @@ int main(int, char**) {
5050
assert(!result2.second);
5151
assert(map[Key(0)] == 42);
5252
}
53+
return true;
54+
}
5355

56+
int main(int, char**) {
57+
assert(test());
58+
#if TEST_STD_VER >= 26
59+
static_assert(test());
60+
#endif
5461
return 0;
5562
}

libcxx/test/std/containers/associative/map/get_allocator.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class map
1212

13-
// allocator_type get_allocator() const
13+
// allocator_type get_allocator() const // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -19,7 +19,7 @@
1919
#include "test_allocator.h"
2020
#include "test_macros.h"
2121

22-
int main(int, char**) {
22+
TEST_CONSTEXPR_CXX26 bool test() {
2323
typedef std::pair<const int, std::string> ValueType;
2424
{
2525
std::allocator<ValueType> alloc;
@@ -31,6 +31,13 @@ int main(int, char**) {
3131
const std::map<int, std::string, std::less<int>, other_allocator<ValueType> > m(alloc);
3232
assert(m.get_allocator() == alloc);
3333
}
34+
return true;
35+
}
3436

37+
int main(int, char**) {
38+
assert(test());
39+
#if TEST_STD_VER >= 26
40+
static_assert(test());
41+
#endif
3542
return 0;
3643
}

libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// <map>
9+
// <map> // constexpr since C++26
1010

1111
// Check that std::map and its iterators can be instantiated with an incomplete
1212
// type.
@@ -25,8 +25,15 @@ struct A {
2525

2626
inline bool operator==(A const& L, A const& R) { return &L == &R; }
2727
inline bool operator<(A const& L, A const& R) { return L.data < R.data; }
28-
int main(int, char**) {
28+
TEST_CONSTEXPR_CXX26 bool test() {
2929
A a;
30+
return true;
31+
}
3032

33+
int main(int, char**) {
34+
assert(test());
35+
#if TEST_STD_VER >= 26
36+
static_assert(test());
37+
#endif
3138
return 0;
3239
}

libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class map
1212

13-
// map(const map& m);
13+
// map(const map& m); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
@@ -20,7 +20,7 @@
2020
#include "test_allocator.h"
2121
#include "min_allocator.h"
2222

23-
int main(int, char**) {
23+
TEST_CONSTEXPR_CXX26 bool test() {
2424
{
2525
typedef std::pair<const int, double> V;
2626
V ar[] = {
@@ -122,6 +122,13 @@ int main(int, char**) {
122122
assert(*std::next(mo.begin(), 2) == V(3, 1));
123123
}
124124
#endif
125+
return true;
126+
}
125127

128+
int main(int, char**) {
129+
assert(test());
130+
#if TEST_STD_VER >= 26
131+
static_assert(test());
132+
#endif
126133
return 0;
127134
}

libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// class map
1212

13-
// map& operator=(const map& m);
13+
// map& operator=(const map& m); // constexpr since C++26
1414

1515
#include <map>
1616
#include <algorithm>
@@ -131,7 +131,7 @@ bool balanced_allocs() {
131131
}
132132
#endif
133133

134-
int main(int, char**) {
134+
TEST_CONSTEXPR_CXX26 bool test() {
135135
{
136136
typedef std::pair<const int, double> V;
137137
V ar[] = {V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2)};
@@ -292,6 +292,13 @@ int main(int, char**) {
292292
}
293293
assert(balanced_allocs());
294294
#endif
295+
return true;
296+
}
295297

298+
int main(int, char**) {
299+
assert(test());
300+
#if TEST_STD_VER >= 26
301+
static_assert(test());
302+
#endif
296303
return 0;
297304
}

libcxx/test/std/containers/associative/map/map.cons/deduct.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// template<ranges::input_range R, class Allocator>
3434
// map(from_range_t, R&&, Allocator)
3535
// -> map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>; // C++23
36-
36+
// constexpr since C++26
3737
#include <algorithm> // std::equal
3838
#include <array>
3939
#include <cassert>
@@ -48,7 +48,7 @@
4848
using P = std::pair<int, long>;
4949
using PC = std::pair<const int, long>;
5050

51-
int main(int, char**) {
51+
TEST_CONSTEXPR_CXX26 bool test() {
5252
{
5353
const P arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
5454
std::map m(std::begin(arr), std::end(arr));
@@ -192,6 +192,13 @@ int main(int, char**) {
192192
#endif
193193

194194
AssociativeContainerDeductionGuidesSfinaeAway<std::map, std::map<int, long>>();
195+
return true;
196+
}
195197

198+
int main(int, char**) {
199+
assert(test());
200+
#if TEST_STD_VER >= 26
201+
static_assert(test());
202+
#endif
196203
return 0;
197204
}

libcxx/test/std/containers/associative/map/map.cons/deduct_const.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// template<class Key, class Allocator>
2525
// map(initializer_list<Key>, Allocator)
2626
// -> map<Key, less<Key>, Allocator>;
27-
27+
// constexpr since C++26
2828
#include <algorithm> // std::equal
2929
#include <cassert>
3030
#include <climits> // INT_MAX
@@ -39,7 +39,7 @@ using P = std::pair<int, long>;
3939
using PC = std::pair<const int, long>;
4040
using PCC = std::pair<const int, const long>;
4141

42-
int main(int, char**) {
42+
TEST_CONSTEXPR_CXX26 bool test() {
4343
{
4444
const PCC arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
4545
std::map m(std::begin(arr), std::end(arr));
@@ -102,6 +102,13 @@ int main(int, char**) {
102102
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
103103
assert(m.get_allocator().get_id() == 45);
104104
}
105+
return true;
106+
}
105107

108+
int main(int, char**) {
109+
assert(test());
110+
#if TEST_STD_VER >= 26
111+
static_assert(test());
112+
#endif
106113
return 0;
107114
}

libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
// class map
1212

13-
// map();
13+
// map(); // constexpr since C++26
1414

1515
#include <map>
1616
#include <cassert>
1717

1818
#include "test_macros.h"
1919
#include "min_allocator.h"
2020

21-
int main(int, char**) {
21+
TEST_CONSTEXPR_CXX26 bool test() {
2222
{
2323
std::map<int, double> m;
2424
assert(m.empty());
@@ -50,6 +50,13 @@ int main(int, char**) {
5050
assert(m.begin() == m.end());
5151
}
5252
#endif
53+
return true;
54+
}
5355

56+
int main(int, char**) {
57+
assert(test());
58+
#if TEST_STD_VER >= 26
59+
static_assert(test());
60+
#endif
5461
return 0;
5562
}

libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// noexcept(
1313
// is_nothrow_default_constructible<allocator_type>::value &&
1414
// is_nothrow_default_constructible<key_compare>::value &&
15-
// is_nothrow_copy_constructible<key_compare>::value);
15+
// is_nothrow_copy_constructible<key_compare>::value); // constexpr since C++26
1616

1717
// This tests a conforming extension
1818

@@ -32,7 +32,7 @@ struct some_comp {
3232
bool operator()(const T&, const T&) const { return false; }
3333
};
3434

35-
int main(int, char**) {
35+
TEST_CONSTEXPR_CXX26 bool test() {
3636
typedef std::pair<const MoveOnly, MoveOnly> V;
3737
#if defined(_LIBCPP_VERSION)
3838
{
@@ -52,6 +52,13 @@ int main(int, char**) {
5252
typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
5353
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
5454
}
55+
return true;
56+
}
5557

58+
int main(int, char**) {
59+
assert(test());
60+
#if TEST_STD_VER >= 26
61+
static_assert(test());
62+
#endif
5663
return 0;
5764
}

libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// <map>
1010

11-
// ~map() // implied noexcept;
11+
// ~map() // implied noexcept; // constexpr since C++26
1212

1313
// UNSUPPORTED: c++03
1414

@@ -26,7 +26,7 @@ struct some_comp {
2626
bool operator()(const T&, const T&) const noexcept { return false; }
2727
};
2828

29-
int main(int, char**) {
29+
TEST_CONSTEXPR_CXX26 bool test() {
3030
typedef std::pair<const MoveOnly, MoveOnly> V;
3131
{
3232
typedef std::map<MoveOnly, MoveOnly> C;
@@ -46,6 +46,13 @@ int main(int, char**) {
4646
static_assert(!std::is_nothrow_destructible<C>::value, "");
4747
}
4848
#endif // _LIBCPP_VERSION
49+
return true;
50+
}
4951

52+
int main(int, char**) {
53+
assert(test());
54+
#if TEST_STD_VER >= 26
55+
static_assert(test());
56+
#endif
5057
return 0;
5158
}

0 commit comments

Comments
 (0)