#include <expected.h>
Inherits AZStd::Internal::expected_storage_move_assignment< T, E, special_member_availability >.
Inherited by AZ::Outcome< void, VisitorError > [private], AZ::Outcome< void, AZStd::string > [private], and AZ::Outcome< ValueT, ErrorT > [private].
Public Types | |
| using | value_type = T |
| using | error_type = E |
| using | unexpected_type = unexpected< E > |
| template<class U > | |
| using | rebind = expected< U, error_type > |
Public Member Functions | |
| constexpr | expected (const expected &rhs)=default |
copy constructor - Defaults to the expected_storage_copy_constructor for constraint checks | |
| constexpr | expected (expected &&rhs)=default |
move constructor - Defaults to the expected_storage_move_constructor for constraint checks | |
| template<class U , class G > requires ((is_void_v<T> && is_void_v<U>) || is_constructible_v<T, add_lvalue_reference_t<const U>>) && is_constructible_v<E, const G&> && Internal::not_convertible_or_constructible_from_other_std_expected_v<T, E, U, G> | |
| constexpr | expected (const expected< U, G > &rhs) |
| template<class U , class G > requires ((is_void_v<T> && is_void_v<U>) || is_constructible_v<T, U>) && is_constructible_v<E, G> && Internal::not_convertible_or_constructible_from_other_std_expected_v<T, E, U, G> | |
| constexpr | expected (expected< U, G > &&rhs) |
|
template<class U > requires (!is_void_v<T>) && (!is_same_v<remove_cvref_t<U>, in_place_t>) && (!is_same_v<expected<T, E>, remove_cvref_t<U>>) && (!Internal::is_std_unexpected_specialization_v<remove_cvref_t<U>>) && is_constructible_v<T, U> | |
| constexpr | expected (U &&v) |
|
template<class G > requires is_constructible_v<E, const G&> | |
| constexpr | expected (const unexpected< G > &err) |
|
template<class G > requires is_constructible_v<E, G> | |
| constexpr | expected (unexpected< G > &&err) |
|
template<class... Args> requires (!is_void_v<T>) && is_constructible_v<T, Args...> | |
| constexpr | expected (in_place_t, Args &&... args) |
| Direct non-list initialization for expected type with variadic arguments. | |
|
template<class U , class... Args> requires (!is_void_v<T>) && is_constructible_v<T, initializer_list<U>&, Args...> | |
| constexpr | expected (in_place_t, initializer_list< U > il, Args &&...args) |
|
template<bool = true> requires is_void_v<T> | |
| constexpr | expected (in_place_t) |
| expected<void, E> specialization for in-place constructor | |
|
template<class... Args> requires is_constructible_v<E, Args...> | |
| constexpr | expected (unexpect_t, Args &&... args) |
| Direct non-list initialization for error type with variadic arguments. | |
|
template<class U , class... Args> requires is_constructible_v<E, initializer_list<U>&, Args...> | |
| constexpr | expected (unexpect_t, initializer_list< U > il, Args &&...args) |
| ~expected ()=default | |
destructor - Defaults to the expected_union for constraint checks | |
| constexpr expected & | operator= (const expected &rhs)=default |
| Copy-assignment from other expected. | |
| constexpr expected & | operator= (expected &&rhs) noexcept(is_nothrow_move_assignable_v< T > &&is_nothrow_move_constructible_v< T > &&is_nothrow_move_assignable_v< E > &&is_nothrow_move_constructible_v< E >)=default |
| Move-assignment from other expected. | |
|
template<class U > requires (!is_void_v<T>) && (!is_same_v<expected<T, E>, remove_cvref_t<U>>) && (!Internal::is_std_unexpected_specialization_v<remove_cvref_t<U>>) && is_constructible_v<T, U> && is_assignable_v<add_lvalue_reference_t<T>, U> | |
| constexpr auto | operator= (U &&value) -> expected & |
| Direct initializes value into expected. | |
|
template<class G > requires is_constructible_v<E, const G&> && is_assignable_v<E&, const G&> | |
| constexpr auto | operator= (const unexpected< G > &error) -> expected & |
| Copy error into expected. | |
|
template<class G > requires is_constructible_v<E, G> && is_assignable_v<E&, G> | |
| constexpr auto | operator= (unexpected< G > &&error) -> expected & |
| Move error into expected. | |
| template<class... Args> | |
| constexpr decltype(auto) | emplace (Args &&... args) noexcept |
| emplace overloads for when T is not a void type | |
| template<class U , class... Args> | |
| constexpr decltype(auto) | emplace (initializer_list< U > il, Args &&... args) noexcept |
| constexpr void | emplace () noexcept |
| emplace overload for when T is void | |
| constexpr auto | swap (expected &rhs) noexcept(is_nothrow_move_constructible_v< T > &&is_nothrow_swappable_v< T > &&is_nothrow_move_constructible_v< E > &&is_nothrow_swappable_v< E >) -> void |
| constexpr | operator bool () const noexcept |
| Returns whether the expected contains a value type(true) or error type(false) | |
| constexpr bool | has_value () const noexcept |
| constexpr auto | operator-> () const noexcept -> const T * |
| constexpr auto | operator-> () noexcept -> T * |
| constexpr auto | operator* () const &noexcept -> add_lvalue_reference_t< const T > |
| constexpr auto | operator* () &noexcept -> add_lvalue_reference_t< T > |
| constexpr auto | operator* () const &&noexcept -> add_rvalue_reference_t< const T > |
| constexpr auto | operator* () &&noexcept -> add_rvalue_reference_t< T > |
| constexpr auto | value () const &-> add_lvalue_reference_t< const T > |
| constexpr auto | value () &-> add_lvalue_reference_t< T > |
| constexpr auto | value () const &&-> add_rvalue_reference_t< const T > |
| constexpr auto | value () &&-> add_rvalue_reference_t< T > |
| constexpr void | operator* () const &noexcept |
| constexpr void | operator* () const &&noexcept |
| constexpr void | value () const & |
| constexpr void | value () && |
| constexpr const E & | error () const &noexcept |
| constexpr E & | error () &noexcept |
| constexpr const E && | error () const &&noexcept |
| constexpr E && | error () &&noexcept |
|
template<class U > requires (!is_void_v<T>) | |
| constexpr auto | value_or (U &&value) const &-> T |
|
template<class U > requires (!is_void_v<T>) | |
| constexpr auto | value_or (U &&value) &&-> T |
Friends | |
| constexpr void | swap (expected &x, expected &y) noexcept(noexcept(x.swap(y))) |
| template<class T2 , class E2 > | |
| constexpr bool | operator== (const expected &x, const expected< T2, E2 > &y) |
| template<class T2 , class E2 > | |
| constexpr bool | operator!= (const expected &x, const expected< T2, E2 > &y) |
| template<class T2 > | |
| constexpr bool | operator== (const expected &x, const T2 &value) |
| template<class T2 > | |
| constexpr bool | operator!= (const expected &x, const T2 &value) |
| template<class E2 > | |
| constexpr bool | operator== (const expected &x, const unexpected< E2 > &err) |
| template<class E2 > | |
| constexpr bool | operator!= (const expected &x, const unexpected< E2 > &err) |
Implementation of C++23 std::expected The AZ::Outcome class inherits from it with a few differences to the initial state AZStd::expected default constructs with the expected(success) value. AZStd::expected supports operator*, operator-> and emplace functions AZStd::expected does NOT support an error type of void, AZStd::optional<T> should be used instead AZ::Outcome default constructs with the failure(unexpected) value. AZ::Outcome also supports void error type, which is not needed, as in that case an AZStd::optional is a better choice differences from std::expected Since O3DE doesn't use exceptions, noexcept isn't used throughout the code. Therefore the constraints on needing types to be noexcept are not in the AZStd::expected implementation
|
inlineconstexpr |
Direct initialization copy constructor Allows construction of an expected from a type that can direct initialize T
|
inlineconstexpr |
Direct initialization move constructor The first class = parameter check the condition for whether the constructor should be explicit The second class= paramter checks the constraints on the constructor