// { dg-do run { target c++23 } } #include #include constexpr void test_convert_contained_value_to_bool() { struct BaseError { }; struct DerivedError : BaseError { }; std::expected e = false; // Should use expected(const expected&) ctor, not expected(U&&): std::expected e2 = e; // Contained value should be e.value() not static_cast(e): VERIFY( e2.value() == false ); std::expected e3(std::unexpect); std::expected e4 = e3; // Should have error, not static_cast(e3): VERIFY( ! e4.has_value() ); } int main() { test_convert_contained_value_to_bool(); static_assert([] { test_convert_contained_value_to_bool(); return true; }()); }