[libcxx-commits] [libcxx] Fix `expected::error_or(...) &&` test (PR #215553)
David Bayer via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 11 06:19:57 PDT 2026
https://github.com/davebayer created https://github.com/llvm/llvm-project/pull/215553
In tests that should test the `expected::error_or(...) &&` member function the `e` member is declared as `const`, thus the `const &` version is used and the `&&` overload stays untested. This PR removes the `const` specifier from the variable.
>From 639a234c28b113f9fb3c0f6ef3375fe13d9f5abe Mon Sep 17 00:00:00 2001
From: David Bayer <bayer.david99 at gmail.com>
Date: Tue, 11 Aug 2026 15:16:14 +0200
Subject: [PATCH] Fix `expected::error_or(...) &&` test
---
.../expected/expected.expected/observers/error_or.pass.cpp | 4 ++--
.../expected/expected.void/observers/error_or.pass.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
index f698f44ba8f3a..3052bc2974066 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/observers/error_or.pass.cpp
@@ -39,14 +39,14 @@ constexpr bool test_default_template_arg() {
// &&, has_value()
{
- const std::expected<int, ConstructFromInt> e(5);
+ std::expected<int, ConstructFromInt> e(5);
std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
assert(x.value == 10);
}
// &&, !has_value()
{
- const std::expected<int, ConstructFromInt> e(std::unexpect, 5);
+ std::expected<int, ConstructFromInt> e(std::unexpect, 5);
std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
assert(x.value == 5);
}
diff --git a/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp b/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
index db2891f61c3cb..e5d9b1dc2eeaf 100644
--- a/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.void/observers/error_or.pass.cpp
@@ -39,14 +39,14 @@ constexpr bool test_default_template_arg() {
// &&, has_value()
{
- const std::expected<void, ConstructFromInt> e;
+ std::expected<void, ConstructFromInt> e;
std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
assert(x.value == 10);
}
// &&, !has_value()
{
- const std::expected<void, ConstructFromInt> e(std::unexpect, 5);
+ std::expected<void, ConstructFromInt> e(std::unexpect, 5);
std::same_as<ConstructFromInt> decltype(auto) x = std::move(e).error_or(10);
assert(x.value == 5);
}
More information about the libcxx-commits
mailing list