summaryrefslogtreecommitdiff
path: root/zen/optional.h
diff options
context:
space:
mode:
Diffstat (limited to 'zen/optional.h')
-rwxr-xr-xzen/optional.h21
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; }
bgstack15