22 new (&m_storage) T(val);
23 m_value =
reinterpret_cast<T *
>(&m_storage);
28 new (&m_storage) T(std::forward<T>(val));
29 m_value =
reinterpret_cast<T *
>(&m_storage);
44 *m_value = std::forward<U>(u);
48 new (&m_storage) T(std::forward<U>(u));
49 m_value =
reinterpret_cast<T *
>(&m_storage);
58 new (&m_storage) T(*other.m_value);
59 m_value =
reinterpret_cast<T *
>(&m_storage);
71 new (&m_storage) T(std::forward<T>(*other.m_value));
72 m_value =
reinterpret_cast<T *
>(&m_storage);
91 *m_value = *other.m_value;
104 new (&m_storage) T(*other.m_value);
105 m_value =
reinterpret_cast<T *
>(&m_storage);
122 *m_value = *other.m_value;
135 new (&m_storage) T(*other.m_value);
136 m_value =
reinterpret_cast<T *
>(&m_storage);
153 *m_value = std::forward<U>(*other.m_value);
166 new (&m_storage) T(std::forward<U>(*other.m_value));
167 m_value =
reinterpret_cast<T *
>(&m_storage);
177 const T &&
operator*() const && {
return std::move(*m_value); }
180 explicit operator bool() const noexcept {
return m_value !=
nullptr; }
181 bool has_value() const noexcept {
return m_value !=
nullptr; }
184 const T &
value() const & {
return *m_value; }
186 T &&
value() && {
return std::move(*m_value); }
187 const T &&
value() const && {
return std::move(*m_value); }
190 typename std::aligned_storage<
sizeof(T)>::
type m_storage;
Definition: Optional.h:17
const T & operator*() const &
Definition: Optional.h:175
Optional(const T &val)
Definition: Optional.h:20
Optional & operator=(const Optional &other)
Definition: Optional.h:80
const T & value() const &
Definition: Optional.h:184
Optional()
Definition: Optional.h:19
bool has_value() const noexcept
Definition: Optional.h:181
Optional(const Optional< T > &other)
Definition: Optional.h:54
T && operator*() &&
Definition: Optional.h:178
const T && operator*() const &&
Definition: Optional.h:177
Optional(Optional< T > &&other)
Definition: Optional.h:67
Optional< T > & operator=(const Optional< U > &other)
Definition: Optional.h:111
Optional(T &&val)
Definition: Optional.h:26
T & operator*() &
Definition: Optional.h:176
Optional< T > & operator=(Optional< U > &&other)
Definition: Optional.h:142
T && value() &&
Definition: Optional.h:186
const T * operator->() const
Definition: Optional.h:173
Optional & operator=(U &&u)
Definition: Optional.h:40
T & value() &
Definition: Optional.h:183
~Optional()
Definition: Optional.h:32
T * operator->()
Definition: Optional.h:174
const T && value() const &&
Definition: Optional.h:187
newitem type
Definition: cJSON.cpp:2724