summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/expected
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/expected')
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/bad.cc15
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/cons.cc18
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/requirements.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/swap.cc12
4 files changed, 40 insertions, 7 deletions
diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc
new file mode 100644
index 00000000000..17bc6d69e88
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc
@@ -0,0 +1,15 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile }
+
+#include <expected>
+
+struct E {
+ E() = default;
+ E(E&&) = default;
+};
+
+void
+test_pr105146()
+{
+ std::bad_expected_access(E{});
+}
diff --git a/libstdc++-v3/testsuite/20_util/expected/cons.cc b/libstdc++-v3/testsuite/20_util/expected/cons.cc
index 1fe5b7bf4d1..6946858198c 100644
--- a/libstdc++-v3/testsuite/20_util/expected/cons.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/cons.cc
@@ -162,6 +162,22 @@ test_copy()
return true;
}
+constexpr bool
+test_pr105153()
+{
+ struct E {
+ E(int&&) = delete;
+ E(const int&);
+ };
+
+ std::expected<void, E> e(std::expected<void, int>{});
+
+ static_assert( ! std::is_constructible_v<std::expected<void, int>,
+ std::expected<int, int>> );
+
+ return true;
+}
+
int main()
{
test_default();
@@ -172,4 +188,6 @@ int main()
static_assert( test_err() );
test_copy();
static_assert( test_copy() );
+ test_pr105153();
+ static_assert( test_pr105153() );
}
diff --git a/libstdc++-v3/testsuite/20_util/expected/requirements.cc b/libstdc++-v3/testsuite/20_util/expected/requirements.cc
index 485aa338679..aae7059ef71 100644
--- a/libstdc++-v3/testsuite/20_util/expected/requirements.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/requirements.cc
@@ -124,6 +124,6 @@ static_assert( move_assignable< void, G > );
// QoI properties
static_assert( sizeof(std::expected<char, unsigned char>) == 2 );
static_assert( sizeof(std::expected<void, char>) == 2 );
-static_assert( sizeof(std::expected<void*, char>) == 2 * __alignof(void*) );
+static_assert( sizeof(std::expected<void*, char>) == sizeof(void*) + __alignof(void*) );
static_assert( alignof(std::expected<void, char>) == 1 );
static_assert( alignof(std::expected<void*, char>) == alignof(void*) );
diff --git a/libstdc++-v3/testsuite/20_util/expected/swap.cc b/libstdc++-v3/testsuite/20_util/expected/swap.cc
index 1b3b8c5f4e8..745db65fc6c 100644
--- a/libstdc++-v3/testsuite/20_util/expected/swap.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/swap.cc
@@ -27,19 +27,19 @@ test_swap()
VERIFY( e3.error() == 4 );
VERIFY( e4.error() == 3 );
- std::expected<int, int> v1(1), v2(2);
- std::expected<int, int> v3(std::unexpect, 3), v4(std::unexpect, 4);
+ std::expected<void, int> v1, v2;
+ std::expected<void, int> v3(std::unexpect, 3), v4(std::unexpect, 4);
swap(v1, v2);
- VERIFY( v1.value() == 2 );
- VERIFY( v2.value() == 1 );
+ VERIFY( v1.has_value() );
+ VERIFY( v2.has_value() );
swap(v1, v3);
VERIFY( ! v1.has_value() );
VERIFY( v1.error() == 3 );
- VERIFY( v3.value() == 2 );
+ VERIFY( v3.has_value() );
swap(v1, v3);
VERIFY( ! v3.has_value() );
- VERIFY( v1.value() == 2 );
+ VERIFY( v1.has_value() );
VERIFY( v3.error() == 3 );
swap(v3, v4);
VERIFY( ! v3.has_value() );