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

Unified Diff: base/memory/scoped_ptr.h

Issue 13673002: Make scoped_array<T> more compatible with scoped_ptr<T[]>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Being ambitious. Created 7 years, 8 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/scoped_ptr.h
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index 7098e14281e4e182517d6700ce3d0b18b73c22b8..971767f3a8bdc2b023f991bd667bb0e63620c9e7 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -663,6 +663,18 @@ class scoped_array {
private:
C* array_;
+ // Disable initialization from any type other than C*, by providing a
+ // constructor that matches such an initialization, but is private and has no
+ // definition. This is disabled because it is not safe to call delete[] on an
+ // array whose static type does not match its dynamic type.
+ template <typename C2> explicit scoped_array(C2* array);
+ explicit scoped_array(int disallow_construction_from_null);
+
+ // Disable reset() from any type other than C*, for the same reasons as the
+ // constructor above.
+ template <typename C2> void reset(C2* array);
+ void reset(int disallow_reset_from_null);
+
// Forbid comparison of different scoped_array types.
template <class C2> bool operator==(scoped_array<C2> const& p2) const;
template <class C2> bool operator!=(scoped_array<C2> const& p2) const;
« 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