API reference

Project index

  • CXX_DECLARE_RESULT — Declares a C struct representation of result<R, S>.

  • CXX_DECLARE_RESULT_EC — Declares a C struct representation of result<R, std::error_code>.

  • CXX_RESULT — A reference to a previously declared struct by CXX_DECLARE_RESULT(R, RD, S, SD)

  • CXX_RESULT_EC — A reference to a previously declared struct by CXX_DECLARE_RESULT_EC(R, RD)

  • CXX_RESULT_ERROR — C11 generic selecting a result struct’s error or code integer member.

  • CXX_RESULT_ERROR_IS_ERRNO — True if a result struct’s error or code is an errno domain code suitable for setting errno with.

  • CXX_RESULT_HAS_ERROR — True if a result struct has a valid error

  • CXX_RESULT_HAS_VALUE — True if a result struct has a valid value

  • CXX_RESULT_SET_ERRNO — Convenience macro setting errno to a result struct’s errno compatible error if present, or EAGAIN if errored but incompatible.

  • OUTCOME_TRY — If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure immediately, else set v to the unwrapped value.

  • OUTCOME_TRYV — If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure state immediately

  • OUTCOME_TRYX — If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure state immediately, else become the unwrapped value as an expression. This makes OUTCOME_TRYX(expr) an expression which can be used exactly like the try operator in other languages.

  • cxx_error_code — A C struct representation of std::error_code.

  • Namespace outcome_v2_xxx::convert

    Namespace for injected convertibility

  • Namespace outcome_v2_xxx::hooks

    Namespace containing hooks used for intercepting and manipulating result/outcome

    • hook_outcome_construction — The default instantiation hook implementation called when a outcome is first created by conversion from one of its possible types. Does nothing.

    • hook_outcome_copy_construction — The default instantiation hook implementation called when a outcome is created by copying from another outcome or result. Does nothing.

    • hook_outcome_in_place_construction — The default instantiation hook implementation called when a outcome is created by in place construction. Does nothing.

    • hook_outcome_move_construction — The default instantiation hook implementation called when a outcome is created by moving from another outcome or result. Does nothing.

    • hook_result_construction — The default instantiation hook implementation called when a result is first created by conversion from one of its possible types. Does nothing.

    • hook_result_copy_construction — The default instantiation hook implementation called when a result is created by copying from another result. Does nothing.

    • hook_result_in_place_construction — The default instantiation hook implementation called when a result is created by in place construction. Does nothing.

    • hook_result_move_construction — The default instantiation hook implementation called when a result is created by moving from another result. Does nothing.

    • override_outcome_exception — Used in hook implementations to override the payload/exception to something other than what was constructed.

    • set_spare_storage — Sets the sixteen bits of spare storage in a result or outcome.

    • spare_storage — Get the sixteen bits of spare storage in a result or outcome.

  • Namespace outcome_v2_xxx::policy

    Namespace for policies

    • all_narrow — Policy which treats wide checks as narrow checks.

    • default_policy — Default policy selector.

    • error_code — Used by policies to extract a std::error_code from some input T via ADL discovery of some make_error_code(T) function.

    • error_code_throw_as_system_error — Policy interpreting EC as a type for which trait::has_error_code_v<EC> is true.

    • exception_ptr — Used by policies to extract a std::exception_ptr from some input T via ADL discovery of some make_exception_ptr(T) function.

    • exception_ptr_rethrow — Policy interpreting EC or E as a type for which trait::has_exception_ptr_v<EC|E> is true.

    • terminate — Policy implementing any wide attempt to access the successful state as calling std::terminate

    • throw_as_system_error_with_payload — Override to define what the policies which throw a system error with payload ought to do for some particular result.error().

    • throw_bad_result_access — Policy which throws bad_result_access_with<EC> or bad_result_access during wide checks.

  • Namespace outcome_v2_xxx::trait

    Namespace for traits

    • has_error_code — Trait for whether a free function make_error_code(T) returning a std::error_code exists or not.

    • has_error_code_v — Trait for whether a free function make_error_code(T) returning a std::error_code exists or not.

    • has_exception_ptr — Trait for whether a free function make_exception_ptr(T) returning a std::exception_ptr exists or not.

    • has_exception_ptr_v — Trait for whether a free function make_exception_ptr(T) returning a std::exception_ptr exists or not.

  • Namespace outcome_v2_xxx

    • bad_outcome_access — Thrown when you try to access state in a outcome<T, EC, E> which isn’t present.

    • bad_result_access — Thrown when you try to access state in a result<R, S> which isn’t present.

    • bad_result_access_with — Thrown when you try to access a value in a result<R, S> which isn’t present.

    • checked — A “checked” edition of result<T, E> which resembles fairly closely a std::expected<T, E>.

    • error_from_exception — Utility function which tries to match the exception in the pointer provided to an equivalent error code. Ought to work for all standard STL types.

    • failure — Returns type sugar for implicitly constructing a result<T> with a failure state.

    • failure_type — Type sugar for implicitly constructing a result<> with a failure state of error code and exception.

    • in_place_type — Aliases std::in_place_type<T> if on C++ 17 or later, else defined locally.

    • in_place_type_t — Aliases std::in_place_type_t<T> if on C++ 17 or later, else defined locally.

    • is_outcome — True if an outcome

    • is_outcome_v — True if an outcome

    • is_result — True if a result

    • is_result_v — True if a result

    • operator!= — True if the result is not equal to the outcome

    • operator<< — Serialise a result. Format is status_unsigned [value][error]. Spare storage is preserved.

    • operator== — True if the result is equal to the outcome

    • operator>> — Deserialise a result. Format is status_unsigned [value][error]. Spare storage is preserved.

    • outcome — Used to return from functions one of (i) a successful value (ii) a cause of failure (ii) a different cause of failure. constexpr capable.

    • print — Debug print a result into a form suitable for human reading. Format is value|error. If the error type is error_code, appends " (ec.message())" afterwards.

    • result — Used to return from functions either (i) a successful value (ii) a cause of failure. constexpr capable.

    • success — Returns type sugar for implicitly constructing a result<T> with a successful state, default constructing T if necessary.

    • success_type — Type sugar for implicitly constructing a result<> with a successful state.

    • swap — Specialise swap for result.

    • try_operation_return_as — Customisation point for changing what the OUTCOME_TRY macros do. This function defaults to returning std::forward<T>(v).as_failure().

    • try_throw_std_exception_from_error — Utility function which tries to throw the equivalent STL exception type for some given error code, not including system_error.

    • unchecked — An “unchecked” edition of result<T, E> which does no special handling of specific E types at all.