• François Degros's avatar
    Unified scoped_refptr's assignment operators. · 017f0cee
    François Degros authored
    Replaced several of scoped_refptr's assignment operators by a unified assignment
    operator. This works beautifully in tandem with scoped_refptr's different
    constructors, and it removes some duplicated and tricky code. It is exception
    safe, and works fine in case of self assignment.
    
    We still need to keep operator=(T*), despite the implicit conversion constructor
    scoped_refptr(T*). There is code assigning rtc::scoped_refptr<T> to
    scoped_refptr<T>, and we want to keep this code compiling and working as is.
    rtc::scoped_refptr<T> has an implicit conversion operator to T*. C++ allows one
    implicit conversion, but not two, to be chained in a row.
    
    Marked scoped_refptr's move and swap operations as noexcept. This allows
    std::vector<scoped_refptr<T>> to use scoped_refptr's more efficient move
    operations instead of copy operations. This avoids extraneous calls to
    T::AddRef() and T::Release() when vector is reallocating its internal buffer.
    
    Change-Id: Id6f360f8acab827133fe5bef829a7a2e308b87fd
    Reviewed-on: https://chromium-review.googlesource.com/802338Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Commit-Queue: François Degros <fdegros@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#524008}
    017f0cee
ref_counted_unittest.cc 19.5 KB