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

Unified Diff: base/memory/scoped_ptr.h

Issue 15721007: Make expressions like "if (weak_ptr)" work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment again Created 7 years, 6 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/weak_ptr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_ptr.h
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index 5edde8fb32e655f0516f19733c1a8b86c86a59dc..dfa12587242962f5884d1f6246aeeca068d16756 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -384,6 +384,11 @@ class scoped_ptr {
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
+ //
+ // Note that this trick is only safe when the == and != operators
+ // are declared explicitly, as otherwise "scoped_ptr1 ==
+ // scoped_ptr2" will compile but do the wrong thing (i.e., convert
+ // to Testable and then do the comparison).
private:
typedef base::internal::scoped_ptr_impl<element_type, deleter_type>
scoped_ptr::*Testable;
« no previous file with comments | « no previous file | base/memory/weak_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698