mirror of
https://github.com/ksherlock/wdc-utils.git
synced 2024-12-26 17:29:30 +00:00
optional emplacement.
This commit is contained in:
parent
61c3b82aaf
commit
6d1e684f8d
10
optional.h
10
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>(args)...);
|
||||
_engaged = true;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user