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

Unified Diff: Source/wtf/RefPtr.h

Issue 354023003: Add move constructor and assignment operator to RefPtr class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take Nico's feedback into consideration Created 6 years, 6 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
« no previous file with comments | « no previous file | Source/wtf/text/AtomicString.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/RefPtr.h
diff --git a/Source/wtf/RefPtr.h b/Source/wtf/RefPtr.h
index f640a7713070a8d5afe9dfd7513025056ce8cba7..424be1e99ad7aaa8302a93fbfb95d14fd30fbdc1 100644
--- a/Source/wtf/RefPtr.h
+++ b/Source/wtf/RefPtr.h
@@ -44,6 +44,11 @@ namespace WTF {
ALWAYS_INLINE RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { refIfNotNull(m_ptr); }
template<typename U> RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) : m_ptr(o.get()) { refIfNotNull(m_ptr); }
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ RefPtr(RefPtr&& o) : m_ptr(o.m_ptr) { o.m_ptr = 0; }
+ RefPtr& operator=(RefPtr&&);
+#endif
+
// See comments in PassRefPtr.h for an explanation of why this takes a const reference.
template<typename U> RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T));
@@ -103,6 +108,14 @@ namespace WTF {
return *this;
}
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ template<typename T> inline RefPtr<T>& RefPtr<T>::operator=(RefPtr&& o)
+ {
+ swap(o);
Mikhail 2014/06/27 07:48:44 This does not look correct, look { RefPtr<A> a = a
+ return *this;
+ }
+#endif
+
template<typename T> template<typename U> inline RefPtr<T>& RefPtr<T>::operator=(const RefPtr<U>& o)
{
RefPtr ptr = o;
« no previous file with comments | « no previous file | Source/wtf/text/AtomicString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698