Chromium Code Reviews| Index: third_party/WebKit/Source/platform/inspector_protocol/PlatformSTL.h |
| diff --git a/third_party/WebKit/Source/platform/inspector_protocol/PlatformSTL.h b/third_party/WebKit/Source/platform/inspector_protocol/PlatformSTL.h |
| index 3e687b994c951e4ee0a65f2ce302fcc6022c28b7..289b8e686bd590a5b92a662e979046feea2a7e16 100644 |
| --- a/third_party/WebKit/Source/platform/inspector_protocol/PlatformSTL.h |
| +++ b/third_party/WebKit/Source/platform/inspector_protocol/PlatformSTL.h |
| @@ -122,6 +122,7 @@ public: |
| unique_ptr() : m_ptr(nullptr) {} |
| unique_ptr(std::nullptr_t) : m_ptr(nullptr) {} |
| + unique_ptr(const unique_ptr&); |
| unique_ptr(unique_ptr&&); |
| template <typename U, typename = typename enable_if<is_convertible<U*, T*>::value>::type> unique_ptr(unique_ptr<U>&&); |
| @@ -146,7 +147,7 @@ public: |
| unique_ptr& operator=(std::nullptr_t) { reset(); return *this; } |
| - |
| + unique_ptr& operator=(const unique_ptr&); |
| unique_ptr& operator=(unique_ptr&&); |
| template <typename U> unique_ptr& operator=(unique_ptr<U>&&); |
| @@ -157,6 +158,12 @@ public: |
| explicit unique_ptr(PtrType ptr) : m_ptr(ptr) {} |
| private: |
| + PtrType internalRelease() const |
|
pfeldman
2016/07/15 23:14:07
How is this different from release()
eostroukhov-old
2016/07/15 23:45:53
This is an ugly hack - this method is actually con
|
| + { |
| + PtrType ptr = m_ptr; |
| + m_ptr = nullptr; |
| + return ptr; |
| + } |
| // We should never have two unique_ptrs for the same underlying object |
| // (otherwise we'll get double-destruction), so these equality operators |
| @@ -172,7 +179,7 @@ private: |
| return false; |
| } |
| - PtrType m_ptr; |
| + mutable PtrType m_ptr; |
| }; |
| @@ -198,6 +205,11 @@ template <typename T> inline typename unique_ptr<T>::ValueType& unique_ptr<T>::o |
| return m_ptr[i]; |
| } |
| +template <typename T> inline unique_ptr<T>::unique_ptr(const unique_ptr<T>& o) |
| + : m_ptr(o.internalRelease()) |
| +{ |
| +} |
| + |
| template <typename T> inline unique_ptr<T>::unique_ptr(unique_ptr<T>&& o) |
| : m_ptr(o.release()) |
| { |
| @@ -210,6 +222,16 @@ template <typename U, typename> inline unique_ptr<T>::unique_ptr(unique_ptr<U>&& |
| static_assert(!is_array<T>::value, "pointers to array must never be converted"); |
| } |
| +template <typename T> inline unique_ptr<T>& unique_ptr<T>::operator=(const unique_ptr<T>& o) |
| +{ |
| + PtrType ptr = m_ptr; |
|
pfeldman
2016/07/15 23:14:07
Looks like the same code as below, reuse?
eostroukhov-old
2016/07/15 23:45:53
Done.
|
| + m_ptr = o.internalRelease(); |
| + DCHECK(!ptr || m_ptr != ptr); |
| + OwnedPtrDeleter<T>::deletePtr(ptr); |
| + |
| + return *this; |
| +} |
| + |
| template <typename T> inline unique_ptr<T>& unique_ptr<T>::operator=(unique_ptr<T>&& o) |
| { |
| PtrType ptr = m_ptr; |