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

Unified Diff: base/memory/ref_counted.h

Issue 9232069: Add assert() for scoped_refptr<T>::operator->() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use assert() instead Created 8 years, 11 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 | no next file » | 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 b7cb5e064175466d747e5ae66125262d8f1558cf..cf8ff1688dc7f4de093f78d15a17a1fade0ed0fe 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -6,6 +6,8 @@
#define BASE_MEMORY_REF_COUNTED_H_
#pragma once
+#include <cassert>
+
#include "base/atomic_ref_count.h"
#include "base/base_export.h"
#include "base/threading/thread_collision_warner.h"
@@ -243,7 +245,10 @@ class scoped_refptr {
T* get() const { return ptr_; }
operator T*() const { return ptr_; }
- T* operator->() const { return ptr_; }
+ T* operator->() const {
+ assert(ptr_ != NULL);
jar (doing other things) 2012/01/28 02:47:22 Could you clarify when this would be significant?
+ return ptr_;
+ }
// Release a pointer.
// The return value is the current pointer held by this object.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698