aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwiberg <kwiberg@webrtc.org>2016-01-12 07:24:19 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-12 15:24:27 +0000
commit36220ae24f8f5d34b660d6c4c91dd4260886dcb9 (patch)
tree82a31807ea32622f225486e71d2945da70cbd624
parentd20e6513272f2da5c91cb6d73efe79cb27e645cf (diff)
downloadwebrtc-36220ae24f8f5d34b660d6c4c91dd4260886dcb9.tar.gz
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}
-rw-r--r--webrtc/base/buffer.h6
-rw-r--r--webrtc/base/buffer_unittest.cc4
-rw-r--r--webrtc/base/scoped_ptr.h11
-rw-r--r--webrtc/system_wrappers/include/scoped_vector.h7
-rw-r--r--webrtc/system_wrappers/source/scoped_vector_unittest.cc12
5 files changed, 29 insertions, 11 deletions
diff --git a/webrtc/base/buffer.h b/webrtc/base/buffer.h
index bf2e9f3c93..ff9bb73d3f 100644
--- a/webrtc/base/buffer.h
+++ b/webrtc/base/buffer.h
@@ -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);
}
diff --git a/webrtc/base/buffer_unittest.cc b/webrtc/base/buffer_unittest.cc
index f1ae6b8676..0b93b9b56e 100644
--- a/webrtc/base/buffer_unittest.cc
+++ b/webrtc/base/buffer_unittest.cc
@@ -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);
diff --git a/webrtc/base/scoped_ptr.h b/webrtc/base/scoped_ptr.h
index 3f1a87a73c..d6aedfc198 100644
--- a/webrtc/base/scoped_ptr.h
+++ b/webrtc/base/scoped_ptr.h
@@ -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.
diff --git a/webrtc/system_wrappers/include/scoped_vector.h b/webrtc/system_wrappers/include/scoped_vector.h
index 284f437259..15c3380c8c 100644
--- a/webrtc/system_wrappers/include/scoped_vector.h
+++ b/webrtc/system_wrappers/include/scoped_vector.h
@@ -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]; }
diff --git a/webrtc/system_wrappers/source/scoped_vector_unittest.cc b/webrtc/system_wrappers/source/scoped_vector_unittest.cc
index b049e4a340..6e38f01f0b 100644
--- a/webrtc/system_wrappers/source/scoped_vector_unittest.cc
+++ b/webrtc/system_wrappers/source/scoped_vector_unittest.cc
@@ -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);