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

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

Issue 2063773002: Reland: WTF: Implement explicit RefPtr::operator bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/wtf/RefPtr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/PassRefPtr.h
diff --git a/third_party/WebKit/Source/wtf/PassRefPtr.h b/third_party/WebKit/Source/wtf/PassRefPtr.h
index bd1ee380cfbf2ddb9eb92febda883694a687fd84..48538cd788a66d22bbbe934ef426f31801288f61 100644
--- a/third_party/WebKit/Source/wtf/PassRefPtr.h
+++ b/third_party/WebKit/Source/wtf/PassRefPtr.h
@@ -83,10 +83,9 @@ public:
bool operator!() const { return !m_ptr; }
- // This conversion operator allows implicit conversion to bool but not to
- // other integer types.
- typedef T* (PassRefPtr::*UnspecifiedBoolType);
- operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; }
+ // TODO(jbroman): Simplifying this in the obvious way causes a massive
+ // regression in a perf test on ARM. http://crbug.com/607208
+ explicit operator bool() const { return m_ptr ? &PassRefPtr::m_ptr : 0; }
friend PassRefPtr adoptRef<T>(T*);
@@ -149,6 +148,16 @@ template <typename T, typename U> inline bool operator==(T* a, const PassRefPtr<
return a == b.get();
}
+template <typename T> inline bool operator==(const PassRefPtr<T>& a, std::nullptr_t)
+{
+ return !a.get();
+}
+
+template <typename T> inline bool operator==(std::nullptr_t, const PassRefPtr<T>& b)
+{
+ return !b.get();
+}
+
template <typename T, typename U> inline bool operator!=(const PassRefPtr<T>& a, const PassRefPtr<U>& b)
{
return a.get() != b.get();
@@ -174,6 +183,16 @@ template <typename T, typename U> inline bool operator!=(T* a, const PassRefPtr<
return a != b.get();
}
+template <typename T> inline bool operator!=(const PassRefPtr<T>& a, std::nullptr_t)
+{
+ return a.get();
+}
+
+template <typename T> inline bool operator!=(std::nullptr_t, const PassRefPtr<T>& b)
+{
+ return b.get();
+}
+
template <typename T> PassRefPtr<T> adoptRef(T* p)
{
adopted(p);
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/wtf/RefPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698