diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-10 18:54:24 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-10 18:54:24 +0000 |
commit | f0b7d5960d6c0bab6c4d8126be296b39f21c3134 (patch) | |
tree | 412edb08430644dfc874e7fe44c480579a0d0387 /core | |
parent | 4f261fffddddd97602e88fe462fef1a18a0b4782 (diff) | |
download | pdfium-f0b7d5960d6c0bab6c4d8126be296b39f21c3134.tar.xz |
Add Observable::ObservedPtr::HasObservable().
if (pObserved->HasObservable()) is more readable than if (*pObserved).
Change-Id: I61ad3deb8e9f30cdc120a05555c2558f34489681
Reviewed-on: https://pdfium-review.googlesource.com/c/43811
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/observable.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/fxcrt/observable.h b/core/fxcrt/observable.h index e118dc898b..3205bc09df 100644 --- a/core/fxcrt/observable.h +++ b/core/fxcrt/observable.h @@ -46,6 +46,7 @@ class Observable { ASSERT(m_pObservable); m_pObservable = nullptr; } + bool HasObservable() const { return !!m_pObservable; } ObservedPtr& operator=(const ObservedPtr& that) { Reset(that.Get()); return *this; @@ -54,7 +55,7 @@ class Observable { return m_pObservable == that.m_pObservable; } bool operator!=(const ObservedPtr& that) const { return !(*this == that); } - explicit operator bool() const { return !!m_pObservable; } + explicit operator bool() const { return HasObservable(); } T* Get() const { return m_pObservable; } T& operator*() const { return *m_pObservable; } T* operator->() const { return m_pObservable; } |