template <typename T, typename E>
expected class
A C++23-like expected
.
Constructors, destructors, conversion operators
-
template <typename U = value_type, typename = std::expected(U&& val) constexpr
enable_if_t<std:: is_convertible<U, value_type>::value>> -
template <typename... Args, typename = std::expected(std::
enable_if_t<std:: is_constructible<T, Args...>::value>> in_place_t, Args && ... args) explicit constexpr - Construct an expected value directly in-place.
-
template <typename... Args, typename = std::expected(unexpect_t, Args && ... args) explicit constexpr
enable_if_t<std:: is_constructible<E, Args...>::value>> - Construct an unexpected value directly in-place.
Public functions
-
template <typename... Args, typename std::auto emplace(Args && ... args) → decltype(auto)
enable_if_t<std:: is_constructible<T, Args...>::value>* = nullptr> - auto error() & → error_type& constexpr
- Get the unexpected value, if one is contained in *this.
-
template <typename U = T, std::auto operator*() & → U& constexpr
enable_if_t<!std:: is_void<U>::value>* = nullptr> - Get the expected value, if one is contained in *this.
-
template <typename U = T, std::auto value() & → U& constexpr
enable_if_t<!std:: is_void<U>::value>* = 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
enable_if_t<std:: is_copy_constructible<T>::value&& std:: is_convertible<U, T>::value>>
Function documentation
template <typename T, typename E>
template <typename U = value_type, typename = std:: enable_if_t<std:: is_convertible<U, value_type>::value>>
scn::expected::expected(U&& val) constexpr
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... Args, typename std:: enable_if_t<std:: is_constructible<T, Args...>::value>* = nullptr>
decltype(auto) scn::expected::emplace(Args && ... args)
template <typename... Args, typename std::
Destroys the contained value, and then initializes the expected value directly in-place.
template <typename T, typename E>
template <typename U, typename = std:: enable_if_t<std:: is_copy_constructible<T>::value&& std:: is_convertible<U, T>::value>>
T scn::expected::value_or(U&& default_value) const & constexpr
template <typename U, typename = std::
Returns the expected value if *this contains one, otherwise returns default_value