Replace manual casting to rvalue reference with calls to std::move
Review URL: https://codereview.webrtc.org/1570473002 Cr-Commit-Position: refs/heads/master@{#11163}
This commit is contained in:
@ -43,9 +43,7 @@ class ScopedVector {
|
||||
~ScopedVector() { clear(); }
|
||||
|
||||
// Move construction and assignment.
|
||||
ScopedVector(ScopedVector&& other) {
|
||||
*this = static_cast<ScopedVector&&>(other);
|
||||
}
|
||||
ScopedVector(ScopedVector&& other) { *this = std::move(other); }
|
||||
ScopedVector& operator=(ScopedVector&& other) {
|
||||
std::swap(v_, other.v_); // The arguments are std::vectors, so std::swap
|
||||
// is the one that we want.
|
||||
@ -58,7 +56,7 @@ class ScopedVector {
|
||||
ScopedVector& operator=(const ScopedVector& other) = delete;
|
||||
|
||||
// Get an rvalue reference. (sv.Pass() does the same thing as std::move(sv).)
|
||||
ScopedVector&& Pass() { return static_cast<ScopedVector&&>(*this); }
|
||||
ScopedVector&& Pass() { return std::move(*this); }
|
||||
|
||||
reference operator[](size_t index) { return v_[index]; }
|
||||
const_reference operator[](size_t index) const { return v_[index]; }
|
||||
|
||||
Reference in New Issue
Block a user