Go to the documentation of this file.
16 #if __cplusplus >= 201703L
20 # include <type_traits>
28 #if __cplusplus >= 201703L
29 template <
typename T>
using Optional = std::optional<T>;
37 new (&m_storage) T(val);
38 m_value =
reinterpret_cast<T *
>(&m_storage);
43 new (&m_storage) T(std::forward<T>(val));
44 m_value =
reinterpret_cast<T *
>(&m_storage);
59 *m_value = std::forward<U>(u);
63 new (&m_storage) T(std::forward<U>(u));
64 m_value =
reinterpret_cast<T *
>(&m_storage);
73 new (&m_storage) T(*other.m_value);
74 m_value =
reinterpret_cast<T *
>(&m_storage);
86 new (&m_storage) T(std::forward<T>(*other.m_value));
87 m_value =
reinterpret_cast<T *
>(&m_storage);
106 *m_value = *other.m_value;
119 new (&m_storage) T(*other.m_value);
120 m_value =
reinterpret_cast<T *
>(&m_storage);
137 *m_value = *other.m_value;
150 new (&m_storage) T(*other.m_value);
151 m_value =
reinterpret_cast<T *
>(&m_storage);
168 *m_value = std::forward<U>(*other.m_value);
181 new (&m_storage) T(std::forward<U>(*other.m_value));
182 m_value =
reinterpret_cast<T *
>(&m_storage);
192 const T &&
operator*() const && {
return std::move(*m_value); }
195 explicit operator bool() const noexcept {
return m_value !=
nullptr; }
196 bool has_value() const noexcept {
return m_value !=
nullptr; }
199 const T &
value() const & {
return *m_value; }
201 T &&
value() && {
return std::move(*m_value); }
202 const T &&
value() const && {
return std::move(*m_value); }
205 typename std::aligned_storage<
sizeof(T)>::
type m_storage;
T * operator->()
Definition: Optional.h:189
~Optional()
Definition: Optional.h:47
const T && value() const &&
Definition: Optional.h:202
Optional(const T &val)
Definition: Optional.h:35
T && value() &&
Definition: Optional.h:201
Optional< T > & operator=(Optional< U > &&other)
Definition: Optional.h:157
Optional< T > & operator=(const Optional< U > &other)
Definition: Optional.h:126
Optional(Optional< T > &&other)
Definition: Optional.h:82
const T & value() const &
Definition: Optional.h:199
T && operator*() &&
Definition: Optional.h:193
const T && operator*() const &&
Definition: Optional.h:192
T & operator*() &
Definition: Optional.h:191
Optional & operator=(U &&u)
Definition: Optional.h:55
Definition: Optional.h:32
Optional(const Optional< T > &other)
Definition: Optional.h:69
Optional & operator=(const Optional &other)
Definition: Optional.h:95
bool has_value() const noexcept
Definition: Optional.h:196
Optional()
Definition: Optional.h:34
Optional(T &&val)
Definition: Optional.h:41
const T & operator*() const &
Definition: Optional.h:190
newitem type
Definition: cJSON.cpp:2209
const T * operator->() const
Definition: Optional.h:188
T & value() &
Definition: Optional.h:198