| Index: base/memory/scoped_ptr.h
|
| diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
|
| index 282a014869b6f12231df0b4c753506c5f5494a06..fae6a9ba32c4cf38b58e268e9e93724dc6cac301 100644
|
| --- a/base/memory/scoped_ptr.h
|
| +++ b/base/memory/scoped_ptr.h
|
| @@ -145,6 +145,12 @@ class scoped_ptr_impl {
|
| }
|
|
|
| template <typename U, typename V>
|
| + void TakeState(std::unique_ptr<U, V>* other) {
|
| + reset(other->release());
|
| + get_deleter() = other->get_deleter();
|
| + }
|
| +
|
| + template <typename U, typename V>
|
| void TakeState(scoped_ptr_impl<U, V>* other) {
|
| // See comment in templated constructor above regarding lack of support
|
| // for move-only deleters.
|
| @@ -394,6 +400,22 @@ class scoped_ptr {
|
| return impl_.release();
|
| }
|
|
|
| + // Conversion shims to help with the std::unique_ptr transition.
|
| + template <typename U, typename V>
|
| + scoped_ptr(std::unique_ptr<U, V>&& p)
|
| + : impl_(p.release(), p.get_deleter()) {}
|
| +
|
| + template <typename U, typename V>
|
| + scoped_ptr& operator=(std::unique_ptr<U, V>&& p) {
|
| + impl_.TakeState(&p);
|
| + return *this;
|
| + }
|
| +
|
| + template <typename U, typename V>
|
| + operator std::unique_ptr<U, V>() && {
|
| + return std::unique_ptr<U, V>(release(), get_deleter());
|
| + }
|
| +
|
| private:
|
| // Needed to reach into |impl_| in the constructor.
|
| template <typename U, typename V> friend class scoped_ptr;
|
| @@ -486,6 +508,19 @@ class scoped_ptr<T[], D> {
|
| return impl_.release();
|
| }
|
|
|
| + // Conversion shims to help with the std::unique_ptr transition.
|
| + scoped_ptr(std::unique_ptr<T[], D>&& p)
|
| + : impl_(p.release(), p.get_deleter()) {}
|
| +
|
| + scoped_ptr& operator=(std::unique_ptr<T[], D>&& p) {
|
| + impl_.TakeState(&p);
|
| + return *this;
|
| + }
|
| +
|
| + operator std::unique_ptr<T[], D>() && {
|
| + return std::unique_ptr<T[], D>(release(), get_deleter());
|
| + }
|
| +
|
| private:
|
| // Force element_type to be a complete type.
|
| enum { type_must_be_complete = sizeof(element_type) };
|
|
|