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

Unified Diff: base/memory/scoped_ptr.h

Issue 11411318: DO NOT COMMIT: NullPtr support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP Created 8 years 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 | « base/base.gypi ('k') | base/nullptr.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 3547b7a15397f9c58f3c5193401d6d9defae333d..c12b98083e90e34709ae9f233c46abe8438ca7fb 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -95,9 +95,13 @@
#include <stddef.h>
#include <stdlib.h>
+#include <type_traits>
+
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/move.h"
+#include "base/nullptr.h"
#include "base/template_util.h"
namespace base {
@@ -141,10 +145,15 @@ class scoped_ptr {
// The element type
typedef C element_type;
+ scoped_ptr() : ptr_(NULL) {}
+ scoped_ptr(base::nullptr_t) : ptr_(NULL) {}
+
// Constructor. Defaults to initializing with NULL.
// There is no way to create an uninitialized scoped_ptr.
// The input parameter must be allocated with new.
- explicit scoped_ptr(C* p = NULL) : ptr_(p) { }
+ template <typename V>
+ scoped_ptr(V p, typename std::enable_if<!std::is_integral<V>::value &&
+ std::is_convertible<V, C*>::value, int>::type = 0) : ptr_(p) { }
// Constructor. Allows construction from a scoped_ptr rvalue for a
// convertible type.
« no previous file with comments | « base/base.gypi ('k') | base/nullptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698