Slap deprecation notices on Pass methods
There's no reason not to use std::move instead now that we can use the C++11 standard library. BUG=webrtc:5373 Review URL: https://codereview.webrtc.org/1531013003 Cr-Commit-Position: refs/heads/master@{#11225}
This commit is contained in:
parent
d20e651327
commit
36220ae24f
@ -15,6 +15,8 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <utility> // std::swap (C++11 and later)
|
||||
|
||||
#include "webrtc/base/deprecation.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -170,7 +172,9 @@ class Buffer {
|
||||
}
|
||||
|
||||
// b.Pass() does the same thing as std::move(b).
|
||||
Buffer&& Pass() {
|
||||
// Deprecated; remove in March 2016 (bug 5373).
|
||||
RTC_DEPRECATED Buffer&& Pass() { return DEPRECATED_Pass(); }
|
||||
Buffer&& DEPRECATED_Pass() {
|
||||
assert(IsConsistent());
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ TEST(BufferTest, TestEnsureCapacityLarger) {
|
||||
TEST(BufferTest, TestMoveConstruct) {
|
||||
Buffer buf1(kTestData, 3, 40);
|
||||
const uint8_t* data = buf1.data();
|
||||
Buffer buf2(buf1.Pass());
|
||||
Buffer buf2(buf1.DEPRECATED_Pass());
|
||||
EXPECT_EQ(buf2.size(), 3u);
|
||||
EXPECT_EQ(buf2.capacity(), 40u);
|
||||
EXPECT_EQ(buf2.data(), data);
|
||||
@ -152,7 +152,7 @@ TEST(BufferTest, TestMoveAssign) {
|
||||
Buffer buf1(kTestData, 3, 40);
|
||||
const uint8_t* data = buf1.data();
|
||||
Buffer buf2(kTestData);
|
||||
buf2 = buf1.Pass();
|
||||
buf2 = buf1.DEPRECATED_Pass();
|
||||
EXPECT_EQ(buf2.size(), 3u);
|
||||
EXPECT_EQ(buf2.capacity(), 40u);
|
||||
EXPECT_EQ(buf2.data(), data);
|
||||
|
||||
@ -90,6 +90,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/deprecation.h"
|
||||
#include "webrtc/base/template_util.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -374,7 +375,10 @@ class scoped_ptr {
|
||||
scoped_ptr& operator=(const scoped_ptr& other) = delete;
|
||||
|
||||
// Get an rvalue reference. (sp.Pass() does the same thing as std::move(sp).)
|
||||
scoped_ptr&& Pass() { return std::move(*this); }
|
||||
// Deprecated; remove in March 2016 (bug 5373).
|
||||
RTC_DEPRECATED scoped_ptr&& Pass() {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
// Reset. Deletes the currently owned object, if any.
|
||||
// Then takes ownership of a new object, if given.
|
||||
@ -507,7 +511,10 @@ class scoped_ptr<T[], D> {
|
||||
scoped_ptr& operator=(const scoped_ptr& other) = delete;
|
||||
|
||||
// Get an rvalue reference. (sp.Pass() does the same thing as std::move(sp).)
|
||||
scoped_ptr&& Pass() { return std::move(*this); }
|
||||
// Deprecated; remove in March 2016 (bug 5373).
|
||||
RTC_DEPRECATED scoped_ptr&& Pass() {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
// Reset. Deletes the currently owned array, if any.
|
||||
// Then takes ownership of a new object, if given.
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/deprecation.h"
|
||||
#include "webrtc/system_wrappers/include/stl_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -56,7 +57,11 @@ 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 std::move(*this); }
|
||||
// Deprecated; remove in March 2016 (bug 5373).
|
||||
RTC_DEPRECATED ScopedVector&& Pass() { return DEPRECATED_Pass(); }
|
||||
ScopedVector&& DEPRECATED_Pass() {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
reference operator[](size_t index) { return v_[index]; }
|
||||
const_reference operator[](size_t index) const { return v_[index]; }
|
||||
|
||||
@ -221,7 +221,8 @@ TEST(ScopedVectorTest, MoveConstruct) {
|
||||
EXPECT_FALSE(scoped_vector.empty());
|
||||
EXPECT_TRUE(watcher.IsWatching(scoped_vector.back()));
|
||||
|
||||
ScopedVector<LifeCycleObject> scoped_vector_copy(scoped_vector.Pass());
|
||||
ScopedVector<LifeCycleObject> scoped_vector_copy(
|
||||
scoped_vector.DEPRECATED_Pass());
|
||||
EXPECT_TRUE(scoped_vector.empty());
|
||||
EXPECT_FALSE(scoped_vector_copy.empty());
|
||||
EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back()));
|
||||
@ -241,7 +242,7 @@ TEST(ScopedVectorTest, MoveAssign) {
|
||||
EXPECT_FALSE(scoped_vector.empty());
|
||||
EXPECT_TRUE(watcher.IsWatching(scoped_vector.back()));
|
||||
|
||||
scoped_vector_assign = scoped_vector.Pass();
|
||||
scoped_vector_assign = scoped_vector.DEPRECATED_Pass();
|
||||
EXPECT_TRUE(scoped_vector.empty());
|
||||
EXPECT_FALSE(scoped_vector_assign.empty());
|
||||
EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back()));
|
||||
@ -273,10 +274,11 @@ class DeleteCounter {
|
||||
template <typename T>
|
||||
class PassThru {
|
||||
public:
|
||||
explicit PassThru(ScopedVector<T> scoper) : scoper_(scoper.Pass()) {}
|
||||
explicit PassThru(ScopedVector<T> scoper)
|
||||
: scoper_(scoper.DEPRECATED_Pass()) {}
|
||||
|
||||
ScopedVector<T> Run() {
|
||||
return scoper_.Pass();
|
||||
return scoper_.DEPRECATED_Pass();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -288,7 +290,7 @@ TEST(ScopedVectorTest, Passed) {
|
||||
ScopedVector<DeleteCounter> deleter_vector;
|
||||
deleter_vector.push_back(new DeleteCounter(&deletes));
|
||||
EXPECT_EQ(0, deletes);
|
||||
PassThru<DeleteCounter> pass_thru(deleter_vector.Pass());
|
||||
PassThru<DeleteCounter> pass_thru(deleter_vector.DEPRECATED_Pass());
|
||||
EXPECT_EQ(0, deletes);
|
||||
ScopedVector<DeleteCounter> result = pass_thru.Run();
|
||||
EXPECT_EQ(0, deletes);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user