Functions - Boost.Outcome documentation

# Functions

1. Hooks

   Functions used to hook into the functionality of `basic_result` and `basic_outcome`.

   1. `uint16_t spare_storage(const basic_result|basic_outcome *) noexcept`

      Returns the sixteen bits of spare storage in the specified result or outcome.

   2. `void hook_outcome_construction(T *, U &&) noexcept`

      ADL discovered free function hook invoked by the implicit constructors of `basic_outcome`.

   3. `void hook_outcome_construction(T *, U &&, V &&) noexcept`

      ADL discovered free function hook invoked by the implicit constructors of `basic_outcome`.

   4. `void hook_outcome_copy_construction(T *, U &&) noexcept`

      ADL discovered free function hook invoked by the converting copy constructors of `basic_outcome`.

   5. `void hook_outcome_copy_construction(T *, U &&, V &&) noexcept`

      ADL discovered free function hook invoked by the converting copy constructors of `basic_outcome`.

   6. `void hook_outcome_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept`

      ADL discovered free function hook invoked by the in-place constructors of `basic_outcome`.

   7. `void hook_outcome_move_construction(T *, U &&) noexcept`

      ADL discovered free function hook invoked by the converting move constructors of `basic_outcome`.

   8. `void hook_outcome_move_construction(T *, U &&, V &&) noexcept`

      ADL discovered free function hook invoked by the converting move constructors of `basic_outcome`.

   9. `void hook_result_construction(T *, U &&) noexcept`

      ADL discovered free function hook invoked by the implicit constructors of `basic_result`.

   10. `void hook_result_copy_construction(T *, U &&) noexcept`

       ADL discovered free function hook invoked by the converting copy constructors of `basic_result`.

   11. `void hook_result_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept`

       ADL discovered free function hook invoked by the in-place constructors of `basic_result`.

   12. `void hook_result_move_construction(T *, U &&) noexcept`

       ADL discovered free function hook invoked by the converting move constructors of `basic_result`.

   13. `void override_outcome_exception(basic_outcome<T, EC, EP, NoValuePolicy> *, U &&) noexcept`

       Overrides the exception to something other than what was constructed.

   14. `void set_spare_storage(basic_result|basic_outcome *, uint16_t) noexcept`

       Sets the sixteen bits of spare storage in the specified result or outcome.

2. Iostream

   Functions used to print, serialise and deserialise `basic_result` and `basic_outcome`.

   1. `std::istream &operator>>(std::istream &, basic_outcome<T, EC, EP, NoValuePolicy> &)`

      Deserialises a `basic_outcome` from a `std::istream`.

   2. `std::istream &operator>>(std::istream &, basic_result<T, E, NoValuePolicy> &)`

      Deserialises a `basic_result` from a `std::istream`.

   3. `std::ostream &operator<<(std::ostream &, const basic_outcome<T, EC, EP, NoValuePolicy> &)`

      Serialises a `basic_outcome` to a `std::ostream`.

   4. `std::ostream &operator<<(std::ostream &, const basic_result<T, E, NoValuePolicy> &)`

      Serialises a `basic_result` to a `std::ostream`.

   5. `std::string print(const basic_outcome<T, EC, EP, NoValuePolicy> &)`

      Returns a string containing a human readable rendition of the `basic_outcome`.

   6. `std::string print(const basic_result<T, E, NoValuePolicy> &)`

      Returns a string containing a human readable rendition of the `basic_result`.

3. Policy

   Functions used to customise how the policy classes operate.

   1. `auto basic_outcome_failure_exception_from_error(const EC &)`

      ADL discovered free function synthesising an exception type from an error type, used by the `.failure()` observers.

   2. `decltype(auto) error_code(T &&)`

      Extracts a `boost::system::error_code` or `std::error_code` from the input via ADL discovery of a suitable `make_error_code(T)` function.

   3. `decltype(auto) exception_ptr(T &&)`

      Extracts a `boost::exception_ptr` or `std::exception_ptr` from the input via ADL discovery of a suitable `make_exception_ptr(T)` function.

   4. `void outcome_throw_as_system_error_with_payload(BoostErrorCodeEnum &&)`

      Specialisation of `outcome_throw_as_system_error_with_payload()` for input types where `boost::system::errc::is_error_code_enum<BoostErrorCodeEnum>` or `boost::system::errc::is_error_condition_enum<BoostErrorCodeEnum>` is true.

   5. `void outcome_throw_as_system_error_with_payload(ErrorCodeEnum &&)`

      Specialisation of `outcome_throw_as_system_error_with_payload()` for input types where `std::is_error_code_enum<ErrorCodeEnum>` or `std::is_error_condition_enum<ErrorCodeEnum>` is true.

   6. `void outcome_throw_as_system_error_with_payload(const boost::system::error_code &)`

      Specialisation of `outcome_throw_as_system_error_with_payload()` for `boost::system::error_code`.

   7. `void outcome_throw_as_system_error_with_payload(const std::error_code &)`

      Specialisation of `outcome_throw_as_system_error_with_payload()` for `std::error_code`.

4. `auto failure(T &&, ...)`

   Returns appropriate type sugar for constructing an unsuccessful result or outcome.

5. `auto success(T &&)`

   Returns appropriate type sugar for constructing a successful result or outcome.

6. `bool try_operation_has_value(X)`

   Default implementation of `try_operation_has_value(X)` ADL customisation point for `BOOST_OUTCOME_TRY`.

7. `decltype(auto) try_operation_extract_value(X)`

   Default implementation of `try_operation_extract_value(X)` ADL customisation point for `BOOST_OUTCOME_TRY`.

8. `decltype(auto) try_operation_return_as(X)`

   Default implementation of `try_operation_return_as(X)` ADL customisation point for `BOOST_OUTCOME_TRY`.

9. `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.

10. `void strong_swap(bool &all_good, T &a, T &b)`

    Tries to perform a strong guarantee swap.

11. `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.

Last revised: December 13, 2018 at 21:10:19 UTC