<p dir="ltr">Unit tests? (I say this in part because I recall giving Chris Lattner some grief over a similar change (that turned out to be buggy...))</p>
<p dir="ltr">And if you're going to define some operators in terms of others you could do that for all and implement A == nullptr as nullptr == A</p>
<p dir="ltr">On Jun 3, 2014 6:39 AM, "Rafael Espindola" <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
> Author: rafael<br>
> Date: Tue Jun 3 08:26:18 2014<br>
> New Revision: 210100<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=210100&view=rev">http://llvm.org/viewvc/llvm-project?rev=210100&view=rev</a><br>
> Log:<br>
> Add operator== and operator!= to compare with nullptr.<br>
><br>
> Modified:<br>
> llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h<br>
><br>
> Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=210100&r1=210099&r2=210100&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=210100&r1=210099&r2=210100&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)<br>
> +++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Tue Jun 3 08:26:18 2014<br>
> @@ -241,6 +241,26 @@ public:<br>
> return A != B.getPtr();<br>
> }<br>
><br>
> + template <class T><br>
> + bool operator==(std::nullptr_t A, const IntrusiveRefCntPtr<T> &B) {<br>
> + return !B;<br>
> + }<br>
> +<br>
> + template <class T><br>
> + bool operator==(const IntrusiveRefCntPtr<T> &A, std::nullptr_t B) {<br>
> + return !A;<br>
> + }<br>
> +<br>
> + template <class T><br>
> + bool operator!=(std::nullptr_t A, const IntrusiveRefCntPtr<T> &B) {<br>
> + return !(A == B);<br>
> + }<br>
> +<br>
> + template <class T><br>
> + bool operator!=(const IntrusiveRefCntPtr<T> &A, std::nullptr_t B) {<br>
> + return !(A == B);<br>
> + }<br>
> +<br>
> //===----------------------------------------------------------------------===//<br>
> // LLVM-style downcasting support for IntrusiveRefCntPtr objects<br>
> //===----------------------------------------------------------------------===//<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</p>