 Chromium Code Reviews
 Chromium Code Reviews Issue 354023003:
  Add move constructor and assignment operator to RefPtr class  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 354023003:
  Add move constructor and assignment operator to RefPtr class  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| 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; |