diff options
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/utility.h b/src/utility.h index 6342420..db33608 100644 --- a/src/utility.h +++ b/src/utility.h @@ -4,24 +4,30 @@ namespace detail { template < - typename Value + typename Type > -struct Result { - Result(): - value_(false, Value()) { } +class optional_ptr { + public: + typedef typename std::add_pointer<Type>::type pointer; + typedef Type element_type; - Result(Value value): - value_(true, value) { } + optional_ptr(): + value_(false, nullptr) { } - inline operator bool() const { - return this->value_.first; - } + optional_ptr(pointer ptr): + value_(true, ptr) { } - inline Value get() const { - return this->value_.second; - } + inline operator bool() const { + return this->value_.first; + } + + inline pointer get() const { + return this->value_.second; + } + + private: + const std::pair<bool, pointer> value_; - const std::pair<bool, Value> value_; }; } |