| Index: base/memory/weak_ptr.h
|
| diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h
|
| index 3b8bcb1b077607f36224fa52837e72161f3ed295..23826f7ccbb99238a2de0f97b64855003bd5dadb 100644
|
| --- a/base/memory/weak_ptr.h
|
| +++ b/base/memory/weak_ptr.h
|
| @@ -226,36 +226,9 @@ class WeakPtr : public internal::WeakPtrBase {
|
| ptr_ = nullptr;
|
| }
|
|
|
| - // Implement "Safe Bool Idiom"
|
| - // https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Safe_bool
|
| - //
|
| - // Allow WeakPtr<element_type> to be used in boolean expressions such as
|
| - // if (weak_ptr_instance)
|
| - // But do not become convertible to a real bool (which is dangerous).
|
| - // Implementation requires:
|
| - // typedef Testable
|
| - // operator Testable() const
|
| - // operator==
|
| - // operator!=
|
| - //
|
| - // == and != operators must be declared explicitly or dissallowed, as
|
| - // otherwise "ptr1 == ptr2" will compile but do the wrong thing (i.e., convert
|
| - // to Testable and then do the comparison).
|
| - //
|
| - // C++11 provides for "explicit operator bool()", however it is currently
|
| - // banned due to MSVS2013. https://chromium-cpp.appspot.com/#core-blacklist
|
| - private:
|
| - typedef T* WeakPtr::*Testable;
|
| -
|
| - public:
|
| - operator Testable() const { return get() ? &WeakPtr::ptr_ : nullptr; }
|
| + explicit operator bool() const { return get() != nullptr; }
|
|
|
| private:
|
| - // Explicitly declare comparison operators as required by the "Safe Bool
|
| - // Idiom", but keep them private.
|
| - template <class U> bool operator==(WeakPtr<U> const&) const;
|
| - template <class U> bool operator!=(WeakPtr<U> const&) const;
|
| -
|
| friend class internal::SupportsWeakPtrBase;
|
| template <typename U> friend class WeakPtr;
|
| friend class SupportsWeakPtr<T>;
|
|
|