diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2018-06-30 12:43:08 +0200 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2018-06-30 12:43:08 +0200 |
commit | a98326eb2954ac1e79f5eac28dbeab3ec15e047f (patch) | |
tree | bb16257a1894b488e365851273735ec13a9442ef /zen/optional.h | |
parent | 10.0 (diff) | |
download | FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.tar.gz FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.tar.bz2 FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.zip |
10.1
Diffstat (limited to 'zen/optional.h')
-rwxr-xr-x | zen/optional.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/zen/optional.h b/zen/optional.h index 88928ac0..e4605c5f 100755 --- a/zen/optional.h +++ b/zen/optional.h @@ -7,7 +7,6 @@ #ifndef OPTIONAL_H_2857428578342203589 #define OPTIONAL_H_2857428578342203589 -//#include <cassert> #include <type_traits> @@ -51,16 +50,6 @@ public: ~Opt() { if (T* val = get()) val->~T(); } - Opt& operator=(NoValue) //support assignment to Opt<const T> - { - if (T* val = get()) - { - valid_ = false; - val->~T(); - } - return *this; - } - Opt& operator=(const Opt& other) //strong exception-safety iff T::operator=() is strongly exception-safe { if (T* val = get()) @@ -81,6 +70,16 @@ public: return *this; } + Opt& operator=(NoValue) //support assignment to Opt<const T> + { + if (T* val = get()) + { + valid_ = false; + val->~T(); + } + return *this; + } + explicit operator bool() const { return valid_; } //thank you, C++11!!! const T* get() const { return valid_ ? reinterpret_cast<const T*>(&rawMem_) : nullptr; } |