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

Unified Diff: base/memory/ref_counted.h

Issue 609593004: Add an explicit bool conversion to scoped_refptr<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WMI? Created 6 years, 3 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 | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted.h
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index be4919c1a51908699c260936f4f6b3c62a98d9ab..4eab2dda5c0591a8e19a0f1ae38fafe5250b3c1c 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -303,13 +303,15 @@ class scoped_refptr {
operator T*() const { return ptr_; }
#endif
+ explicit operator bool() const { return ptr_ != nullptr; }
+
T& operator*() const {
- assert(ptr_ != NULL);
+ assert(ptr_ != nullptr);
return *ptr_;
}
T* operator->() const {
- assert(ptr_ != NULL);
+ assert(ptr_ != nullptr);
return ptr_;
}
« no previous file with comments | « no previous file | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698