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

Unified Diff: third_party/WebKit/Source/wtf/OwnPtr.h

Issue 1917193006: WTF: Make PassOwnPtr<T> move-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months 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
Index: third_party/WebKit/Source/wtf/OwnPtr.h
diff --git a/third_party/WebKit/Source/wtf/OwnPtr.h b/third_party/WebKit/Source/wtf/OwnPtr.h
index 391031ca4c7d93c088c901d09990ba9f88cbaf18..687e4ea4d90fb272c8c860b40c9b806f72bb699c 100644
--- a/third_party/WebKit/Source/wtf/OwnPtr.h
+++ b/third_party/WebKit/Source/wtf/OwnPtr.h
@@ -43,9 +43,8 @@ public:
OwnPtr() : m_ptr(nullptr) {}
OwnPtr(std::nullptr_t) : m_ptr(nullptr) {}
- // See comment in PassOwnPtr.h for why this takes a const reference.
- OwnPtr(const PassOwnPtr<T>&);
- template <typename U> OwnPtr(const PassOwnPtr<U>&, EnsurePtrConvertibleArgDecl(U, T));
+ OwnPtr(PassOwnPtr<T>&&);
+ template <typename U> OwnPtr(PassOwnPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T));
// Hash table deleted values, which are only constructed and never copied or
// destroyed.
@@ -72,9 +71,9 @@ public:
bool operator!() const { return !m_ptr; }
explicit operator bool() const { return m_ptr; }
- OwnPtr& operator=(const PassOwnPtr<T>&);
+ OwnPtr& operator=(PassOwnPtr<T>&&);
OwnPtr& operator=(std::nullptr_t) { clear(); return *this; }
- template <typename U> OwnPtr& operator=(const PassOwnPtr<U>&);
+ template <typename U> OwnPtr& operator=(PassOwnPtr<U>&&);
OwnPtr(OwnPtr&&);
template <typename U> OwnPtr(OwnPtr<U>&&);
@@ -114,13 +113,13 @@ private:
PtrType m_ptr;
};
-template <typename T> inline OwnPtr<T>::OwnPtr(const PassOwnPtr<T>& o)
+template <typename T> inline OwnPtr<T>::OwnPtr(PassOwnPtr<T>&& o)
: m_ptr(o.leakPtr())
{
}
template <typename T>
-template <typename U> inline OwnPtr<T>::OwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T))
+template <typename U> inline OwnPtr<T>::OwnPtr(PassOwnPtr<U>&& o, EnsurePtrConvertibleArgDefn(U, T))
: m_ptr(o.leakPtr())
{
static_assert(!std::is_array<T>::value, "pointers to array must never be converted");
@@ -155,7 +154,7 @@ template <typename T> inline typename OwnPtr<T>::ValueType& OwnPtr<T>::operator[
return m_ptr[i];
}
-template <typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr<T>& o)
+template <typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(PassOwnPtr<T>&& o)
{
PtrType ptr = m_ptr;
m_ptr = o.leakPtr();
@@ -165,7 +164,7 @@ template <typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr<T>
}
template <typename T>
-template <typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(const PassOwnPtr<U>& o)
+template <typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(PassOwnPtr<U>&& o)
{
static_assert(!std::is_array<T>::value, "pointers to array must never be converted");
PtrType ptr = m_ptr;
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp ('k') | third_party/WebKit/Source/wtf/PassOwnPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698