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

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

Issue 2723083004: Remove a scoped_refptr<>::swap overload (Closed)
Patch Set: avoid to use std::swap Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/filters/ffmpeg_audio_decoder.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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 scoped_refptr<T>(std::move(r)).swap(*this); 347 scoped_refptr<T>(std::move(r)).swap(*this);
348 return *this; 348 return *this;
349 } 349 }
350 350
351 template <typename U> 351 template <typename U>
352 scoped_refptr<T>& operator=(scoped_refptr<U>&& r) { 352 scoped_refptr<T>& operator=(scoped_refptr<U>&& r) {
353 scoped_refptr<T>(std::move(r)).swap(*this); 353 scoped_refptr<T>(std::move(r)).swap(*this);
354 return *this; 354 return *this;
355 } 355 }
356 356
357 void swap(T** pp) {
358 T* p = ptr_;
359 ptr_ = *pp;
360 *pp = p;
361 }
362
363 void swap(scoped_refptr<T>& r) { 357 void swap(scoped_refptr<T>& r) {
364 swap(&r.ptr_); 358 T* tmp = ptr_;
359 ptr_ = r.ptr_;
360 r.ptr_ = tmp;
365 } 361 }
366 362
367 explicit operator bool() const { return ptr_ != nullptr; } 363 explicit operator bool() const { return ptr_ != nullptr; }
368 364
369 template <typename U> 365 template <typename U>
370 bool operator==(const scoped_refptr<U>& rhs) const { 366 bool operator==(const scoped_refptr<U>& rhs) const {
371 return ptr_ == rhs.get(); 367 return ptr_ == rhs.get();
372 } 368 }
373 369
374 template <typename U> 370 template <typename U>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) { 451 bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) {
456 return !operator==(null, rhs); 452 return !operator==(null, rhs);
457 } 453 }
458 454
459 template <typename T> 455 template <typename T>
460 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { 456 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) {
461 return out << p.get(); 457 return out << p.get();
462 } 458 }
463 459
464 #endif // BASE_MEMORY_REF_COUNTED_H_ 460 #endif // BASE_MEMORY_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698