| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_MEMORY_REF_COUNTED_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_H_ |
| 6 #define BASE_MEMORY_REF_COUNTED_H_ | 6 #define BASE_MEMORY_REF_COUNTED_H_ |
| 7 | 7 |
| 8 #include <cassert> | 8 #include <cassert> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 | 10 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 scoped_refptr<T>& operator=(const scoped_refptr<T>& r) { | 324 scoped_refptr<T>& operator=(const scoped_refptr<T>& r) { |
| 325 return *this = r.ptr_; | 325 return *this = r.ptr_; |
| 326 } | 326 } |
| 327 | 327 |
| 328 template <typename U> | 328 template <typename U> |
| 329 scoped_refptr<T>& operator=(const scoped_refptr<U>& r) { | 329 scoped_refptr<T>& operator=(const scoped_refptr<U>& r) { |
| 330 return *this = r.get(); | 330 return *this = r.get(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 scoped_refptr<T>& operator=(scoped_refptr<T>&& r) { | 333 scoped_refptr<T>& operator=(scoped_refptr<T>&& r) { |
| 334 scoped_refptr<T>(r.Pass()).swap(*this); | 334 scoped_refptr<T>(std::move(r)).swap(*this); |
| 335 return *this; | 335 return *this; |
| 336 } | 336 } |
| 337 | 337 |
| 338 template <typename U> | 338 template <typename U> |
| 339 scoped_refptr<T>& operator=(scoped_refptr<U>&& r) { | 339 scoped_refptr<T>& operator=(scoped_refptr<U>&& r) { |
| 340 scoped_refptr<T>(r.Pass()).swap(*this); | 340 scoped_refptr<T>(std::move(r)).swap(*this); |
| 341 return *this; | 341 return *this; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void swap(T** pp) { | 344 void swap(T** pp) { |
| 345 T* p = ptr_; | 345 T* p = ptr_; |
| 346 ptr_ = *pp; | 346 ptr_ = *pp; |
| 347 *pp = p; | 347 *pp = p; |
| 348 } | 348 } |
| 349 | 349 |
| 350 void swap(scoped_refptr<T>& r) { | 350 void swap(scoped_refptr<T>& r) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { | 431 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { |
| 432 return !operator==(lhs, rhs); | 432 return !operator==(lhs, rhs); |
| 433 } | 433 } |
| 434 | 434 |
| 435 template <typename T> | 435 template <typename T> |
| 436 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { | 436 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { |
| 437 return out << p.get(); | 437 return out << p.get(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 #endif // BASE_MEMORY_REF_COUNTED_H_ | 440 #endif // BASE_MEMORY_REF_COUNTED_H_ |
| OLD | NEW |