Index: base/memory/scoped_ptr.h |
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h |
index 291d9b302cf03f7bc4bc0a7423d465b4382d4c9f..a4142ebddb8ae8acb3a66a7592871f6e02621c23 100644 |
--- a/base/memory/scoped_ptr.h |
+++ b/base/memory/scoped_ptr.h |
@@ -313,6 +313,7 @@ class scoped_ptr { |
public: |
// The element and deleter types. |
typedef T element_type; |
+ using Pointer = element_type*; |
typedef D deleter_type; |
// Constructor. Defaults to initializing with nullptr. |
@@ -327,18 +328,16 @@ class scoped_ptr { |
// Constructor. Allows construction from a nullptr. |
scoped_ptr(std::nullptr_t) : impl_(nullptr) {} |
+ // Move constructor. |
+ scoped_ptr(scoped_ptr&& other) : impl_(&other.impl_) {} |
+ |
// Constructor. Allows construction from a scoped_ptr rvalue for a |
// convertible type and deleter. |
- // |
- // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct |
- // from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor |
- // has different post-conditions if D is a reference type. Since this |
- // implementation does not support deleters with reference type, |
- // we do not need a separate move constructor allowing us to avoid one |
- // use of SFINAE. You only need to care about this if you modify the |
- // implementation of scoped_ptr. |
template <typename U, typename V> |
- scoped_ptr(scoped_ptr<U, V>&& other) |
+ scoped_ptr(scoped_ptr<U, V>&& other, |
danakj
2015/11/18 23:39:34
I wish clang-format did a better job wrapping temp
|
+ typename std::enable_if< |
+ std::is_convertible<typename scoped_ptr<U, V>::Pointer, |
danakj
2015/11/18 23:39:34
Can you explain to me why you used enable_if here?
dcheng
2015/11/19 00:23:24
I don't actually know the reasoning behind this: i
vmpstr
2015/11/19 00:37:18
Is it possible to enable_if in the template list i
dcheng
2015/11/19 00:38:57
Any particular reason to prefer that? I guess the
|
+ Pointer>::value>::type* = nullptr) |
: impl_(&other.impl_) { |
COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array); |
} |