|
|
@@ -55,12 +55,6 @@ public:
|
|
|
reference operator*() const { return *_ptr; }
|
|
|
pointer operator->() const { return get(); }
|
|
|
|
|
|
- bool operator==(not_null const&rhs) const { return _ptr == rhs._ptr; }
|
|
|
- bool operator!=(not_null const&rhs) const { return _ptr != rhs._ptr; }
|
|
|
- bool operator<=(not_null const&rhs) const { return _ptr <= rhs._ptr; }
|
|
|
- bool operator>=(not_null const&rhs) const { return _ptr >= rhs._ptr; }
|
|
|
- bool operator< (not_null const&rhs) const { return _ptr < rhs._ptr; }
|
|
|
- bool operator> (not_null const&rhs) const { return _ptr > rhs._ptr; }
|
|
|
private:
|
|
|
void validate() {
|
|
|
if (get() == nullptr) {
|
|
|
@@ -69,3 +63,98 @@ private:
|
|
|
}
|
|
|
T _ptr;
|
|
|
};
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator==(not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ return lhs.get() == rhs.get();
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator!=(not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ return !(lhs == rhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator< (not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ typedef typename std::common_type<
|
|
|
+ typename not_null<T>::pointer,
|
|
|
+ typename not_null<U>::pointer>::type V;
|
|
|
+ return std::less<V>(lhs.get(), rhs.get());
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator> (not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ return rhs < lhs;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator<=(not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ return !(rhs < lhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T, typename U>
|
|
|
+bool operator>=(not_null<T> const&lhs, not_null<U> const&rhs) {
|
|
|
+ return !(lhs < rhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator==(not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ return !lhs;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator==(std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ return !rhs;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator!=(not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ return static_cast<bool>(lhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator!=(std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ return static_cast<bool>(rhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator< (not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ typedef typename not_null<T>::pointer V;
|
|
|
+ return std::less<V>(lhs.get(), nullptr);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator< (std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ typedef typename not_null<T>::pointer V;
|
|
|
+ return std::less<V>(nullptr, rhs.get());
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator> (not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ return nullptr < lhs;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator> (std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ return rhs < nullptr;
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator<=(not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ return !(nullptr < lhs);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator<=(std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ return !(rhs < nullptr);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator>=(not_null<T> const&lhs, std::nullptr_t) {
|
|
|
+ return !(lhs < nullptr);
|
|
|
+}
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+bool operator>=(std::nullptr_t, not_null<T> const&rhs) {
|
|
|
+ return !(nullptr < rhs);
|
|
|
+}
|