constexpr operators

This commit is contained in:
Alexander Ryabykin 2016-07-02 15:24:10 +03:00
parent 0535138459
commit 3c017bfa10

View File

@ -101,8 +101,8 @@ public:
not_null(std::nullptr_t) = delete;
not_null(int) = delete;
not_null<T>& operator=(std::nullptr_t) = delete;
not_null<T>& operator=(int) = delete;
not_null<T>& operator=(int) = delete;
T get() const {
#ifdef _MSC_VER
__assume(ptr_ != nullptr);
@ -110,11 +110,16 @@ public:
return ptr_;
} // the assume() should help the optimizer
operator T() const { return get(); }
operator T() const { return get(); }
T operator->() const { return get(); }
bool operator==(const T& rhs) const { return ptr_ == rhs; }
bool operator!=(const T& rhs) const { return !(*this == rhs); }
bool operator==(const T& rhs) const { return ptr_ == rhs; }
bool operator!=(const T& rhs) const { return !(*this == rhs); }
constexpr bool operator==(std::nullptr_t) const { return false; }
constexpr bool operator!=(std::nullptr_t) const { return true; }
constexpr operator bool() const { return true; }
private:
T ptr_;