Index: base/memory/scoped_ptr.h |
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h |
index 09981d88533ee3cac495829c966b101891950f5b..3547b7a15397f9c58f3c5193401d6d9defae333d 100644 |
--- a/base/memory/scoped_ptr.h |
+++ b/base/memory/scoped_ptr.h |
@@ -54,7 +54,7 @@ |
// } |
// |
// { |
-// scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay)" |
+// scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay"). |
// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay"). |
// scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo. |
// scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2. |
@@ -152,11 +152,8 @@ class scoped_ptr { |
scoped_ptr(scoped_ptr<U> other) : ptr_(other.release()) { } |
// Constructor. Move constructor for C++03 move emulation of this type. |
- scoped_ptr(RValue& other) |
- // The type of the underlying object is scoped_ptr; we have to |
- // reinterpret_cast back to the original type for the call to release to |
- // be valid. (See C++11 5.2.10.7) |
- : ptr_(reinterpret_cast<scoped_ptr&>(other).release()) { |
+ scoped_ptr(RValue rvalue) |
+ : ptr_(rvalue.object->release()) { |
} |
// Destructor. If there is a C object, delete it. |
@@ -175,8 +172,8 @@ class scoped_ptr { |
} |
// operator=. Move operator= for C++03 move emulation of this type. |
- scoped_ptr& operator=(RValue& rhs) { |
- swap(rhs); |
+ scoped_ptr& operator=(RValue rhs) { |
+ swap(*rhs->object); |
return *this; |
} |
@@ -288,11 +285,8 @@ class scoped_array { |
explicit scoped_array(C* p = NULL) : array_(p) { } |
// Constructor. Move constructor for C++03 move emulation of this type. |
- scoped_array(RValue& other) |
- // The type of the underlying object is scoped_array; we have to |
- // reinterpret_cast back to the original type for the call to release to |
- // be valid. (See C++11 5.2.10.7) |
- : array_(reinterpret_cast<scoped_array&>(other).release()) { |
+ scoped_array(RValue rvalue) |
+ : array_(rvalue.object->release()) { |
} |
// Destructor. If there is a C object, delete it. |
@@ -303,8 +297,8 @@ class scoped_array { |
} |
// operator=. Move operator= for C++03 move emulation of this type. |
- scoped_array& operator=(RValue& rhs) { |
- swap(rhs); |
+ scoped_array& operator=(RValue rhs) { |
+ swap(*rhs.object); |
return *this; |
} |
@@ -415,11 +409,8 @@ class scoped_ptr_malloc { |
explicit scoped_ptr_malloc(C* p = NULL): ptr_(p) {} |
// Constructor. Move constructor for C++03 move emulation of this type. |
- scoped_ptr_malloc(RValue& other) |
- // The type of the underlying object is scoped_ptr_malloc; we have to |
- // reinterpret_cast back to the original type for the call to release to |
- // be valid. (See C++11 5.2.10.7) |
- : ptr_(reinterpret_cast<scoped_ptr_malloc&>(other).release()) { |
+ scoped_ptr_malloc(RValue rvalue) |
+ : ptr_(rvalue.object->release()) { |
} |
// Destructor. If there is a C object, call the Free functor. |
@@ -428,8 +419,8 @@ class scoped_ptr_malloc { |
} |
// operator=. Move operator= for C++03 move emulation of this type. |
- scoped_ptr_malloc& operator=(RValue& rhs) { |
- swap(rhs); |
+ scoped_ptr_malloc& operator=(RValue rhs) { |
+ swap(*rhs.object); |
return *this; |
} |