Index: base/memory/ref_counted.h |
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h |
index ba7e657389d1d88e9cdfe75282ee17e250ec2fde..f088589b1c2121545a7b0d31fc62c18d413e8abc 100644 |
--- a/base/memory/ref_counted.h |
+++ b/base/memory/ref_counted.h |
@@ -249,8 +249,12 @@ class scoped_refptr { |
ptr_->Release(); |
} |
+ // Allow scoped_refptr<T> to be used in boolean expressions, but not |
+ // implicitly convertible to a real bool (which is dangerous). |
+ typedef T* scoped_refptr::*Testable; |
+ operator Testable() const { return ptr_ ? &scoped_refptr::ptr_ : NULL; } |
+ |
T* get() const { return ptr_; } |
- operator T*() const { return ptr_; } |
T* operator->() const { |
assert(ptr_ != NULL); |
return ptr_; |