31#ifndef ETL_OPTIONAL_INCLUDED
32#define ETL_OPTIONAL_INCLUDED
70 void operator&()
const ETL_DELETE;
87 optional_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
88 :
exception(reason_, file_name_, line_number_)
97 class optional_invalid :
public optional_exception
101 optional_invalid(string_type file_name_, numeric_type line_number_)
102 : optional_exception(
"optional:invalid", file_name_, line_number_)
110 namespace private_optional
112 template <typename T, bool UseFundamentalPath = etl::is_fundamental<T>::value && !etl::is_const<T>::value>
118 template <
typename T>
123 typedef T value_type;
151 if (other.has_value())
153 storage.construct(other.value());
165 if (other.has_value())
167 storage.construct(etl::move(other.value()));
176 template <
typename U,
177 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type,
etl::in_place_t>::value
178 && !etl::is_same<typename etl::decay<U>::type, optional_impl>::value,
180 ETL_CONSTEXPR20_STL optional_impl(U&& value_)
182 storage.construct(etl::forward<U>(value_));
188 template <
typename... TArgs>
189 ETL_CONSTEXPR20_STL optional_impl(etl::in_place_t, TArgs&&... args)
191 storage.construct(etl::forward<TArgs>(args)...);
194 #if ETL_HAS_INITIALIZER_LIST
198 template <
typename U,
typename... TArgs >
199 ETL_CONSTEXPR20_STL optional_impl(etl::in_place_t, std::initializer_list<U> ilist, TArgs&&... args)
201 storage.construct(ilist, etl::forward<TArgs>(args)...);
237 if (other.has_value())
239 storage.construct(other.value());
259 if (other.has_value())
261 storage.construct(etl::move(other.value()));
277 template <
typename U,
278 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type, optional_impl>::value,
280 ETL_CONSTEXPR20_STL optional_impl& operator=(U&& value_)
282 storage.construct(etl::forward<U>(value_));
290 storage.construct(value_);
304#if ETL_IS_DEBUG_BUILD
308 return &storage.u.value;
317#if ETL_IS_DEBUG_BUILD
321 return &storage.u.value;
330#if ETL_IS_DEBUG_BUILD
334 return storage.u.value;
343#if ETL_IS_DEBUG_BUILD
347 return storage.u.value;
357 #if ETL_IS_DEBUG_BUILD
361 return etl::move(storage.u.value);
370 #if ETL_IS_DEBUG_BUILD
374 return etl::move(storage.u.value);
382 bool has_value() const ETL_NOEXCEPT
384 return storage.valid;
390 ETL_CONSTEXPR20_STL ETL_EXPLICIT
operator bool()
const
401#if ETL_IS_DEBUG_BUILD
405 return storage.u.value;
412 const T&
value() const ETL_LVALUE_REF_QUALIFIER
414#if ETL_IS_DEBUG_BUILD
418 return storage.u.value;
425 T
value_or(
const T& default_value)
const ETL_LVALUE_REF_QUALIFIER
427 return has_value() ?
value() : default_value;
437 #if ETL_IS_DEBUG_BUILD
441 return etl::move(storage.u.value);
448 const T&& value() const&&
450 #if ETL_IS_DEBUG_BUILD
454 return etl::move(storage.u.value);
460 template <
typename U>
461 ETL_CONSTEXPR20_STL etl::enable_if_t<etl::is_convertible<U, T>::value, T> value_or(U&& default_value)
const&
463 return has_value() ? value() : static_cast<T>(
etl::forward<U>(default_value));
469 template <
typename U>
470 ETL_CONSTEXPR20_STL etl::enable_if_t<etl::is_convertible<U, T>::value, T> value_or(U&& default_value) &&
472 return has_value() ? etl::move(value()) : static_cast<T>(etl::forward<U>(default_value));
502#if ETL_IS_DEBUG_BUILD
506 storage.construct(other.value());
508 return storage.u.value;
511#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_OPTIONAL_FORCE_CPP03_IMPLEMENTATION)
518 template <
typename U,
typename... URest,
519 typename etl::enable_if<
520 !etl::is_base_of< optional_impl, typename etl::remove_cv< typename etl::remove_reference<U>::type>
::type>::value,
int>
::type = 0>
521 ETL_CONSTEXPR20_STL T& emplace(U&& first, URest&&... rest)
523 storage.construct(etl::forward<U>(first), etl::forward<URest>(rest)...);
525 return storage.u.value;
536 return storage.u.value;
551 T* p = ::new (&storage.u.value) T();
552 storage.valid =
true;
561 template <
typename T1>
562 typename etl::enable_if<
563 !etl::is_base_of< this_type, typename etl::remove_cv< typename etl::remove_reference<T1>::type>
::type>::value
574 T* p = ::new (&storage.u.value) T(value1);
575 storage.valid =
true;
584 template <
typename T1,
typename T2>
585 T&
emplace(
const T1& value1,
const T2& value2)
593 T* p = ::new (&storage.u.value) T(value1, value2);
594 storage.valid =
true;
603 template <
typename T1,
typename T2,
typename T3>
604 T&
emplace(
const T1& value1,
const T2& value2,
const T3& value3)
612 T* p = ::new (&storage.u.value) T(value1, value2, value3);
613 storage.valid =
true;
622 template <
typename T1,
typename T2,
typename T3,
typename T4>
623 T&
emplace(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
631 T* p = ::new (&storage.u.value) T(value1, value2, value3, value4);
632 storage.valid =
true;
649 typedef typename etl::remove_const<T>::type* pointer_type;
661 void construct(
const T& value_)
672 void construct(T&& value_)
681 template <
typename... TArgs>
682 ETL_CONSTEXPR20_STL
void construct(TArgs&&... args)
686 etl::construct_at(
const_cast<pointer_type
>(&u.value), etl::forward<TArgs>(args)...);
721 storage_type storage;
727 template <
typename T>
732 typedef T value_type;
757 if (other.has_value())
759 storage.construct(other.value());
770 if (other.has_value())
772 storage.construct(etl::move(other.value()));
779 ETL_CONSTEXPR14 optional_impl(
const T& value_)
781 storage.construct(value_);
787 ETL_CONSTEXPR14 optional_impl(T&& value_)
789 storage.construct(etl::move(value_));
795 template <
typename... TArgs>
796 ETL_CONSTEXPR14 optional_impl(etl::in_place_t, TArgs&&... args)
798 storage.construct(etl::forward<TArgs>(args)...);
801 #if ETL_HAS_INITIALIZER_LIST
805 template <
typename U,
typename... TArgs >
806 ETL_CONSTEXPR14 optional_impl(etl::in_place_t, std::initializer_list<U> ilist, TArgs&&... args)
808 storage.construct(ilist, etl::forward<TArgs>(args)...);
833 if (other.has_value())
835 storage.construct(other.value());
854 if (other.has_value())
856 storage.construct(etl::move(other.value()));
873 storage.construct(value_);
884 storage.construct(etl::move(value_));
897#if ETL_IS_DEBUG_BUILD
901 return &storage.value;
909#if ETL_IS_DEBUG_BUILD
913 return &storage.value;
921#if ETL_IS_DEBUG_BUILD
925 return storage.value;
931 ETL_CONSTEXPR14
const T&
operator*() const ETL_LVALUE_REF_QUALIFIER
933#if ETL_IS_DEBUG_BUILD
937 return storage.value;
946 #if ETL_IS_DEBUG_BUILD
950 return etl::move(storage.value);
956 ETL_CONSTEXPR14
const T&&
operator*() const&&
958 #if ETL_IS_DEBUG_BUILD
962 return etl::move(storage.value);
969 ETL_CONSTEXPR14
bool has_value() const ETL_NOEXCEPT
971 return storage.valid;
977 ETL_CONSTEXPR14 ETL_EXPLICIT
operator bool()
const
985 ETL_CONSTEXPR14 T&
value() ETL_LVALUE_REF_QUALIFIER
987#if ETL_IS_DEBUG_BUILD
991 return storage.value;
997 ETL_CONSTEXPR14
const T&
value() const ETL_LVALUE_REF_QUALIFIER
999#if ETL_IS_DEBUG_BUILD
1003 return storage.value;
1009 ETL_CONSTEXPR14 T
value_or(
const T& default_value)
const ETL_LVALUE_REF_QUALIFIER
1011 return has_value() ?
value() : default_value;
1018 ETL_CONSTEXPR14 T&& value() &&
1020 #if ETL_IS_DEBUG_BUILD
1024 return etl::move(storage.value);
1030 ETL_CONSTEXPR14
const T&& value() const&&
1032 #if ETL_IS_DEBUG_BUILD
1036 return etl::move(storage.value);
1042 template <
typename U>
1043 ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<U, T>::value, T> value_or(U&& default_value)
const&
1045 return has_value() ? value() : static_cast<T>(
etl::forward<U>(default_value));
1051 template <
typename U>
1052 ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<U, T>::value, T> value_or(U&& default_value) &&
1054 return has_value() ? etl::move(value()) : static_cast<T>(etl::forward<U>(default_value));
1082#if ETL_IS_DEBUG_BUILD
1086 storage.construct(other.value());
1088 return storage.u.value;
1091#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_OPTIONAL_FORCE_CPP03_IMPLEMENTATION)
1096 template <
typename... TArgs>
1097 ETL_CONSTEXPR14 T& emplace(TArgs&&... args)
1099 storage.construct(etl::forward<TArgs>(args)...);
1101 return storage.value;
1116 T* p = ::new (&storage.value) T();
1117 storage.valid =
true;
1126 template <
typename T1>
1127 typename etl::enable_if<
1128 !etl::is_base_of< this_type, typename etl::remove_cv< typename etl::remove_reference<T1>::type>
::type>::value
1139 T* p = ::new (&storage.value) T(value1);
1140 storage.valid =
true;
1149 template <
typename T1,
typename T2>
1158 T* p = ::new (&storage.value) T(value1, value2);
1159 storage.valid =
true;
1168 template <
typename T1,
typename T2,
typename T3>
1169 T&
emplace(
const T1& value1,
const T2& value2,
const T3& value3)
1177 T* p = ::new (&storage.value) T(value1, value2, value3);
1178 storage.valid =
true;
1187 template <
typename T1,
typename T2,
typename T3,
typename T4>
1188 T&
emplace(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
1196 T* p = ::new (&storage.value) T(value1, value2, value3, value4);
1197 storage.valid =
true;
1211 ETL_CONSTEXPR14 storage_type()
1218 ETL_CONSTEXPR14
void construct(
const T& value_)
1226 ETL_CONSTEXPR14
void construct(T&& value_)
1233 template <
typename... TArgs>
1234 ETL_CONSTEXPR14
void construct(TArgs&&... args)
1236 value = T(etl::forward<TArgs>(args)...);
1242 ETL_CONSTEXPR14
void destroy()
1251 storage_type storage;
1255#define ETL_OPTIONAL_ENABLE_CPP14 typename etl::enable_if< etl::is_pod<typename etl::remove_cv<U>::type>::value, int>::type = 0
1256#define ETL_OPTIONAL_ENABLE_CPP20_STL typename etl::enable_if< !etl::is_pod<typename etl::remove_cv<U>::type>::value, int>::type = 0
1258#define ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14 \
1259 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_pod<typename etl::remove_cv<T>::type>::value, bool>::type
1260#define ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL \
1261 ETL_CONSTEXPR20_STL \
1262 typename etl::enable_if< !etl::is_pod<typename etl::remove_cv<T>::type>::value, bool>::type
1271 template <
typename T>
1280 typedef T value_type;
1281 typedef T* iterator;
1282 typedef const T* const_iterator;
1288 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1289 ETL_CONSTEXPR14 optional()
1297 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1298 ETL_CONSTEXPR20_STL optional()
1313 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1322 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1342 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1351 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1352 ETL_CONSTEXPR20_STL optional(
const optional& other)
1371 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1380 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1381 ETL_CONSTEXPR20_STL optional(optional&& other)
1393 template <
typename U,
1394 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type, etl::optional<T>>::value
1395 && !etl::is_same<typename etl::decay<U>::type, etl::in_place_t>::value
1396 && !etl::is_same<typename etl::decay<U>::type, etl::nullopt_t>::value
1397 && etl::is_pod<typename etl::remove_cv<T>::type>::value,
1399 ETL_CONSTEXPR14 optional(U&& value_)
1400 : impl_t(etl::forward<U>(value_))
1407 template <
typename U,
1408 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type, etl::optional<T>>::value
1409 && !etl::is_same<typename etl::decay<U>::type, etl::in_place_t>::value
1410 && !etl::is_same<typename etl::decay<U>::type, etl::nullopt_t>::value
1411 && !etl::is_pod<typename etl::remove_cv<T>::type>::value,
1413 ETL_CONSTEXPR20_STL optional(U&& value_)
1414 : impl_t(etl::forward<U>(value_))
1431 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14,
typename... Args>
1440 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL,
typename... Args>
1441 ETL_CONSTEXPR20_STL
explicit optional(
etl::in_place_t, Args&&... args)
1442 : impl_t(
etl::in_place_t{},
etl::forward<Args>(args)...)
1446 #if ETL_HAS_INITIALIZER_LIST
1450 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14,
typename... TArgs>
1451 ETL_CONSTEXPR14
explicit optional(etl::in_place_t, std::initializer_list<U> ilist, TArgs&&... args)
1452 : impl_t(etl::in_place_t{}, ilist, etl::forward<TArgs>(args)...)
1459 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL,
typename... TArgs>
1460 ETL_CONSTEXPR20_STL
explicit optional(etl::in_place_t, std::initializer_list<U> ilist, TArgs&&... args)
1461 : impl_t(etl::in_place_t{}, ilist, etl::forward<TArgs>(args)...)
1471 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1472 ETL_CONSTEXPR14 optional&
operator=(etl::nullopt_t)
1482 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1483 ETL_CONSTEXPR20_STL optional&
operator=(etl::nullopt_t)
1505 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1508 impl_t::operator=(other);
1516 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1517 ETL_CONSTEXPR20_STL optional&
operator=(
const optional& other)
1519 impl_t::operator=(other);
1529 impl_t::operator=(other);
1539 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP14>
1542 impl_t::operator=(etl::move(other));
1550 template <
typename U = T, ETL_OPTIONAL_ENABLE_CPP20_STL>
1551 ETL_CONSTEXPR20_STL optional&
operator=(optional&& other)
1553 impl_t::operator=(etl::move(other));
1563 template <
typename U,
1564 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type, etl::optional<T>>::value
1565 && !etl::is_same<typename etl::decay<U>::type, etl::nullopt_t>::value
1566 && etl::is_pod<typename etl::remove_cv<T>::type>::value,
1568 ETL_CONSTEXPR14 optional&
operator=(U&& value_)
1570 impl_t::operator=(etl::forward<U>(value_));
1578 template <
typename U,
1579 typename etl::enable_if< etl::is_constructible<T, U&&>::value && !etl::is_same<typename etl::decay<U>::type, etl::optional<T>>::value
1580 && !etl::is_same<typename etl::decay<U>::type, etl::nullopt_t>::value
1581 && !etl::is_pod<typename etl::remove_cv<T>::type>::value,
1583 ETL_CONSTEXPR20_STL optional&
operator=(U&& value_)
1585 impl_t::operator=(etl::forward<U>(value_));
1595 impl_t::operator=(value_);
1607 return this->has_value() ? this->operator->() : ETL_NULLPTR;
1614 const_iterator
begin() const ETL_NOEXCEPT
1616 return this->has_value() ? this->operator->() : ETL_NULLPTR;
1625 return this->has_value() ? this->operator->() + 1 : ETL_NULLPTR;
1632 const_iterator
end() const ETL_NOEXCEPT
1634 return this->has_value() ? this->operator->() + 1 : ETL_NULLPTR;
1643 template <
typename T>
1646 if (lhs.has_value() != rhs.has_value())
1650 else if (!lhs.has_value() && !rhs.has_value())
1656 return lhs.value() == rhs.value();
1663 template <
typename T>
1666 if (lhs.has_value() != rhs.has_value())
1670 else if (!lhs.has_value() && !rhs.has_value())
1676 return lhs.value() == rhs.value();
1683 template <
typename T>
1686 return !(lhs == rhs);
1692 template <
typename T>
1695 return !(lhs == rhs);
1701 template <
typename T>
1704 if (!rhs.has_value())
1708 else if (!lhs.has_value())
1714 return lhs.value() < rhs.value();
1721 template <
typename T>
1724 if (!rhs.has_value())
1728 else if (!lhs.has_value())
1734 return lhs.value() < rhs.value();
1741 template <
typename T>
1744 return !(rhs < lhs);
1750 template <
typename T>
1753 return !(rhs < lhs);
1759 template <
typename T>
1768 template <
typename T>
1777 template <
typename T>
1780 return !(lhs < rhs);
1786 template <
typename T>
1789 return !(lhs < rhs);
1795 template <
typename T>
1798 return !lhs.has_value();
1804 template <
typename T>
1807 return !lhs.has_value();
1813 template <
typename T>
1816 return !rhs.has_value();
1822 template <
typename T>
1825 return !rhs.has_value();
1831 template <
typename T>
1840 template <
typename T>
1849 template <
typename T>
1858 template <
typename T>
1867 template <
typename T>
1876 template <
typename T>
1885 template <
typename T>
1888 return rhs.has_value();
1894 template <
typename T>
1897 return rhs.has_value();
1903 template <
typename T>
1906 return !lhs.has_value();
1912 template <
typename T>
1915 return !lhs.has_value();
1921 template <
typename T>
1930 template <
typename T>
1939 template <
typename T>
1942 return lhs.has_value();
1948 template <
typename T>
1951 return lhs.has_value();
1957 template <
typename T>
1966 template <
typename T>
1975 template <
typename T>
1984 template <
typename T>
1993 template <
typename T>
1996 return !rhs.has_value();
2002 template <
typename T>
2005 return !rhs.has_value();
2011 template <
typename T,
typename U>
2014 return lhs.has_value() ? lhs.value() == rhs :
false;
2020 template <
typename T,
typename U>
2023 return lhs.has_value() ? lhs.value() == rhs :
false;
2029 template <
typename T,
typename U>
2032 return !(lhs == rhs);
2038 template <
typename T,
typename U>
2041 return !(lhs == rhs);
2047 template <
typename T,
typename U>
2050 return rhs.has_value() ? rhs.value() == lhs :
false;
2056 template <
typename T,
typename U>
2059 return rhs.has_value() ? rhs.value() == lhs :
false;
2065 template <
typename T,
typename U>
2068 return !(lhs == rhs);
2074 template <
typename T,
typename U>
2077 return !(lhs == rhs);
2083 template <
typename T,
typename U>
2086 return lhs.has_value() ? lhs.value() < rhs :
true;
2092 template <
typename T,
typename U>
2095 return lhs.has_value() ? lhs.value() < rhs :
true;
2101 template <
typename T,
typename U>
2104 return rhs.has_value() ? lhs < rhs.value() :
false;
2110 template <
typename T,
typename U>
2113 return rhs.has_value() ? lhs < rhs.value() :
false;
2119 template <
typename T,
typename U>
2122 return lhs.has_value() ? lhs.value() <= rhs :
true;
2128 template <
typename T,
typename U>
2131 return lhs.has_value() ? lhs.value() <= rhs :
true;
2137 template <
typename T,
typename U>
2140 return rhs.has_value() ? lhs <= rhs.value() :
false;
2146 template <
typename T,
typename U>
2149 return rhs.has_value() ? lhs <= rhs.value() :
false;
2155 template <
typename T,
typename U>
2158 return lhs.has_value() ? lhs.value() > rhs :
false;
2164 template <
typename T,
typename U>
2167 return lhs.has_value() ? lhs.value() > rhs :
false;
2173 template <
typename T,
typename U>
2176 return rhs.has_value() ? lhs > rhs.value() :
true;
2182 template <
typename T,
typename U>
2185 return rhs.has_value() ? lhs > rhs.value() :
true;
2191 template <
typename T,
typename U>
2194 return lhs.has_value() ? lhs.value() >= rhs :
false;
2200 template <
typename T,
typename U>
2203 return lhs.has_value() ? lhs.value() >= rhs :
false;
2209 template <
typename T,
typename U>
2212 return rhs.has_value() ? lhs >= rhs.value() :
true;
2218 template <
typename T,
typename U>
2221 return rhs.has_value() ? lhs >= rhs.value() :
true;
2229 template <
typename T>
2238#if ETL_CPP17_SUPPORTED
2239 template <
typename T>
2240 optional(T) -> optional<T>;
2247template <
typename T>
2253#undef ETL_OPTIONAL_ENABLE_CPP14
2254#undef ETL_OPTIONAL_ENABLE_CPP20_STL
2256#undef ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14
2257#undef ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL
Definition optional.h:1273
optional & operator=(const optional &other)
Assignment operator from optional.
Definition optional.h:1527
ETL_CONSTEXPR20_STL const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the optional.
Definition optional.h:1614
ETL_CONSTEXPR20_STL iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the optional.
Definition optional.h:1605
ETL_CONSTEXPR20_STL iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the optional.
Definition optional.h:1623
optional(etl::nullopt_t)
Constructor with nullopt.
Definition optional.h:1331
optional & operator=(const T &value_)
Assignment operator from value type.
Definition optional.h:1593
optional(const T &value_)
Construct from value type.
Definition optional.h:1421
optional(const optional &other)
Copy constructor.
Definition optional.h:1360
ETL_CONSTEXPR20_STL const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the optional.
Definition optional.h:1632
optional & operator=(etl::nullopt_t)
Assignment operator from nullopt.
Definition optional.h:1493
ETL_CONSTEXPR20_STL const T & value() const ETL_LVALUE_REF_QUALIFIER
Get a const reference to the value.
Definition optional.h:412
T & emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Definition optional.h:604
ETL_CONSTEXPR20_STL optional_impl()
Constructor.
Definition optional.h:130
ETL_CONSTEXPR20_STL void swap(optional_impl &other)
Swaps this value with another.
Definition optional.h:480
ETL_CONSTEXPR20_STL optional_impl(etl::nullopt_t)
Constructor with nullopt.
Definition optional.h:139
T & emplace(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition optional.h:623
ETL_CONSTEXPR20_STL optional_impl & operator=(const T &value_)
Assignment operator from value type.
Definition optional.h:288
etl::enable_if<!etl::is_base_of< this_type, typenameetl::remove_cv< typenameetl::remove_reference< T1 >::type >::type >::value &&!etl::is_same< etl::optional< T >, typenameetl::remove_cv< typenameetl::remove_reference< T1 >::type >::type >::value, T & >::type emplace(const T1 &value1)
Definition optional.h:566
ETL_CONSTEXPR20_STL const T * operator->() const
Pointer operator.
Definition optional.h:315
ETL_CONSTEXPR20_STL const T & operator*() const ETL_LVALUE_REF_QUALIFIER
Dereference operator.
Definition optional.h:341
ETL_CONSTEXPR20_STL optional_impl & operator=(etl::nullopt_t)
Assignment operator from nullopt.
Definition optional.h:219
ETL_CONSTEXPR20_STL T value_or(const T &default_value) const ETL_LVALUE_REF_QUALIFIER
Gets the value or a default if not valid.
Definition optional.h:425
ETL_CONSTEXPR20_STL ~optional_impl()
Destructor.
Definition optional.h:210
ETL_CONSTEXPR20_STL T & operator*() ETL_LVALUE_REF_QUALIFIER
Dereference operator.
Definition optional.h:328
ETL_CONSTEXPR20_STL optional_impl(const optional_impl< T > &other)
Copy constructor.
Definition optional.h:149
ETL_CONSTEXPR20_STL optional_impl & operator=(const optional_impl< T > &other)
Assignment operator from optional_impl.
Definition optional.h:233
ETL_CONSTEXPR20_STL void reset()
Reset back to invalid.
Definition optional.h:491
T & emplace(const T1 &value1, const T2 &value2)
Definition optional.h:585
T & emplace()
Definition optional.h:543
ETL_CONSTEXPR20_STL T & value() ETL_LVALUE_REF_QUALIFIER
Get a reference to the value.
Definition optional.h:399
ETL_CONSTEXPR20_STL T * operator->()
Pointer operator.
Definition optional.h:302
ETL_CONSTEXPR14 optional_impl & operator=(const T &value_)
Assignment operator from value type.
Definition optional.h:871
ETL_CONSTEXPR14 T * operator->()
Pointer operator.
Definition optional.h:895
T & emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Definition optional.h:1169
ETL_CONSTEXPR14 optional_impl & operator=(const optional_impl< T > &other)
Assignment operator from optional_impl.
Definition optional.h:829
T & emplace()
Definition optional.h:1108
ETL_CONSTEXPR14 const T * operator->() const
Pointer operator.
Definition optional.h:907
ETL_CONSTEXPR14 T & operator*() ETL_LVALUE_REF_QUALIFIER
Dereference operator.
Definition optional.h:919
ETL_CONSTEXPR14 T & value() ETL_LVALUE_REF_QUALIFIER
Get a reference to the value.
Definition optional.h:985
etl::enable_if<!etl::is_base_of< this_type, typenameetl::remove_cv< typenameetl::remove_reference< T1 >::type >::type >::value &&!etl::is_same< etl::optional< T >, typenameetl::remove_cv< typenameetl::remove_reference< T1 >::type >::type >::value, T & >::type emplace(const T1 &value1)
Definition optional.h:1131
ETL_CONSTEXPR14 T value_or(const T &default_value) const ETL_LVALUE_REF_QUALIFIER
Gets the value or a default if not valid.
Definition optional.h:1009
ETL_CONSTEXPR14 optional_impl(const optional_impl< T > &other)
Copy constructor.
Definition optional.h:755
ETL_CONSTEXPR14 const T & value() const ETL_LVALUE_REF_QUALIFIER
Get a const reference to the value.
Definition optional.h:997
T & emplace(const T1 &value1, const T2 &value2)
Definition optional.h:1150
ETL_CONSTEXPR14 const T & operator*() const ETL_LVALUE_REF_QUALIFIER
Dereference operator.
Definition optional.h:931
ETL_CONSTEXPR14 void reset()
Reset back to invalid.
Definition optional.h:1071
ETL_CONSTEXPR14 void swap(optional_impl &other)
Swaps this value with another.
Definition optional.h:1061
ETL_CONSTEXPR14 optional_impl(etl::nullopt_t)
Constructor with nullopt.
Definition optional.h:746
ETL_CONSTEXPR14 optional_impl()
Constructor.
Definition optional.h:738
T & emplace(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition optional.h:1188
ETL_CONSTEXPR14 optional_impl & operator=(etl::nullopt_t)
Assignment operator from nullopt.
Definition optional.h:816
Definition optional.h:113
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition exception.h:81
T * construct_at(T *p)
Definition memory.h:1443
etl::enable_if< etl::is_trivially_destructible< T >::value, void >::type destroy_at(T *)
Definition memory.h:1511
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
ETL_CONSTEXPR20_STL etl::optional< typename etl::decay< T >::type > make_optional(T &value)
Make an optional.
Definition optional.h:2230
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1133
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1147
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
ETL_CONSTEXPR14 enable_if<!etl::is_specialization< TRep2, etl::chrono::duration >::value, etl::chrono::duration< typenameetl::common_type< TRep1, TRep2 >::type, TPeriod1 > >::type operator*(const etl::chrono::duration< TRep1, TPeriod1 > &lhs, const TRep2 &rhs) ETL_NOEXCEPT
Operator *.
Definition duration.h:541
const nullopt_t nullopt
Definition optional.h:77
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1106
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1120
ETL_CONSTEXPR20_STL void swap(etl::optional< T > &lhs, etl::optional< T > &rhs)
Swaps the values.
Definition optional.h:2248
in_place disambiguation tags.
Definition utility.h:927
remove_cv
Definition type_traits.h:325