31#ifndef ETL_EXPECTED_INCLUDED
32#define ETL_EXPECTED_INCLUDED
75 template <
typename TError>
86 : error_value(
other.error_value)
95 : error_value(
etl::move(
other.error_value))
120 template <
typename...
Args >
127#if ETL_HAS_INITIALIZER_LIST
131 template <
typename U,
typename...
Args>
148 error_value =
rhs.error_value;
161 error_value = etl::move(
rhs.error_value);
188 return etl::move(error_value);
196 return etl::move(error_value);
213 using ETL_OR_STD::swap;
236 static const unexpect_t unexpect;
242 template <
typename TValue,
typename TError>
248 typedef TValue value_type;
249 typedef TError error_type;
253 template <
typename U>
287 : storage(
other.storage)
296 : storage(etl::move(
other.storage))
307 : storage(
etl::in_place_index_t<Error_Type>(),
ue.error())
313 : storage(
etl::in_place_index_t<Error_Type>(),
ue.error())
317 template <
typename G>
319 : storage(
etl::in_place_index_t<Error_Type>(),
ue.error())
330 : storage(
etl::in_place_index_t<Error_Type>(),
etl::move(
ue.error()))
336 : storage(
etl::in_place_index_t<Error_Type>(),
etl::move(
ue.error()))
345 : storage(value_type())
353 template <
typename...
Args>
359#if ETL_HAS_INITIALIZER_LIST
363 template <
typename U,
typename...
Args>
373 template <
typename...
Args>
379#if ETL_HAS_INITIALIZER_LIST
383 template <
typename U,
typename...
Args>
398 storage =
other.storage;
411 storage = etl::move(
other.storage);
475 ETL_CONSTEXPR14 value_type&
value()&
483 ETL_CONSTEXPR14
const value_type&
value()
const&
491 ETL_CONSTEXPR14 value_type&&
value()&&
499 ETL_CONSTEXPR14
const value_type&&
value()
const&&
518 bool has_value()
const ETL_NOEXCEPT
520 return (storage.
index() == Value_Type);
538 template <
typename U>
557 template <
typename U>
565 return etl::move(
value());
578 error_type& error()& ETL_NOEXCEPT
588 const error_type& error()
const& ETL_NOEXCEPT
598 error_type&& error()&& ETL_NOEXCEPT
608 const error_type&& error()
const&& ETL_NOEXCEPT
619 using ETL_OR_STD::swap;
627 template <
typename...
Args>
628 ETL_CONSTEXPR14 value_type& emplace(
Args&&...
args) ETL_NOEXCEPT
638#if ETL_HAS_INITIALIZER_LIST
639 template <
typename U,
typename...
Args>
640 ETL_CONSTEXPR14 value_type& emplace(std::initializer_list<U>
il,
Args&&...
args) ETL_NOEXCEPT
651 template <
typename U>
667 const error_type& error()
const
676 value_type* operator ->()
678#if ETL_IS_DEBUG_BUILD
679 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
688 const value_type* operator ->()
const
690#if ETL_IS_DEBUG_BUILD
691 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
700 value_type& operator *() ETL_LVALUE_REF_QUALIFIER
702#if ETL_IS_DEBUG_BUILD
703 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
712 const value_type& operator *()
const ETL_LVALUE_REF_QUALIFIER
714#if ETL_IS_DEBUG_BUILD
715 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
725 value_type&& operator *()&&
727#if ETL_IS_DEBUG_BUILD
728 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
737 const value_type&& operator *()
const&&
739#if ETL_IS_DEBUG_BUILD
740 ETL_ASSERT(has_value(), ETL_ERROR(expected_invalid));
757 storage_type storage;
763 template<
typename TError>
769 typedef void value_type;
770 typedef TError error_type;
786 : storage(
ue_.error())
796 : storage(
etl::move(
ue_.error()))
806 : storage(
other.storage)
828 storage =
other.storage;
840 storage = etl::move(
other.storage);
878 return (storage.
index() != Error_Type);
899 error_type& error()& ETL_NOEXCEPT
910 const error_type& error()
const& ETL_NOEXCEPT
921 error_type&& error() && ETL_NOEXCEPT
932 const error_type&& error()
const&& ETL_NOEXCEPT
952 using ETL_OR_STD::swap;
972template <
typename TValue,
typename TError,
typename TValue2,
typename TError2>
976 if (lhs.has_value() != rhs.has_value())
984 return lhs.error() == rhs.error();
988template <
typename TValue,
typename TError,
typename TValue2>
992 if (!lhs.has_value())
996 return lhs.
value() == rhs;
1000template <
typename TValue,
typename TError,
typename TError2>
1004 if (lhs.has_value())
1008 return lhs.error() == rhs.
error();
1012template <
typename TError,
typename TError2>
1016 if (lhs.has_value() != rhs.has_value())
1020 if (lhs.has_value())
1024 return lhs.error() == rhs.error();
1028template <
typename TError,
typename TError2>
1032 if (lhs.has_value())
1036 return lhs.error() == rhs.
error();
1040template <
typename TError,
typename TError2>
1048template <
typename TValue,
typename TError,
typename TValue2,
typename TError2>
1052 return !(lhs == rhs);
1056template <
typename TValue,
typename TError,
typename TValue2>
1060 return !(lhs == rhs);
1064template <
typename TValue,
typename TError,
typename TError2>
1068 return !(lhs == rhs);
1072template <
typename TError,
typename TError2>
1076 return !(lhs == rhs);
1080template <
typename TError,
typename TError2>
1084 return !(lhs == rhs);
1088template <
typename TError,
typename TError2>
1092 return !(lhs == rhs);
1098template <
typename TValue,
typename TError>
1108template <
typename TError>
Specialisation for void value type.
Definition expected.h:765
ETL_CONSTEXPR14 expected()
Default constructor.
Definition expected.h:777
ETL_NODISCARD ETL_CONSTEXPR14 bool has_value() const ETL_NOEXCEPT
Returns true if expected has a value.
Definition expected.h:876
ETL_CONSTEXPR14 expected(const unexpected_type &ue_)
Copy construct from unexpected.
Definition expected.h:785
void swap(this_type &other)
Swap with another etl::expected.
Definition expected.h:950
ETL_CONSTEXPR14 expected(const this_type &other)
Copy construct.
Definition expected.h:805
const error_type & error() const
Definition expected.h:941
Base exception for et::expected.
Definition expected.h:49
expected_invalid
Definition expected.h:62
Expected type.
Definition expected.h:244
ETL_CONSTEXPR14 expected() ETL_NOEXCEPT
Default constructor.
Definition expected.h:260
ETL_CONSTEXPR14 expected(const value_type &value_) ETL_NOEXCEPT
Constructor.
Definition expected.h:268
this_type & operator=(const this_type &other)
Copy assign from etl::expected.
Definition expected.h:394
ETL_CONSTEXPR14 expected(etl::in_place_t) ETL_NOEXCEPT
Construct with default value type.
Definition expected.h:344
ETL_CONSTEXPR14 expected(const expected &other) ETL_NOEXCEPT
Copy constructor.
Definition expected.h:286
const value_type & value() const
Get the value.
Definition expected.h:507
const TError & error() const
Get the error.
Definition expected.h:202
void swap(etl::unexpected< TError > &other)
Swap with another etl::unexpected.
Definition expected.h:211
ETL_CONSTEXPR unexpected(const unexpected &other)
Copy constructor.
Definition expected.h:85
ETL_CONSTEXPR unexpected(const TError &e)
Construct from an lvalue.
Definition expected.h:103
ETL_CONSTEXPR14 etl::unexpected< TError > & operator=(const etl::unexpected< TError > &rhs)
Assign from etl::unexpected.
Definition expected.h:142
ETL_CONSTEXPR14 bool operator==(const etl::expected< TValue, TError > &lhs, const etl::expected< TValue2, TError2 > &rhs)
Equivalence operators.
Definition expected.h:974
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
size_t index() const
Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID.
Definition variant_legacy.h:734
Definition variant_legacy.h:146
bitset_ext
Definition absolute.h:38
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition array.h:1085
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:314
in_place disambiguation tags.
Definition utility.h:617
Definition type_traits_generator.h:2161
Definition type_traits_generator.h:2168
unexpect_t
Definition expected.h:227