patch by Jesse Towner, and bug fix by Sebastian Redl

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@110724 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/cstddef b/include/cstddef
index f6b34ad..8cba5f8 100644
--- a/include/cstddef
+++ b/include/cstddef
@@ -78,6 +78,42 @@
     friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}
     friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}
     friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;}
+
+    template <typename _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, _Tp* __p) {return 0 == __p;}
+
+    template <typename _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator==(_Tp* __p, nullptr_t) {return __p == 0;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, _Tp* __p) {return 0 != __p;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator!=(_Tp* __p, nullptr_t) {return __p != 0;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, _Tp* __p) {return 0 < __p;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator<(_Tp* __p, nullptr_t) {return __p < 0;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, _Tp* __p) {return 0 <= __p;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator<=(_Tp* __p, nullptr_t) {return __p <= 0;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, _Tp* __p) {return 0 > __p;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator>(_Tp* __p, nullptr_t) {return __p > 0;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, _Tp* __p) {return 0 >= __p;}
+
+    template <class _Tp>
+        friend _LIBCPP_ALWAYS_INLINE bool operator>=(_Tp* __p, nullptr_t) {return __p >= 0;}
 };
 
 inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}