This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new ebd186e  Add the flipped equality/inequality operators with raw 
pointers to Ptr<>.
ebd186e is described below

commit ebd186ed99ad12468f6e427ae2510b61f0b315c1
Author: Alan M. Carroll <a...@apache.org>
AuthorDate: Tue May 15 14:49:08 2018 -0500

    Add the flipped equality/inequality operators with raw pointers to Ptr<>.
---
 lib/ts/Ptr.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lib/ts/Ptr.h b/lib/ts/Ptr.h
index da358b6..b78ee36 100644
--- a/lib/ts/Ptr.h
+++ b/lib/ts/Ptr.h
@@ -248,3 +248,36 @@ Ptr<T>::operator=(const Ptr<T> &src)
 {
   return (operator=(src.m_ptr));
 }
+
+// Bit of subtly here for the flipped version of equality checks
+// With only the template versions, the compiler will try to substitute @c 
nullptr_t
+// for @c T and fail, because that's not the type and no operator will be 
found.
+// Therefore there needs to be specific overrides for @c nullptr_t.
+
+template <typename T>
+inline bool
+operator==(std::nullptr_t, Ptr<T> const &rhs)
+{
+  return rhs.get() == nullptr;
+}
+
+template <typename T>
+inline bool
+operator!=(std::nullptr_t, Ptr<T> const &rhs)
+{
+  return rhs.get() != nullptr;
+}
+
+template <typename T>
+inline bool
+operator==(T const *lhs, Ptr<T> const &rhs)
+{
+  return rhs.get() == lhs;
+}
+
+template <typename T>
+inline bool
+operator!=(T const *lhs, Ptr<T> const &rhs)
+{
+  return rhs.get() != lhs;
+}

-- 
To stop receiving notification emails like this one, please contact
a...@apache.org.

Reply via email to