Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: webrtc/base/buffer.h

Issue 2293983002: rtc::Buffer: Let SetData and AppendData accept anything with .data() and .size() (Closed)
Patch Set: Use rtc::HasDataAndSize (née rtc::internal::HasDataAndSize) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/buffer.h
diff --git a/webrtc/base/buffer.h b/webrtc/base/buffer.h
index e9f7cfac1058828ce555e528b9dc601daae876ec..6ae49f7a8f74e07816d362f5f1032b043f5f1c68 100644
--- a/webrtc/base/buffer.h
+++ b/webrtc/base/buffer.h
@@ -19,6 +19,7 @@
#include "webrtc/base/array_view.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/type_traits.h"
namespace rtc {
@@ -197,7 +198,12 @@ class BufferT {
SetData(array, N);
}
- void SetData(const BufferT& buf) { SetData(buf.data(), buf.size()); }
+ template <typename W,
+ typename std::enable_if<
+ HasDataAndSize<const W, const T>::value>::type* = nullptr>
+ void SetData(const W& w) {
+ SetData(w.data(), w.size());
+ }
// Replace the data in the buffer with at most |max_elements| of data, using
// the function |setter|, which should have the following signature:
@@ -239,7 +245,12 @@ class BufferT {
AppendData(array, N);
}
- void AppendData(const BufferT& buf) { AppendData(buf.data(), buf.size()); }
+ template <typename W,
+ typename std::enable_if<
+ HasDataAndSize<const W, const T>::value>::type* = nullptr>
+ void AppendData(const W& w) {
+ AppendData(w.data(), w.size());
+ }
template <typename U,
typename std::enable_if<
« no previous file with comments | « webrtc/base/base.gyp ('k') | webrtc/base/buffer_unittest.cc » ('j') | webrtc/base/type_traits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698