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

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

Issue 1878253003: Allow explicit conversion operators and implement WTF::OwnPtr::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/OwnPtr.h
diff --git a/third_party/WebKit/Source/wtf/OwnPtr.h b/third_party/WebKit/Source/wtf/OwnPtr.h
index 0b0b58e081883b6b114a5ab04d6c8a17cf6d1f28..391031ca4c7d93c088c901d09990ba9f88cbaf18 100644
--- a/third_party/WebKit/Source/wtf/OwnPtr.h
+++ b/third_party/WebKit/Source/wtf/OwnPtr.h
@@ -70,11 +70,7 @@ public:
ValueType& operator[](std::ptrdiff_t i) const;
bool operator!() const { return !m_ptr; }
-
- // This conversion operator allows implicit conversion to bool but not to
- // other integer types.
- typedef PtrType OwnPtr::*UnspecifiedBoolType;
- operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtr::m_ptr : 0; }
+ explicit operator bool() const { return m_ptr; }
danakj 2016/04/12 23:23:24 do you mean return !!m_ptr? not sure if this leak
jbroman 2016/04/12 23:26:38 No, conversion to bool will result in either |true
danakj 2016/04/12 23:30:11 Yay thanks
OwnPtr& operator=(const PassOwnPtr<T>&);
OwnPtr& operator=(std::nullptr_t) { clear(); return *this; }

Powered by Google App Engine
This is Rietveld 408576698