Skip to content

Commit bf95a0c

Browse files
[libc++][test] Avoid C++23 Core features that MSVC lacks (#73438)
Found while running libc++'s test suite with MSVC's STL, where we use both Clang and MSVC's compiler. libc++'s test suite has started using some C++23 Core Language features that MSVC hasn't implemented yet. When avoiding these features costs just a tiny bit of syntax, I would like to ask libc++ to consider making that change in the interest of practical portability, at least until MSVC catches up. If there's no desire to do so, then I could skip the affected tests, but that would make me a slightly sad kitty.
1 parent ca00718 commit bf95a0c

File tree

12 files changed

+34
-34
lines changed

12 files changed

+34
-34
lines changed

libcxx/test/std/containers/views/mdspan/CustomTestLayouts.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class layout_wrapping_integral<WrapArg>::mapping {
176176

177177
friend constexpr void swap(mapping& x, mapping& y) noexcept {
178178
swap(x.extents_, y.extents_);
179-
if !consteval {
179+
if (!std::is_constant_evaluated()) {
180180
swap_counter()++;
181181
}
182182
}
@@ -317,7 +317,7 @@ class always_convertible_layout::mapping {
317317

318318
friend constexpr void swap(mapping& x, mapping& y) noexcept {
319319
swap(x.extents_, y.extents_);
320-
if !consteval {
320+
if (!std::is_constant_evaluated()) {
321321
swap_counter()++;
322322
}
323323
}

libcxx/test/std/containers/views/mdspan/mdspan/CustomTestAccessors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct move_counted_handle {
5353
constexpr move_counted_handle(const move_counted_handle<OtherT>& other) : ptr(other.ptr) {}
5454
constexpr move_counted_handle(move_counted_handle&& other) {
5555
ptr = other.ptr;
56-
if !consteval {
56+
if (!std::is_constant_evaluated()) {
5757
move_counter()++;
5858
}
5959
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_array.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ template <class H, class M, class A, size_t N>
5555
constexpr void
5656
test_mdspan_ctor_array(const H& handle, const M& map, const A&, std::array<typename M::index_type, N> exts) {
5757
using MDS = std::mdspan<typename A::element_type, typename M::extents_type, typename M::layout_type, A>;
58-
if !consteval {
58+
if (!std::is_constant_evaluated()) {
5959
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
6060
}
6161
MDS m(handle, exts);
62-
if !consteval {
62+
if (!std::is_constant_evaluated()) {
6363
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
6464
assert((H::move_counter() == 1));
6565
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_extents.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ constexpr void test_mdspan_types(const H& handle, const M& map, const A&) {
4141
static_assert(mec == std::is_constructible_v<M, const typename M::extents_type&>);
4242
static_assert(ac == std::is_default_constructible_v<A>);
4343
if constexpr (mec && ac) {
44-
if !consteval {
44+
if (!std::is_constant_evaluated()) {
4545
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
4646
}
4747
// use formulation of constructor which tests that its not explicit
4848
MDS m = {handle, map.extents()};
49-
if !consteval {
49+
if (!std::is_constant_evaluated()) {
5050
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
5151
assert((H::move_counter() == 1));
5252
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_integers.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ constexpr void test_mdspan_types(const H& handle, const M& map, const A&, Idxs..
5252
static_assert(ac == std::is_default_constructible_v<A>);
5353

5454
if constexpr (mec && ac) {
55-
if !consteval {
55+
if (!std::is_constant_evaluated()) {
5656
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
5757
}
5858
MDS m(handle, idxs...);
59-
if !consteval {
59+
if (!std::is_constant_evaluated()) {
6060
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
6161
assert((H::move_counter() == 1));
6262
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_map.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ constexpr void test_mdspan_types(const H& handle, const M& map, const A&) {
3838

3939
static_assert(ac == std::is_default_constructible_v<A>);
4040
if constexpr (ac) {
41-
if !consteval {
41+
if (!std::is_constant_evaluated()) {
4242
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
4343
}
4444
// use formulation of constructor which tests that it is not explicit
4545
MDS m = {handle, map};
46-
if !consteval {
46+
if (!std::is_constant_evaluated()) {
4747
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
4848
assert((H::move_counter() == 1));
4949
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_map_acc.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ template <class H, class M, class A>
3333
constexpr void test_mdspan_types(const H& handle, const M& map, const A& acc) {
3434
using MDS = std::mdspan<typename A::element_type, typename M::extents_type, typename M::layout_type, A>;
3535

36-
if !consteval {
36+
if (!std::is_constant_evaluated()) {
3737
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
3838
}
3939
// use formulation of constructor which tests that it is not explicit
4040
MDS m = {handle, map, acc};
41-
if !consteval {
41+
if (!std::is_constant_evaluated()) {
4242
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
4343
assert((H::move_counter() == 1));
4444
}

libcxx/test/std/containers/views/mdspan/mdspan/ctor.dh_span.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ template <class H, class M, class A, size_t N>
5555
constexpr void
5656
test_mdspan_ctor_span(const H& handle, const M& map, const A&, std::span<typename M::index_type, N> exts) {
5757
using MDS = std::mdspan<typename A::element_type, typename M::extents_type, typename M::layout_type, A>;
58-
if !consteval {
58+
if (!std::is_constant_evaluated()) {
5959
move_counted_handle<typename MDS::element_type>::move_counter() = 0;
6060
}
6161
MDS m(handle, exts);
62-
if !consteval {
62+
if (!std::is_constant_evaluated()) {
6363
if constexpr (std::is_same_v<H, move_counted_handle<typename MDS::element_type>>) {
6464
assert((H::move_counter() == 1));
6565
}

libcxx/test/std/containers/views/mdspan/mdspan/swap.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ constexpr void test_swap(MDS a, MDS b) {
4343
}
4444
// This check uses a side effect of layout_wrapping_integral::swap to make sure
4545
// mdspan calls the underlying components' swap via ADL
46-
if !consteval {
46+
if (!std::is_constant_evaluated()) {
4747
if constexpr (std::is_same_v<typename MDS::layout_type, layout_wrapping_integral<4>>) {
4848
assert(MDS::mapping_type::swap_counter() > 0);
4949
}

libcxx/test/std/utilities/expected/expected.expected/observers/has_value.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ constexpr bool test() {
5757
//
5858
// See https://github.com/llvm/llvm-project/issues/68552 and the linked PR.
5959
{
60-
auto f1 = [] -> std::expected<std::optional<int>, long> { return 0; };
60+
auto f1 = []() -> std::expected<std::optional<int>, long> { return 0; };
6161

62-
auto f2 = [&f1] -> std::expected<std::optional<int>, int> {
62+
auto f2 = [&f1]() -> std::expected<std::optional<int>, int> {
6363
return f1().transform_error([](auto) { return 0; });
6464
};
6565

libcxx/test/std/utilities/expected/expected.void/monadic/and_then.pass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,31 @@ static_assert(!has_and_then<const std::expected<int, std::unique_ptr<int>>&&, in
5858
constexpr void test_val_types() {
5959
// Test & overload
6060
{
61-
auto l = [] -> std::expected<int, int> { return 2; };
61+
auto l = []() -> std::expected<int, int> { return 2; };
6262
std::expected<void, int> v;
6363
std::same_as<std::expected<int, int>> decltype(auto) val = v.and_then(l);
6464
assert(val == 2);
6565
}
6666

6767
// Test const& overload
6868
{
69-
auto l = [] -> std::expected<int, int> { return 2; };
69+
auto l = []() -> std::expected<int, int> { return 2; };
7070
const std::expected<void, int> v;
7171
assert(v.and_then(l).value() == 2);
7272
static_assert(std::is_same_v< decltype(v.and_then(l)), std::expected<int, int>>);
7373
}
7474

7575
// Test && overload
7676
{
77-
auto l = [] -> std::expected<int, int> { return 2; };
77+
auto l = []() -> std::expected<int, int> { return 2; };
7878
std::expected<void, int> v;
7979
std::same_as<std::expected<int, int>> decltype(auto) val = std::move(v).and_then(l);
8080
assert(val == 2);
8181
}
8282

8383
// Test const&& overload
8484
{
85-
auto l = [] -> std::expected<int, int> { return 2; };
85+
auto l = []() -> std::expected<int, int> { return 2; };
8686
const std::expected<void, int> v;
8787
std::same_as<std::expected<int, int>> decltype(auto) val = std::move(v).and_then(l);
8888
assert(val == 2);
@@ -92,7 +92,7 @@ constexpr void test_val_types() {
9292
constexpr void test_fail() {
9393
// Test & overload
9494
{
95-
auto f = [] -> std::expected<int, int> {
95+
auto f = []() -> std::expected<int, int> {
9696
assert(false);
9797
return 0;
9898
};
@@ -103,7 +103,7 @@ constexpr void test_fail() {
103103

104104
// Test const& overload
105105
{
106-
auto f = [] -> std::expected<int, int> {
106+
auto f = []() -> std::expected<int, int> {
107107
assert(false);
108108
return 0;
109109
};
@@ -114,7 +114,7 @@ constexpr void test_fail() {
114114

115115
// Test && overload
116116
{
117-
auto f = [] -> std::expected<int, int> {
117+
auto f = []() -> std::expected<int, int> {
118118
assert(false);
119119
return 0;
120120
};
@@ -125,7 +125,7 @@ constexpr void test_fail() {
125125

126126
// Test const&& overload
127127
{
128-
auto f = [] -> std::expected<int, int> {
128+
auto f = []() -> std::expected<int, int> {
129129
assert(false);
130130
return 0;
131131
};

libcxx/test/std/utilities/expected/expected.void/monadic/transform.pass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ static_assert(!has_transform<const std::expected<int, std::unique_ptr<int>>&&, i
3535
constexpr void test_val_types() {
3636
// Test & overload
3737
{
38-
auto l = [] -> int { return 1; };
38+
auto l = []() -> int { return 1; };
3939
std::expected<void, int> v;
4040
std::same_as<std::expected<int, int>> decltype(auto) val = v.transform(l);
4141
assert(val == 1);
4242
}
4343

4444
// Test const& overload
4545
{
46-
auto l = [] -> int { return 1; };
46+
auto l = []() -> int { return 1; };
4747
const std::expected<void, int> v;
4848
std::same_as<std::expected<int, int>> decltype(auto) val = v.transform(l);
4949
assert(val == 1);
5050
}
5151

5252
// Test && overload
5353
{
54-
auto l = [] -> int { return 1; };
54+
auto l = []() -> int { return 1; };
5555
std::expected<void, int> v;
5656
std::same_as<std::expected<int, int>> decltype(auto) val = std::move(v).transform(l);
5757
assert(val == 1);
5858
}
5959

6060
// Test const&& overload
6161
{
62-
auto l = [] -> int { return 1; };
62+
auto l = []() -> int { return 1; };
6363
const std::expected<void, int> v;
6464
std::same_as<std::expected<int, int>> decltype(auto) val = std::move(v).transform(l);
6565
assert(val == 1);
@@ -69,7 +69,7 @@ constexpr void test_val_types() {
6969
constexpr void test_fail() {
7070
// Test & overload
7171
{
72-
auto l = [] -> int {
72+
auto l = []() -> int {
7373
assert(false);
7474
return 0;
7575
};
@@ -80,7 +80,7 @@ constexpr void test_fail() {
8080

8181
// Test const& overload
8282
{
83-
auto l = [] -> int {
83+
auto l = []() -> int {
8484
assert(false);
8585
return 0;
8686
};
@@ -91,7 +91,7 @@ constexpr void test_fail() {
9191

9292
// Test && overload
9393
{
94-
auto l = [] -> int {
94+
auto l = []() -> int {
9595
assert(false);
9696
return 0;
9797
};
@@ -102,7 +102,7 @@ constexpr void test_fail() {
102102

103103
// Test const&& overload
104104
{
105-
auto l = [] -> int {
105+
auto l = []() -> int {
106106
assert(false);
107107
return 0;
108108
};

0 commit comments

Comments
 (0)