Change operator* and operator-> to throw instead of having a precondition

This commit is contained in:
Peter Dimov
2026-02-21 03:26:49 +02:00
parent 0ff6989330
commit 9ead4aeea9
16 changed files with 228 additions and 141 deletions
+10 -1
View File
@@ -27,6 +27,15 @@ struct X
int X::instances = 0;
struct E
{
};
BOOST_NORETURN void throw_exception_from_error( X const &, boost::source_location const& )
{
throw E();
}
int main()
{
{
@@ -53,7 +62,7 @@ int main()
BOOST_TEST( r.has_value() );
BOOST_TEST( !r.has_error() );
BOOST_TEST_EQ( *r, 1 );
BOOST_TEST_EQ( r.unsafe_value(), 1 );
}
BOOST_TEST_EQ( X::instances, 0 );