18 Optional(
const Optional<T>& t_optional) : m_value(t_optional.m_value ?
new T(*t_optional.m_value) :
nullptr) {}
21 t_optional.m_value =
nullptr;
24 Optional(
const T& t_value) : m_value(
new T(t_value)) {}
26 Optional(T&& t_value) : m_value(
new T(std::move(t_value))) {}
34 bool has_value()
const {
return m_value; }
38 throw std::bad_optional_access();
43 const T& value()
const {
45 throw std::bad_optional_access();
50 T& operator*() {
return value(); }
52 const T& operator*()
const {
return value(); }
54 T* operator->() {
return m_value; }
56 const T* operator->()
const {
return m_value; }
58 explicit operator bool()
const {
return m_value; }
64 m_value =
new T(std::move(t_value));
72 m_value =
new T(t_value);
83 template<
class ...ArgsT>
84 T& emplace(ArgsT&& ...t_args) {
88 m_value =
new T(std::forward<ArgsT>(t_args)...);