26 new (m_storage)
T(
val);
27 m_value =
reinterpret_cast<T *
>(m_storage);
32 new (m_storage)
T(std::forward<T>(
val));
33 m_value =
reinterpret_cast<T *
>(m_storage);
49 typename std::enable_if<
56 *m_value = std::forward<U>(
u);
60 new (m_storage)
T(std::forward<U>(
u));
61 m_value =
reinterpret_cast<T *
>(m_storage);
70 new (m_storage)
T(*other.m_value);
71 m_value =
reinterpret_cast<T *
>(m_storage);
83 new (m_storage)
T(std::forward<T>(*other.m_value));
84 m_value =
reinterpret_cast<T *
>(m_storage);
94 new (m_storage)
T(std::forward<Args>(
args)...);
95 m_value =
reinterpret_cast<T *
>(m_storage);
108 new (m_storage)
T(std::forward<Args>(
args)...);
109 m_value =
reinterpret_cast<T *
>(m_storage);
127 T &&
value() && {
return std::move(*m_value); }
140 template <
typename Op>
Optional &assign(
Op &&other)
145 using U =
typename std::conditional<
146 std::is_const<typename std::remove_reference<Op>::type>
::value,
147 const typename std::decay<Op>::type::ValueType &,
148 typename std::decay<Op>::type::ValueType>::type;
150 if ((
void *)
this == (
void *)&other)
159 if (other.has_value())
161 *m_value = std::forward<U>(other.value());
172 if (other.has_value())
174 new (m_storage)
T(std::forward<U>(other.value()));
175 m_value =
reinterpret_cast<T *
>(m_storage);
181 alignas(
T)
char m_storage[
sizeof(
T)];
const T & operator*() const &
Definition Optional.h:116
Optional(const T &val)
Definition Optional.h:24
Optional< T > & operator=(const Optional &other)
Definition Optional.h:98
T ValueType
Definition Optional.h:21
Optional & operator=(U &&u)
Definition Optional.h:52
const T & value() const &
Definition Optional.h:125
Optional()
Definition Optional.h:23
T & emplace(Args &&...args)
Definition Optional.h:104
bool has_value() const noexcept
Definition Optional.h:122
void reset()
Definition Optional.h:130
Optional(const Optional< T > &other)
Definition Optional.h:66
T && operator*() &&
Definition Optional.h:119
const T && operator*() const &&
Definition Optional.h:118
Optional(Aws::Crt::InPlaceT, Args &&...args)
Definition Optional.h:92
Optional(Optional< T > &&other)
Definition Optional.h:79
Optional< T > & operator=(const Optional< U > &other)
Definition Optional.h:100
Optional(T &&val)
Definition Optional.h:30
T & operator*() &
Definition Optional.h:117
Optional< T > & operator=(Optional< U > &&other)
Definition Optional.h:102
T && value() &&
Definition Optional.h:127
const T * operator->() const
Definition Optional.h:114
T & value() &
Definition Optional.h:124
~Optional()
Definition Optional.h:36
T * operator->()
Definition Optional.h:115
const T && value() const &&
Definition Optional.h:128
std::unique_ptr< T, std::function< void(T *)> > ScopedResource
Definition Types.h:163
Definition Allocator.h:11