API reference
-
Macros
- Constrained template macros
- Version macros
-
BOOST_OUTCOME_CO_TRY(var, expr)
Evaluate within a coroutine an expression which results in an understood type, assigning
T
to a decl calledvar
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYV(expr)/BOOST_OUTCOME_CO_TRY(expr)
Evaluate from within a coroutine an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYV2(spec, expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYV2_FAILURE_LIKELY(spec, expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYV_FAILURE_LIKELY(expr)/BOOST_OUTCOME_CO_TRY_FAILURE_LIKELY(expr)
Evaluate from within a coroutine an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYX(expr)
Evaluate from within a coroutine an expression which results in an understood type, emitting the
T
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRYX_FAILURE_LIKELY(expr)
Evaluate from within a coroutine an expression which results in an understood type, emitting the
T
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_CO_TRY_FAILURE_LIKELY(var, expr)
Evaluate within a coroutine an expression which results in an understood type, assigning
T
to a decl calledvar
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_DISABLE_EXECINFO
If defined, disables the use of the
<execinfo.h>
header (or the win32 emulation). -
BOOST_OUTCOME_ENABLE_LEGACY_SUPPORT_FOR
Enables backwards features and naming compatibility for earlier versions of Outcome.
-
BOOST_OUTCOME_NODISCARD
How to tell the compiler than the return value of a function should not be discarded without examining it.
-
BOOST_OUTCOME_REQUIRES(...)
A C++ 20
requires(...)
, if available. -
BOOST_OUTCOME_SYMBOL_VISIBLE
How to mark throwable types as always having default ELF symbol visibility.
-
BOOST_OUTCOME_THREAD_LOCAL
How to mark variables as having thread local storage duration.
-
BOOST_OUTCOME_THROW_EXCEPTION(expr)
How to throw a C++ exception, or equivalent thereof.
-
BOOST_OUTCOME_TRY(var, expr)
Evaluate an expression which results in an understood type, assigning
T
to a decl calledvar
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYV(expr)/BOOST_OUTCOME_TRY(expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYV2(spec, expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYV2_FAILURE_LIKELY(spec, expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYV_FAILURE_LIKELY(expr)/BOOST_OUTCOME_TRY_FAILURE_LIKELY(expr)
Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning
try_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYX(expr)
Evaluate an expression which results in an understood type, emitting the
T
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRYX_FAILURE_LIKELY(expr)
Evaluate an expression which results in an understood type, emitting the
T
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_TRY_FAILURE_LIKELY(var, expr)
Evaluate an expression which results in an understood type, assigning
T
to a decl calledvar
if successful, immediately returningtry_operation_return_as(X)
from the calling function if unsuccessful. -
BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE
How to implement
in_place_type_t<T>
andin_place_type<T>
. -
BOOST_OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE
How to implement
is_nothrow_swappable<T>
.
-
Concepts
-
basic_outcome<T>
A boolean concept matching types which are convertible to a
basic_outcome<T, EC, EP, NoValuePolicy>
. -
basic_result<T>
A boolean concept matching types which are convertible to a
basic_result<T, E, NoValuePolicy>
. -
value_or_error<T>
A boolean concept matching types with either a value or an error.
-
value_or_none<T>
A boolean concept matching types with an optional value.
-
-
Converters
-
value_or_error<T, U>
A customisable converter of
value_or_error<T, E>
concept matching types.
-
-
Traits
-
is_basic_outcome<T>
An integral constant type true for
basic_outcome<T, EC, EP, NoValuePolicy>
types. -
is_basic_result<T>
An integral constant type true for
basic_result<T, E, NoValuePolicy>
types. -
is_error_code_available<T>
True if an error code can be constructed from a
T
. -
is_error_type<E>
A customisable integral constant type true for
E
types which are to receive error throwing no-value policies. -
is_error_type_enum<E, Enum>
A customisable integral constant type true for
E
types constructible fromEnum
types which are to receive error throwing no-value policies. -
is_exception_ptr_available<T>
True if an exception ptr can be constructed from a
T
. -
is_failure_type<T>
An integral constant boolean variable true for
failure_type<EC, E = void>
types. -
is_move_bitcopying<T>
(>= Outcome v2.2.0) A customisable integral constant type true for
T
types which are move bitcopying safe. -
is_success_type<T>
An integral constant boolean variable true for
success_type<T>
types. -
type_can_be_used_in_basic_result<R>
A constexpr boolean true for types permissible in
basic_result<T, E, NoValuePolicy>
.
-
-
Policies
-
base
Base class of most policy classes defining the narrow observer policies.
-
all_narrow
Policy class defining that hard undefined behaviour should occur on incorrect narrow and wide value, error or exception observation. Inherits publicly from
base
. -
error_code_throw_as_system_error<T, EC, EP>
Policy class defining that
EP
ought to be rethrown if possible, then the ADL discovered free functionoutcome_throw_as_system_error_with_payload()
should be called on incorrect wide value observation. Inherits publicly frombase
. Can only be used withbasic_outcome
. -
error_code_throw_as_system_error<T, EC, void>
Policy class defining that the ADL discovered free function
outcome_throw_as_system_error_with_payload()
should be called on incorrect wide value observation. Inherits publicly frombase
. Can only be used withbasic_result
. -
exception_ptr_rethrow<T, EC, EP>
Policy class defining that the ADL discovered free function
rethrow_exception()
should be called on incorrect wide value observation. Inherits publicly frombase
. Can only be used withbasic_outcome
. -
exception_ptr_rethrow<T, EC, void>
Policy class defining that the ADL discovered free function
rethrow_exception()
should be called on incorrect wide value observation. Inherits publicly frombase
. Can only be used withbasic_result
. -
fail_to_compile_observers
Policy class defining that a static assertion should occur upon compilation of the wide value, error or exception observation. Inherits publicly from
base
. -
terminate
Policy class defining that
std::terminate()
should be called on incorrect wide value, error or exception observation. Inherits publicly frombase
. -
throw_bad_result_access<EC>
Policy class defining that
bad_result_access_with<EC>
should be thrown on incorrect wide value observation. Inherits publicly frombase
.
-
-
Types
-
basic_outcome<T, EC, EP, NoValuePolicy>
A type carrying one of (i) a successful
T
(ii) a disappointmentEC
(iii) a failureEP
(iv) both a disappointmentEC
and a failureEP
, withNoValuePolicy
specifying what to do if one tries to read state which isn’t there. -
basic_result<T, E, NoValuePolicy>
A sum type carrying either a successful
T
, or a disappointmentE
, withNoValuePolicy
specifying what to do if one tries to read state which isn’t there. -
bad_outcome_access
Exception type publicly inheriting from
std::logic_error
indicating an incorrect observation of value or error or exception occurred. -
bad_result_access_with<EC>
Exception type publicly inheriting from
bad_result_access
indicating an incorrect observation of value occurred, supplying the error value. -
bad_result_access
Exception type publicly inheriting from
std::logic_error
indicating an incorrect observation of value or error occurred. -
eager<T, Executor = void>/atomic_eager<T, Executor = void>
An eagerly evaluated coroutine awaitable with Outcome customisation.
-
failure_type<EC, EP = void>
Type sugar for constructing an unsuccessful result or outcome.
-
generator<T, Executor = void>
A lazily evaluated coroutine generator with Outcome customisation.
-
in_place_type_t<T>
Either
std::in_place_type_t<T>
or a local emulation, depending on theBOOST_OUTCOME_USE_STD_IN_PLACE_TYPE
macro. -
lazy<T, Executor = void>/atomic_lazy<T, Executor = void>
A lazily evaluated coroutine awaitable with Outcome customisation.
-
success_type<T>
Type sugar for constructing a successful result or outcome.
-
-
Aliases
-
boost_checked<T, E = boost::system::error_code>
A type alias to a
basic_result
configured withboost::system::error_code
andpolicy::throw_bad_result_access<EC>
. -
boost_outcome<T, EC = boost::system::error_code, EP = boost::exception_ptr, NoValuePolicy = policy::default_policy<T, EC, EP>>
A type alias to a
basic_outcome
configured withboost::system::error_code
,boost::exception_ptr
andpolicy::default_policy
. -
boost_result<T, E = boost::system::error_code, NoValuePolicy = policy::default_policy<T, E, void>>
A type alias to a
basic_result
configured withboost::system::error_code
andpolicy::default_policy
. -
boost_unchecked<T, E = boost::system::error_code>
A type alias to a
basic_result
configured withboost::system::error_code
andpolicy::all_narrow
. -
checked<T, E = varies>
A type alias to a
std_checked<T, E>
(standalone edition) orboost_checked<T, E>
(Boost edition). -
default_policy<T, EC, EP>
A type alias to a no-value policy selected based on traits matching of
T
,EC
andEP
. -
outcome<T, EC = varies, EP = varies, NoValuePolicy = policy::default_policy<T, EC, EP>>
A type alias to a
std_outcome<T, EC, EP, NoValuePolicy>
(standalone edition) orboost_outcome<T, EC, EP, NoValuePolicy>
(Boost edition). -
result<T, E = varies, NoValuePolicy = policy::default_policy<T, E, void>>
A type alias to a
std_result<T, E, NoValuePolicy>
(standalone edition) orboost_result<T, E, NoValuePolicy>
(Boost edition). -
std_checked<T, E = std::error_code>
A type alias to a
basic_result
configured withstd::error_code
andpolicy::throw_bad_result_access<EC>
. -
std_outcome<T, EC = std::error_code, EP = std::exception_ptr, NoValuePolicy = policy::default_policy<T, EC, EP>>
A type alias to a
basic_outcome
configured withstd::error_code
,std::exception_ptr
andpolicy::default_policy
. -
std_result<T, E = std::error_code, NoValuePolicy = policy::default_policy<T, E, void>>
A type alias to a
basic_result
configured withstd::error_code
andpolicy::default_policy
. -
std_unchecked<T, E = std::error_code>
A type alias to a
basic_result
configured withstd::error_code
andpolicy::all_narrow
. -
unchecked<T, E = varies>
A type alias to a
std_unchecked<T, E>
(standalone edition) orboost_unchecked<T, E>
(Boost edition).
-
-
Functions
-
Hooks
Functions used to hook into the functionality of
basic_result
andbasic_outcome
. -
Iostream
Functions used to print, serialise and deserialise
basic_result
andbasic_outcome
. -
Policy
Functions used to customise how the policy classes operate.
-
auto failure(T &&, ...)
Returns appropriate type sugar for constructing an unsuccessful result or outcome.
-
auto success(T &&, ...)
Returns appropriate type sugar for constructing a successful result or outcome.
-
bool try_operation_has_value(X)
Default implementation of
try_operation_has_value(X)
ADL customisation point forBOOST_OUTCOME_TRY
. -
decltype(auto) try_operation_extract_value(X)
Default implementation of
try_operation_extract_value(X)
ADL customisation point forBOOST_OUTCOME_TRY
. -
decltype(auto) try_operation_return_as(X)
Default implementation of
try_operation_return_as(X)
ADL customisation point forBOOST_OUTCOME_TRY
. -
std::error_code error_from_exception(std::exception_ptr &&ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept
Returns an error code matching a thrown standard library exception.
-
void strong_swap(bool &all_good, T &a, T &b)
Tries to perform a strong guarantee swap.
-
void try_throw_std_exception_from_error(std::error_code ec, const std::string &msg = std::string{})
Try to throw a standard library exception type matching an error code.
-
Hooks