optional emplacement.

This commit is contained in:
Kelvin Sherlock 2017-01-13 00:33:21 -05:00
parent 61c3b82aaf
commit 6d1e684f8d
1 changed files with 8 additions and 2 deletions

View File

@ -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>(args)...);
_engaged = true;
}