Built-in policies
These are the predefined policies built into Outcome:
all_narrowIf there is an observation of a value/error/exception which is not present,
the program is put into a hard undefined behaviour situation. However this
is a tool-friendly UB using intrinsics
such as __builtin_unreachable() that allows tools to make use of it, e.g.,
better bug detection or optimizations.
terminate
Observation of a missing value/error/exception causes a call to
std::terminate().
error_code_throw_as_system_error<T, EC, EP>
This policy assumes that EC has the interface of std::error_code,
and EP has the interface of std::exception_ptr. Upon missing value
observation:
- if an exception is stored through pointer of type
EPit is rethrown; - otherwise, if an error of type
ECis stored, it is converted toerror_codeand then thrown assystem_error.
Upon missing error observation throws:
bad_result_access("no error")from instances ofbasic_result<>.bad_outcome_access("no error")from instances ofbasic_outcome<>.
Upon missing exception observation throws bad_outcome_access("no exception").
Overloads are provided for boost::system::error_code and boost::exception_ptr.
exception_ptr_rethrow<T, EC, EP>
This policy assumes that either EC or EP (unless void) has the interface of std::exception_ptr. Upon missing value observation:
- in instances of
basic_result<>, rethrows exception pointed to byEC; - in instances of
basic_outcome<>, if exceptionEPis present rethrows it, otherwise rethrowsEC.
Upon missing error observation:
- in instances of
basic_result<>, throwsbad_result_access("no error"); - in instances of
basic_outcome<>, throwsbad_outcome_access("no error").
Upon missing exception observation throws bad_outcome_access("no exception").
Overloads are provided for boost::exception_ptr.
throw_bad_result_access<EC>
Upon missing value observation throws bad_result_access_with<EC>(ec),
where ec is the value of the stored error. If error is not stored,
the behaviour is undefined.
Upon missing error observation throws bad_result_access("no error").
This policy can be used with basic_outcome<> instances, where it always
throws bad_outcome_access for all no-value/error/exception observations.



