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:
kwiberg
2016-01-07 05:52:04 -08:00
committed by Commit bot
parent a46a4c92d0
commit cea7c2f783
5 changed files with 20 additions and 23 deletions

View File

@ -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]; }