constexpr operators

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

View File

@ -101,7 +101,7 @@ 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
@ -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_;