diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
commit | 01eb8253196672c969a39587e90b49321a182428 (patch) | |
tree | 4a3b71d7913de519744466c9227fda6461c4f0b5 /zen/optional.h | |
parent | 5.0 (diff) | |
download | FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.gz FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.bz2 FreeFileSync-01eb8253196672c969a39587e90b49321a182428.zip |
5.1
Diffstat (limited to 'zen/optional.h')
-rw-r--r-- | zen/optional.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/zen/optional.h b/zen/optional.h index 1e04f52c..2bd272ae 100644 --- a/zen/optional.h +++ b/zen/optional.h @@ -34,9 +34,13 @@ template <class T> class Opt { public: - Opt() : valid(false), value() {} - Opt(NoValue) : valid(false), value() {} - Opt(const T& val) : valid(true ), value(val) {} + Opt() : value() , valid(false) {} + Opt(NoValue) : value() , valid(false) {} + Opt(const T& val) : value(val), valid(true ) {} + + //rvalue optimization: only basic exception safety: + Opt(Opt&& tmp) : value(std::move(tmp.value)), valid(tmp.valid) {} + Opt& operator=(const Opt& tmp) { value = std::move(tmp.value); valid = tmp.valid; } #ifdef _MSC_VER private: @@ -52,9 +56,11 @@ public: const T* operator->() const { return &value; } /**/ T* operator->() { return &value; } + + void reset() { valid = false; } private: - const bool valid; T value; + bool valid; }; } |