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

Side by Side Diff: base/memory/ref_counted.h

Issue 1479473002: base: Use std::move() instead of Pass() for real movable types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: basepass: missing-include Created 5 years 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 unified diff | Download patch
« no previous file with comments | « base/json/json_writer_unittest.cc ('k') | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « base/json/json_writer_unittest.cc ('k') | base/memory/ref_counted_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698