Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Prev Up HomeNext

Built-in policies

These are the predefined policies built into Outcome:

all_narrow

If 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:

Upon missing error observation throws:

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:

Upon missing error observation:

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.

Last revised: February 06, 2019 at 14:38:54 UTC


Prev Up HomeNext