template <typename T, typename E>
expected class
A C++23-like expected
.
Constructors, destructors, conversion operators
-
template <typename... Args, typename = std::expected(std::
enable_if_t<std:: is_constructible_v<T, Args...>>> in_place_t, Args && ... args) explicit constexpr noexcept(…) - Construct an expected value directly in-place.
-
template <typename... Args, typename = std::expected(unexpect_t, Args && ... args) explicit constexpr noexcept(…)
enable_if_t<std:: is_constructible_v<E, Args...>>> - Construct an unexpected value directly in-place.
Public functions
-
template <typename... Args, std::auto emplace(Args && ... args) → decltype(auto) noexcept(…)
enable_if_t<std:: is_constructible_v<T, Args...>>* = nullptr> - auto error() & → error_type& constexpr noexcept
- Get the unexpected value, if one is contained in *this.
-
template <typename U = value_type, typename = std::auto expected(U&& val) → SCN_IMPLICIT constexpr noexcept(…)
enable_if_t<std:: is_convertible_v<U, value_type>>> -
template <typename U = T, std::auto operator*() & → U& constexpr noexcept
enable_if_t<!std:: is_void_v<U>>* = nullptr> - Get the expected value, if one is contained in *this.
-
template <typename U = T, std::auto value() & → U& constexpr noexcept
enable_if_t<!std:: is_void_v<U>>* = nullptr> - Get the expected value, if one is contained in *this.
-
template <typename U, typename = std::auto value_or(U&& default_value) const & → T constexpr noexcept(…)
enable_if_t<std:: is_copy_constructible_v<T>&& std:: is_convertible_v<U, T>>>
Function documentation
template <typename T, typename E>
template <typename... Args, std:: enable_if_t<std:: is_constructible_v<T, Args...>>* = nullptr>
decltype(auto) scn::v3::expected::emplace(Args && ... args) noexcept(…)
template <typename... Args, std::
Destroys the contained value, and then initializes the expected value directly in-place.
template <typename T, typename E>
template <typename U = value_type, typename = std:: enable_if_t<std:: is_convertible_v<U, value_type>>>
SCN_IMPLICIT scn::v3::expected::expected(U&& val) constexpr noexcept(…)
template <typename U = value_type, typename = std::
Construct an expected value. Intentionally non-explicit, to make constructing an expected value as transparent as possible.
template <typename T, typename E>
template <typename U, typename = std:: enable_if_t<std:: is_copy_constructible_v<T>&& std:: is_convertible_v<U, T>>>
T scn::v3::expected::value_or(U&& default_value) const & constexpr noexcept(…)
template <typename U, typename = std::
Returns the expected value if *this contains one, otherwise returns default_value