Chromium Code Reviews| Index: base/memory/scoped_ptr.h |
| diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h |
| index 2d69a9db4489eb840ad65ad40087f08ecac7ff0d..8a21851d820c816d65242a000401ec51d80d8563 100644 |
| --- a/base/memory/scoped_ptr.h |
| +++ b/base/memory/scoped_ptr.h |
| @@ -126,6 +126,12 @@ class scoped_ptr { |
| // The input parameter must be allocated with new. |
| explicit scoped_ptr(C* p = NULL) : ptr_(p) { } |
| + // Constructor. Allows construction from a scoped_ptr rvalue for a |
|
Ami GONE FROM CHROMIUM
2011/12/30 02:09:32
Changes in this file are patched in from http://co
|
| + // convertible type. |
| + template <typename U> |
| + scoped_ptr(scoped_ptr<U> other) : ptr_(other.release()) { |
| + } |
| + |
| // Destructor. If there is a C object, delete it. |
| // We don't need to test ptr_ == NULL because C++ does that for us. |
| ~scoped_ptr() { |
| @@ -133,6 +139,14 @@ class scoped_ptr { |
| delete ptr_; |
| } |
| + // operator=. Allows assignment from a scoped_ptr rvalue for a convertible |
| + // type. |
| + template <typename U> |
| + scoped_ptr& operator=(scoped_ptr<U> rhs) { |
| + reset(rhs.release()); |
| + return *this; |
| + } |
| + |
| // Reset. Deletes the current owned object, if any. |
| // Then takes ownership of a new object, if given. |
| // this->reset(this->get()) works. |