diff --git a/optional.h b/optional.h index e3fbd12..9260cad 100644 --- a/optional.h +++ b/optional.h @@ -56,6 +56,10 @@ public: } + ~optional() { + reset(); + } + template< class U = T > optional& operator=( U&& value ) { @@ -82,9 +86,11 @@ public: return *this; } - - ~optional() { + template< class... Args > + void emplace( Args&&... args ) { reset(); + new(std::addressof(_data)) T(std::forward(args)...); + _engaged = true; }