Types - Boost.Outcome documentation

# Types

1. `basic_outcome<T, EC, EP, NoValuePolicy>`

   A type carrying one of (i) a successful `T` (ii) a disappointment `EC` (iii) a failure `EP` (iv) both a disappointment `EC` and a failure `EP`, with `NoValuePolicy` specifying what to do if one tries to read state which isn’t there.

   1. `basic_outcome() = delete`

      The default constructor (disabled).

   2. `basic_outcome(basic_outcome &&)`

      Move constructor. Constexpr, triviality and noexcept propagating.

   3. `basic_outcome(const basic_outcome &)`

      Copy constructor. Constexpr, triviality and noexcept propagating.

   4. `basic_outcome &operator=(basic_outcome &&)`

      Move assignment. Constexpr, triviality and noexcept propagating.

   5. `basic_outcome &operator=(const basic_outcome &)`

      Copy assignment. Constexpr, triviality and noexcept propagating.

   6. `~basic_outcome()`

      Destructor. Constexpr, triviality and noexcept propagating.

   7. `basic_outcome(Args...) = delete`

      Disabling catchall constructor used to give useful diagnostic error when trying to use non-inplace constructors when `predicate::constructors_enabled` is false.

   8. `basic_outcome(X &&) = delete`

      Disabling implicit constructor used to give useful diagnostic error when trying to use implicit constructors when `predicate::implicit_constructors_enabled` is false.

   9. `basic_outcome(R &&)`

      Implicit `value_type` constructor. Available if `predicate::enable_value_converting_constructor<R>` is true. Constexpr, triviality and noexcept propagating.

   10. `basic_outcome(S &&)`

       Implicit `error_type` constructor. Available if `predicate::enable_error_converting_constructor<S>` is true. Constexpr, triviality and noexcept propagating.

   11. `basic_outcome(ErrorCondEnum &&)`

       Implicit `error_type` from `ErrorCondEnum` constructor. Available if `predicate::enable_error_condition_converting_constructor<ErrorCondEnum>` is true. Constexpr, triviality and noexcept propagating.

   12. `basic_outcome(P &&)`

       Implicit `exception_type` constructor. Available if `predicate::enable_exception_converting_constructor<P>` is true. Constexpr, triviality and noexcept propagating.

   13. `basic_outcome(S &&, P &&)`

       Implicit `error_type` + `exception_type` constructor. Available if `predicate::enable_error_exception_converting_constructor<S, P>` is true. Constexpr, triviality and noexcept propagating.

   14. `explicit basic_outcome(ValueOrError<T, E> &&)`

       Explicit converting constructor from `ValueOrError<T, E>` concept matching types. Available if `convert::value_or_error<>` permits it. Constexpr, triviality and noexcept propagating.

   15. `explicit basic_outcome(const basic_outcome<A, B, C, D> &)`

       Explicit converting copy constructor from compatible `basic_outcome`. Available if `predicate::enable_compatible_conversion<A, B, C, D>` is true. Constexpr, triviality and noexcept propagating.

   16. `explicit basic_outcome(basic_outcome<A, B, C, D> &&)`

       Explicit converting move constructor from compatible `basic_outcome`. Available if `predicate::enable_compatible_conversion<A, B, C, D>` is true. Constexpr, triviality and noexcept propagating.

   17. `explicit basic_outcome(const basic_result<A, B, C> &)`

       Explicit converting copy constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<A, B, void, C>` is true. Constexpr, triviality and noexcept propagating.

   18. `explicit basic_outcome(basic_result<A, B, C> &&)`

       Explicit converting move constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<A, B, void, C>` is true. Constexpr, triviality and noexcept propagating.

   19. `explicit basic_outcome(in_place_type_t<value_type_if_enabled>, Args ...)`

       Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating.

   20. `explicit basic_outcome(in_place_type_t<value_type_if_enabled>, std::initializer_list<U>, Args ...)`

       Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   21. `explicit basic_outcome(in_place_type_t<error_type_if_enabled>, Args ...)`

       Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating.

   22. `explicit basic_outcome(in_place_type_t<error_type_if_enabled>, std::initializer_list<U>, Args ...)`

       Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   23. `explicit basic_outcome(in_place_type_t<exception_type_if_enabled>, Args ...)`

       Explicit inplace exception constructor. Available if `predicate::enable_inplace_exception_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating.

   24. `explicit basic_outcome(in_place_type_t<exception_type_if_enabled>, std::initializer_list<U>, Args ...)`

       Explicit inplace exception constructor. Available if `predicate::enable_inplace_exception_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   25. `basic_outcome(A1 &&, A2 &&, Args ...)`

       Implicit inplace value or error or exception constructor. Available if `predicate::enable_inplace_value_error_exception_constructor<A1, A2, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   26. `basic_outcome(const success_type<T> &)`

       Implicit value-from-success-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   27. `basic_outcome(success_type<T> &&)`

       Implicit value-from-success-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   28. `basic_outcome(const failure_type<EC> &)`

       Implicit error-from-failure-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<void, EC, void, void>` is true. Constexpr, triviality and noexcept propagating.

   29. `basic_outcome(failure_type<EC> &&)`

       Implicit error-from-failure-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<void, EC, void, void>` is true. Constexpr, triviality and noexcept propagating.

   30. `basic_outcome(const failure_type<EP> &)`

       Implicit exception-from-failure-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<void, void, EP, void>` is true. Constexpr, triviality and noexcept propagating.

   31. `basic_outcome(failure_type<EP> &&)`

       Implicit exception-from-failure-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<void, void, EP, void>` is true. Constexpr, triviality and noexcept propagating.

   32. `basic_outcome(const failure_type<EC, EP> &)`

       Implicit error-and-exception-from-failure-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<void, EC, EP, void>` is true. Constexpr, triviality and noexcept propagating.

   33. `basic_outcome(failure_type<EC, EP> &&)`

       Implicit error-and-exception-from-failure-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<void, EC, EP, void>` is true. Constexpr, triviality and noexcept propagating.

   34. `explicit operator bool() const noexcept`

       Returns true if a value is present. Constexpr, never throws.

   35. `bool has_value() const noexcept`

       Returns true if a value is present. Constexpr, never throws.

   36. `bool has_error() const noexcept`

       Returns true if an error is present. Constexpr, never throws.

   37. `bool has_exception() const noexcept`

       Returns true if an exception is present. Constexpr, never throws.

   38. `bool has_failure() const noexcept`

       Returns true if there is either an error or an exception. Constexpr, never throws.

   39. `value_type &assume_value() & noexcept`

       Narrow contract lvalue reference observer of any value present. Constexpr propagating, never throws.

   40. `const value_type &assume_value() const & noexcept`

       Narrow contract const lvalue reference observer of any value present. Constexpr propagating, never throws.

   41. `value_type &&assume_value() && noexcept`

       Narrow contract rvalue reference observer of any value present. Constexpr propagating, never throws.

   42. `const value_type &&assume_value() const && noexcept`

       Narrow contract const rvalue reference observer of any value present. Constexpr propagating, never throws.

   43. `value_type &value() &`

       Wide contract lvalue reference observer of any value present. Constexpr propagating.

   44. `const value_type &value() const &`

       Wide contract const lvalue reference observer of any value present. Constexpr propagating.

   45. `value_type &&value() &&`

       Wide contract rvalue reference observer of any value present. Constexpr propagating.

   46. `const value_type &&value() const &&`

       Wide contract const rvalue reference observer of any value present. Constexpr propagating.

   47. `error_type &assume_error() & noexcept`

       Narrow contract lvalue reference observer of the stored error. Constexpr propagating, never throws.

   48. `const error_type &assume_error() const & noexcept`

       Narrow contract const lvalue reference observer of the stored error. Constexpr propagating, never throws.

   49. `error_type &&assume_error() && noexcept`

       Narrow contract rvalue reference observer of the stored error. Constexpr propagating, never throws.

   50. `const error_type &&assume_error() const && noexcept`

       Narrow contract const rvalue reference observer of the stored error. Constexpr propagating, never throws.

   51. `error_type &error() &`

       Wide contract lvalue reference observer of the stored error. Constexpr propagating.

   52. `const error_type &error() const &`

       Wide contract const lvalue reference observer of the stored error. Constexpr propagating.

   53. `error_type &&error() &&`

       Wide contract rvalue reference observer of the stored error. Constexpr propagating.

   54. `const error_type &&error() const &&`

       Wide contract const rvalue reference observer of the stored error. Constexpr propagating.

   55. `exception_type &assume_exception() & noexcept`

       Narrow contract lvalue reference observer of the stored exception. Constexpr propagating, never throws.

   56. `const exception_type &assume_exception() const & noexcept`

       Narrow contract const lvalue reference observer of the stored exception. Constexpr propagating, never throws.

   57. `const exception_type &&assume_exception() const && noexcept`

       Narrow contract const rvalue reference observer of the stored exception. Constexpr propagating, never throws.

   58. `exception_type &&assume_exception() && noexcept`

       Narrow contract rvalue reference observer of the stored exception. Constexpr propagating, never throws.

   59. `exception_type &exception() &`

       Wide contract lvalue reference observer of the stored exception. Constexpr propagating.

   60. `const exception_type &exception() const &`

       Wide contract const lvalue reference observer of the stored exception. Constexpr propagating.

   61. `exception_type &&exception() &&`

       Wide contract rvalue reference observer of the stored exception. Constexpr propagating.

   62. `const exception_type &&exception() const &&`

       Wide contract const rvalue reference observer of the stored exception. Constexpr propagating.

   63. `exception_type failure() const noexcept`

       Synthesising observer of the stored exception or error. Available if the traits `is_error_code_available<T>` and `is_exception_ptr_available<T>` are both true. Never throws.

   64. `bool operator==(const basic_result<A, B, C> &) const`

       Returns true if this outcome compares equal to the other result. Constexpr and noexcept propagating.

   65. `bool operator==(const basic_outcome<A, B, C, D> &) const`

       Returns true if this outcome compares equal to the other outcome. Constexpr and noexcept propagating.

   66. `bool operator==(const success_type<A> &) const`

       Returns true if this result compares equal to the success type sugar. Constexpr and noexcept propagating.

   67. `bool operator==(const failure_type<A, B> &) const`

       Returns true if this outcome compares equal to the failure type sugar. Constexpr and noexcept propagating.

   68. `bool operator!=(const basic_result<A, B, C> &) const`

       Returns true if this outcome does not compare equal to the other result. Constexpr and noexcept propagating.

   69. `bool operator!=(const basic_outcome<A, B, C, D> &) const`

       Returns true if this outcome does not compare equal to the other outcome. Constexpr and noexcept propagating.

   70. `bool operator!=(const success_type<A> &) const`

       Returns true if this outcome does not compare equal to the success type sugar. Constexpr and noexcept propagating.

   71. `bool operator!=(const failure_type<A, B> &) const`

       Returns true if this outcome does not compare equal to the failure type sugar. Constexpr and noexcept propagating.

   72. `void swap(basic_outcome &)`

       Swap one basic_outcome with another, with the strong guarantee. Noexcept propagating.

   73. `failure_type<error_type, exception_type> as_failure() const &`

       Return the output from free function `failure()` containing a copy of any errored and/or excepted state.

   74. `failure_type<error_type, exception_type> as_failure() &&`

       Return the output from free function `failure()` containing a move of any errored and/or excepted state.

2. `basic_result<T, E, NoValuePolicy>`

   A sum type carrying either a successful `T`, or a disappointment `E`, with `NoValuePolicy` specifying what to do if one tries to read state which isn’t there.

   1. `basic_result() = delete`

      The default constructor (disabled).

   2. `basic_result(basic_result &&)`

      Move constructor. Constexpr, triviality and noexcept propagating.

   3. `basic_result(const basic_result &)`

      Copy constructor. Constexpr, triviality and noexcept propagating.

   4. `basic_result &operator=(basic_result &&)`

      Move assignment. Constexpr, triviality and noexcept propagating.

   5. `basic_result &operator=(const basic_result &)`

      Copy assignment. Constexpr, triviality and noexcept propagating.

   6. `~basic_result()`

      Destructor. Constexpr, triviality and noexcept propagating.

   7. `basic_result(Args...) = delete`

      Disabling catchall constructor used to give useful diagnostic error when trying to use non-inplace constructors when `predicate::constructors_enabled` is false.

   8. `basic_result(X &&) = delete`

      Disabling implicit constructor used to give useful diagnostic error when trying to use implicit constructors when `predicate::implicit_constructors_enabled` is false.

   9. `basic_result(R &&)`

      Implicit `value_type` constructor. Available if `predicate::enable_value_converting_constructor<R>` is true. Constexpr, triviality and noexcept propagating.

   10. `basic_result(S &&)`

       Implicit `error_type` constructor. Available if `predicate::enable_error_converting_constructor<S>` is true. Constexpr, triviality and noexcept propagating.

   11. `basic_result(ErrorCondEnum &&)`

       Implicit `error_type` from `ErrorCondEnum` constructor. Available if `predicate::enable_error_condition_converting_constructor<ErrorCondEnum>` is true. Constexpr, triviality and noexcept propagating.

   12. `explicit basic_result(ValueOrError<T, E> &&)`

       Explicit converting constructor from `ValueOrError<T, E>` concept matching types. Available if `convert::value_or_error<>` permits it. Constexpr, triviality and noexcept propagating.

   13. `explicit basic_result(const basic_result<R, S, P> &)`

       Explicit converting copy constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating.

   14. `explicit basic_result(basic_result<R, S, P> &&)`

       Explicit converting move constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating.

   15. `explicit basic_result(in_place_type_t<value_type_if_enabled>, Args ...)`

       Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating.

   16. `explicit basic_result(in_place_type_t<value_type_if_enabled>, std::initializer_list<U>, Args ...)`

       Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   17. `explicit basic_result(in_place_type_t<error_type_if_enabled>, Args ...)`

       Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating.

   18. `explicit basic_result(in_place_type_t<error_type_if_enabled>, std::initializer_list<U>, Args ...)`

       Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   19. `basic_result(A1 &&, A2 &&, Args ...)`

       Implicit inplace value or error constructor. Available if `predicate::enable_inplace_value_error_constructor<A1, A2, Args ...>` is true. Constexpr, triviality and noexcept propagating.

   20. `basic_result(const success_type<T> &)`

       Implicit value-from-success-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   21. `basic_result(success_type<T> &&)`

       Implicit value-from-success-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   22. `basic_result(const failure_type<T> &)`

       Implicit error-from-failure-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   23. `basic_result(failure_type<T> &&)`

       Implicit error-from-failure-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating.

   24. `explicit operator bool() const noexcept`

       Returns true if a value is present. Constexpr, never throws.

   25. `bool has_value() const noexcept`

       Returns true if a value is present. Constexpr, never throws.

   26. `bool has_error() const noexcept`

       Returns true if an error is present. Constexpr, never throws.

   27. `bool has_exception() const noexcept`

       Always returns false for `basic_result`. Constexpr, never throws.

   28. `bool has_failure() const noexcept`

       Returns true if there is either an error or an exception. Constexpr, never throws.

   29. `bool has_lost_consistency() const noexcept`

       Returns true if a preceding swap involving this object failed to preserve the strong guarantee. Constexpr, never throws.

   30. `value_type &assume_value() & noexcept`

       Narrow contract lvalue reference observer of any value present. Constexpr propagating, never throws.

   31. `const value_type &assume_value() const & noexcept`

       Narrow contract const lvalue reference observer of any value present. Constexpr propagating, never throws.

   32. `value_type &&assume_value() && noexcept`

       Narrow contract rvalue reference observer of any value present. Constexpr propagating, never throws.

   33. `const value_type &&assume_value() const && noexcept`

       Narrow contract const rvalue reference observer of any value present. Constexpr propagating, never throws.

   34. `value_type &value() &`

       Wide contract lvalue reference observer of any value present. Constexpr propagating.

   35. `const value_type &value() const &`

       Wide contract const lvalue reference observer of any value present. Constexpr propagating.

   36. `value_type &&value() &&`

       Wide contract rvalue reference observer of any value present. Constexpr propagating.

   37. `const value_type &&value() const &&`

       Wide contract const rvalue reference observer of any value present. Constexpr propagating.

   38. `error_type &assume_error() & noexcept`

       Narrow contract lvalue reference observer of the stored error. Constexpr propagating, never throws.

   39. `const error_type &assume_error() const & noexcept`

       Narrow contract const lvalue reference observer of the stored error. Constexpr propagating, never throws.

   40. `error_type &&assume_error() && noexcept`

       Narrow contract rvalue reference observer of the stored error. Constexpr propagating, never throws.

   41. `const error_type &&assume_error() const && noexcept`

       Narrow contract const rvalue reference observer of the stored error. Constexpr propagating, never throws.

   42. `error_type &error() &`

       Wide contract lvalue reference observer of the stored error. Constexpr propagating.

   43. `const error_type &error() const &`

       Wide contract const lvalue reference observer of the stored error. Constexpr propagating.

   44. `error_type &&error() &&`

       Wide contract rvalue reference observer of the stored error. Constexpr propagating.

   45. `const error_type &&error() const &&`

       Wide contract const rvalue reference observer of the stored error. Constexpr propagating.

   46. `bool operator==(const basic_result<A, B, C> &) const`

       Returns true if this result compares equal to the other result. Constexpr and noexcept propagating.

   47. `bool operator==(const success_type<A> &) const`

       Returns true if this result compares equal to the success type sugar. Constexpr and noexcept propagating.

   48. `bool operator==(const failure_type<A, void> &) const`

       Returns true if this result compares equal to the failure type sugar. Constexpr and noexcept propagating.

   49. `bool operator!=(const basic_result<A, B, C> &) const`

       Returns true if this result does not compare equal to the other result. Constexpr and noexcept propagating.

   50. `bool operator!=(const success_type<A> &) const`

       Returns true if this result does not compare equal to the success type sugar. Constexpr and noexcept propagating.

   51. `bool operator!=(const failure_type<A, void> &) const`

       Returns true if this result does not compare equal to the failure type sugar. Constexpr and noexcept propagating.

   52. `void swap(basic_result &)`

       Swap one basic_result with another, with the strong guarantee. Noexcept propagating.

   53. `auto as_failure() const &`

       Return the output from free function `failure()` containing a copy of any errored state.

   54. `auto as_failure() &&`

       Return the output from free function `failure()` containing a move of any errored state.

3. `bad_outcome_access`

   Exception type publicly inheriting from `std::logic_error` indicating an incorrect observation of value or error or exception occurred.

4. `bad_result_access_with<EC>`

   Exception type publicly inheriting from `bad_result_access` indicating an incorrect observation of value occurred, supplying the error value.

5. `bad_result_access`

   Exception type publicly inheriting from `std::logic_error` indicating an incorrect observation of value or error occurred.

6. `failure_type<EC, EP = void>`

   Type sugar for constructing an unsuccessful result or outcome.

7. `in_place_type_t<T>`

   Either `std::in_place_type_t<T>` or a local emulation, depending on the `BOOST_OUTCOME_USE_STD_IN_PLACE_TYPE` macro.

8. `success_type<T>`

   Type sugar for constructing a successful result or outcome.

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