expected
expected.hFrom:
20.35.13Similar to:
std::expectedA generic result type for returning either a result or an error.
Replacement for etl::result.
template <typename TValue, typename TError>
class expectedSpecialisation for void result.
template <typename TError>
class expected<void, TError>unexpected
template
unexpect_t
A tag type for in-place construction of an unexpected value in an etl::expected object.
struct unexpect_t;
A constant of type etl::unexpect_t which is directly passed to a constructor of etl::expected to construct an unexpected value.
inline constexpr unexpect_t unexpect;From: C++17.
static const unexpect_t unexpect;Before: C++17.
unexpected
template <typename TError>
class unexpected<TError>Types
error_type = TError
Member functions
ETL_CONSTEXPR
unexpected(const unexpected& other)Description
Copy constructor
ETL_CONSTEXPR
unexpected(unexpected&& other)Description
Move constructor.
Since: C++11
template <typename TError>
constexpr explicit unexpected(TError&& e)Description
Construct from an argument.
Since: C++11
template <typename TError>
explicit unexpected(const TError& e)Description
Construct from argument.
Before: C++11
template <typename... TArgs>
constexpr explicit unexpected(etl::in_place_t, TArgs&&... args)Description
Construct from arguments.
Since: C++11
template <typename U, typename... TArgs>
constexpr explicit unexpected(etl::in_place_t, std::initializer_list<U> init, TArgs&&... args)Description
Construct from initializer_list and arguments.
Since: C++11
ETL_CONSTEXPR14
etl::unexpected<TError>& operator =(const etl::unexpected<TError>& rhs)Description
Assign from etl::unexpected
ETL_CONSTEXPR14
etl::unexpected<TError>& operator =(etl::unexpected<TError>&& rhs)Description
Move assign from etl::unexpected
Since: C++11
TError& error() & noexceptDescription
Get the error.
Since: C++11
constexpr const TError& error() const& noexceptDescription
Get the error.
Since: C++11
TError&& error() && noexceptDescription
Get the error.
Since: C++11
constexpr TError&& error() const&& noexceptDescription
Get the error.
Since: C++11
const TError& error() constDescription
Get the error.
Before: C++11
void swap(etl::unexpected<TError>& other)Description
Swap with another etl::unexpected
expected
template <typename TValue, typename TError>
class expected
```cpp
Specialisation for void value type.
```cpp
template <typename TError>
class expected<void, TError>
```cpp
### Types
```cpp
this_type etl::expected<TValue, TError>
value_type TValue
error_type TError
unexpected_type etl::unexpected<TError>Member functions
ETL_CONSTEXPR14 expected() ETL_NOEXCEPTDescription
Default constructor
ETL_CONSTEXPR14 expected(const value_type& value) ETL_NOEXCEPTDescription
Constructor
ETL_CONSTEXPR14 expected(value_type&& value) ETL_NOEXCEPTDescription
Constructor
Since: C++11
ETL_CONSTEXPR14 expected(const expected& other) ETL_NOEXCEPTDescription
Copy constructor
ETL_CONSTEXPR14 expected(expected&& other) ETL_NOEXCEPTDescription
Move constructor
Since: C++11
template <typename F>
ETL_CONSTEXPR14 explicit expected(const etl::unexpected<F>& ue)Description
Copy construct from unexpected type.
template <typename F>
ETL_CONSTEXPR14 explicit expected(etl::unexpected<F>&& ue)Description
Move construct from unexpected type.
Since: C++11
ETL_CONSTEXPR14 explicit expected(etl::in_place_t) ETL_NOEXCEPTDescription
Construct with default value type.
template <typename... TArgs>
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, TArgs&&... args)Description
Construct value type from arguments.
Since: C++11
template <typename U, typename... TArgs>
ETL_CONSTEXPR14 explicit expected(etl::in_place_t, std::initializer_list<U> il, TArgs&&... args)Description
Construct value type from initializer_list and arguments.
template <typename... TArgs>
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, TArgs&&... args)Description
Construct error type from arguments.
Since: C++11
template <typename U, typename... TArgs>
ETL_CONSTEXPR14 explicit expected(etl::unexpect_t, std::initializer_list<U> il, TArgs&&... args)Description
Construct error type from initializer_list and arguments.
Since: C++11
this_type& operator =(const this_type& other)Description
Copy assign
this_type& operator =(this_type&& other)Description
Move assign
Since: C++11
expected& operator =(const value_type& value)Description
Copy assign from value
expected& operator =(value_type&& value)Description
Move assign from value
Since: C++11
expected& operator =(const unexpected_type& error)Description
Copy assign from error
expected& operator =(unexpected_type&& error)Description
Move assign from error
Since: C++11
ETL_CONSTEXPR14 value_type& value()&Description
Get the value.
Undefined if has_value() returns false.
Not valid for void specialisation.
Since: C++11
ETL_CONSTEXPR14 const value_type& value() const&Description
Get the value.
Undefined if has_value() returns false.
Not valid for void specialisation.
Since: C++11
ETL_CONSTEXPR14 value_type&& value()&&Description
Get the value.
Undefined if has_value() returns false.
Not valid for void specialisation.
Since: C++11
ETL_CONSTEXPR14 const value_type&& value() const&&Description
Get the value.
Undefined if has_value() returns false.
Not valid for void specialisation.
Since: C++11
value_type& value() constDescription
Get the value.
Undefined if has_value() returns false.
Not valid for void specialisation.
ETL_NODISCARD
ETL_CONSTEXPR14
bool has_value() constDescription
Returns true if the class contains a value.
ETL_NODISCARD
ETL_CONSTEXPR14
operator bool() constDescription
Returns true if the class contains a value.
template <typename U>
ETL_NODISCARD
ETL_CONSTEXPR14
value_type value_or(U&& default_value) const&Description
Returns the value or default_value if has_value() returns false.
Since: C++11
template <typename U>
ETL_NODISCARD
ETL_CONSTEXPR14
value_type value_or(U&& default_value)&&Description
Returns the value or default_value if has_value() returns false.
Since: C++11
template <typename U>
value_type value_or(const U& default_value) constDescription
Returns the value or default_value if has_value() returns false.
Before: C++11
ETL_NODISCARD
ETL_CONSTEXPR14
error_type& error()& ETL_NOEXCEPTDescription
Returns the error.
Undefined if has_value() returns true.
Since: C++11
ETL_NODISCARD
ETL_CONSTEXPR14
const error_type& error() const& ETL_NOEXCEPTDescription
Returns the error.
Undefined if has_value() returns true.
Since: C++11
ETL_NODISCARD
ETL_CONSTEXPR14
error_type&& error() && ETL_NOEXCEPTDescription
Returns the error.
Undefined if has_value() returns true.
Since: C++11
ETL_NODISCARD
ETL_CONSTEXPR14
const error_type&& error() const&& ETL_NOEXCEPTDescription
Returns the error.
Undefined if has_value() returns true.
Since: C++11
error_type& error() constDescription
Returns the error.
Undefined if has_value() returns true.
Before: C++11
template <typename... TArgs>
ETL_CONSTEXPR14 value_type& emplace(TArgs&&... args) ETL_NOEXCEPTDescription
Returns the error if has_value() returns false.
Undefined if has_value() returns true.
Since: C++11
template <typename U, typename... TArgs>
ETL_CONSTEXPR14 value_type& emplace(std::initializer_list<U>& il, TArgs&&... args) ETL_NOEXCEPTDescription
Create from arguments.
Since: C++11
value_type* operator ->()Description
Class member access operator.
const value_type* operator ->() constDescription
Const class member access operator.
value_type& operator *()Description
Dereference operator.
const value_type& operator *() constDescription
Dereference operator.