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

Unified Diff: webrtc/base/array_view.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/array_view.h
diff --git a/webrtc/base/array_view.h b/webrtc/base/array_view.h
index 725a2d79d6f6fcc055e787dc7627889b30f74569..59e0395199f152a5e405d3cb1b53bc3edfd7966d 100644
--- a/webrtc/base/array_view.h
+++ b/webrtc/base/array_view.h
@@ -11,37 +11,11 @@
#ifndef WEBRTC_BASE_ARRAY_VIEW_H_
#define WEBRTC_BASE_ARRAY_VIEW_H_
-#include <type_traits>
-
#include "webrtc/base/checks.h"
+#include "webrtc/base/type_traits.h"
namespace rtc {
-namespace internal {
-
-// (Internal; please don't use outside this file.) Determines if the given
-// class has zero-argument .data() and .size() methods whose return values are
-// convertible to T* and size_t, respectively.
-template <typename DS, typename T>
-class HasDataAndSize {
- private:
- template <
- typename C,
- typename std::enable_if<
- std::is_convertible<decltype(std::declval<C>().data()), T*>::value &&
- std::is_convertible<decltype(std::declval<C>().size()),
- size_t>::value>::type* = nullptr>
- static int Test(int);
-
- template <typename>
- static char Test(...);
-
- public:
- static constexpr bool value = std::is_same<decltype(Test<DS>(0)), int>::value;
-};
-
-} // namespace internal
-
// Many functions read from or write to arrays. The obvious way to do this is
// to use two arguments, a pointer to the first element and an element count:
//
@@ -122,9 +96,9 @@ class ArrayView final {
// or ArrayView<const T>, const std::vector<T> to ArrayView<const T>, and
// rtc::Buffer to ArrayView<uint8_t> (with the same const behavior as
// std::vector).
- template <typename U,
- typename std::enable_if<
- internal::HasDataAndSize<U, T>::value>::type* = nullptr>
+ template <
+ typename U,
+ typename std::enable_if<HasDataAndSize<U, T>::value>::type* = nullptr>
ArrayView(U& u) : ArrayView(u.data(), u.size()) {}
// Indexing, size, and iteration. These allow mutation even if the ArrayView

Powered by Google App Engine
This is Rietveld 408576698