Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: third_party/WebKit/Source/wtf/RefPtr.h

Issue 1912203002: Revert of WTF: Implement explicit RefPtr::operator bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/RefPtr.h
diff --git a/third_party/WebKit/Source/wtf/RefPtr.h b/third_party/WebKit/Source/wtf/RefPtr.h
index 1660f882f8b321cf8ee9605558c5af12319ffe17..4ed3ea5de07c16ca00103e0044387d07421dbaef 100644
--- a/third_party/WebKit/Source/wtf/RefPtr.h
+++ b/third_party/WebKit/Source/wtf/RefPtr.h
@@ -70,7 +70,11 @@
ALWAYS_INLINE T* operator->() const { return m_ptr; }
bool operator!() const { return !m_ptr; }
- explicit operator bool() const { return m_ptr; }
+
+ // This conversion operator allows implicit conversion to bool but not to
+ // other integer types.
+ typedef T* (RefPtr::*UnspecifiedBoolType);
+ operator UnspecifiedBoolType() const { return m_ptr ? &RefPtr::m_ptr : 0; }
RefPtr& operator=(RefPtr o) { swap(o); return *this; }
RefPtr& operator=(std::nullptr_t) { clear(); return *this; }
@@ -131,16 +135,6 @@
return a == b.get();
}
-template <typename T> inline bool operator==(const RefPtr<T>& a, std::nullptr_t)
-{
- return !a.get();
-}
-
-template <typename T> inline bool operator==(std::nullptr_t, const RefPtr<T>& b)
-{
- return !b.get();
-}
-
template <typename T, typename U> inline bool operator!=(const RefPtr<T>& a, const RefPtr<U>& b)
{
return a.get() != b.get();
@@ -154,16 +148,6 @@
template <typename T, typename U> inline bool operator!=(T* a, const RefPtr<U>& b)
{
return a != b.get();
-}
-
-template <typename T> inline bool operator!=(const RefPtr<T>& a, std::nullptr_t)
-{
- return a.get();
-}
-
-template <typename T> inline bool operator!=(std::nullptr_t, const RefPtr<T>& b)
-{
- return b.get();
}
template <typename T, typename U> inline RefPtr<T> static_pointer_cast(const RefPtr<U>& p)
« no previous file with comments | « third_party/WebKit/Source/wtf/PassRefPtr.h ('k') | third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698