mirror of
https://github.com/ksherlock/wdc-utils.git
synced 2025-07-15 16:24:05 +00:00
optional emplacement.
This commit is contained in:
10
optional.h
10
optional.h
@@ -56,6 +56,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
~optional() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template< class U = T >
|
template< class U = T >
|
||||||
optional& operator=( U&& value ) {
|
optional& operator=( U&& value ) {
|
||||||
@@ -82,9 +86,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< class... Args >
|
||||||
~optional() {
|
void emplace( Args&&... args ) {
|
||||||
reset();
|
reset();
|
||||||
|
new(std::addressof(_data)) T(std::forward<Args>(args)...);
|
||||||
|
_engaged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user