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

Unified Diff: base/memory/scoped_ptr.h

Issue 9015015: Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | « no previous file | media/base/async_filter_factory_base.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 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.
« no previous file with comments | « no previous file | media/base/async_filter_factory_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698