| Index: webrtc/api/array_view.h
|
| diff --git a/webrtc/rtc_base/array_view.h b/webrtc/api/array_view.h
|
| similarity index 92%
|
| copy from webrtc/rtc_base/array_view.h
|
| copy to webrtc/api/array_view.h
|
| index afc69995ae8d9cbc1cd72a56c28a78326549d964..c97d388cc947d327b808efcc113b99a037a85108 100644
|
| --- a/webrtc/rtc_base/array_view.h
|
| +++ b/webrtc/api/array_view.h
|
| @@ -8,14 +8,20 @@
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
|
|
| -#ifndef WEBRTC_RTC_BASE_ARRAY_VIEW_H_
|
| -#define WEBRTC_RTC_BASE_ARRAY_VIEW_H_
|
| +#ifndef WEBRTC_API_ARRAY_VIEW_H_
|
| +#define WEBRTC_API_ARRAY_VIEW_H_
|
| +
|
| +#include <algorithm>
|
| +#include <type_traits>
|
|
|
| #include "webrtc/rtc_base/checks.h"
|
| #include "webrtc/rtc_base/type_traits.h"
|
|
|
| namespace rtc {
|
|
|
| +// tl;dr: rtc::ArrayView is the same thing as gsl::span from the Guideline
|
| +// Support Library.
|
| +//
|
| // 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:
|
| //
|
| @@ -155,7 +161,8 @@ class ArrayView final : public impl::ArrayViewBase<T, Size> {
|
| // Construct an empty ArrayView. Note that fixed-size ArrayViews of size > 0
|
| // cannot be empty.
|
| ArrayView() : ArrayView(nullptr, 0) {}
|
| - ArrayView(std::nullptr_t) : ArrayView() {}
|
| + ArrayView(std::nullptr_t) // NOLINT
|
| + : ArrayView() {}
|
| ArrayView(std::nullptr_t, size_t size)
|
| : ArrayView(static_cast<T*>(nullptr), size) {
|
| static_assert(Size == 0 || Size == impl::kArrayViewVarSize, "");
|
| @@ -164,7 +171,8 @@ class ArrayView final : public impl::ArrayViewBase<T, Size> {
|
|
|
| // Construct an ArrayView from an array.
|
| template <typename U, size_t N>
|
| - ArrayView(U (&array)[N]) : ArrayView(array, N) {
|
| + ArrayView(U (&array)[N]) // NOLINT
|
| + : ArrayView(array, N) {
|
| static_assert(Size == N || Size == impl::kArrayViewVarSize,
|
| "Array size must match ArrayView size");
|
| }
|
| @@ -176,11 +184,12 @@ class ArrayView final : public impl::ArrayViewBase<T, Size> {
|
| // N>, but not the other way around. We also don't allow conversion from
|
| // ArrayView<T> to ArrayView<T, N>, or from ArrayView<T, M> to ArrayView<T,
|
| // N> when M != N.
|
| - template <typename U,
|
| - typename std::enable_if<
|
| - Size != impl::kArrayViewVarSize &&
|
| - HasDataAndSize<U, T>::value>::type* = nullptr>
|
| - ArrayView(U& u) : ArrayView(u.data(), u.size()) {
|
| + template <
|
| + typename U,
|
| + typename std::enable_if<Size != impl::kArrayViewVarSize &&
|
| + HasDataAndSize<U, T>::value>::type* = nullptr>
|
| + ArrayView(U& u) // NOLINT
|
| + : ArrayView(u.data(), u.size()) {
|
| static_assert(U::size() == Size, "Sizes must match exactly");
|
| }
|
|
|
| @@ -199,7 +208,8 @@ class ArrayView final : public impl::ArrayViewBase<T, Size> {
|
| typename U,
|
| typename std::enable_if<Size == impl::kArrayViewVarSize &&
|
| HasDataAndSize<U, T>::value>::type* = nullptr>
|
| - ArrayView(U& u) : ArrayView(u.data(), u.size()) {}
|
| + ArrayView(U& u) // NOLINT
|
| + : ArrayView(u.data(), u.size()) {}
|
|
|
| // Indexing and iteration. These allow mutation even if the ArrayView is
|
| // const, because the ArrayView doesn't own the array. (To prevent mutation,
|
| @@ -250,4 +260,4 @@ inline ArrayView<T> MakeArrayView(T* data, size_t size) {
|
|
|
| } // namespace rtc
|
|
|
| -#endif // WEBRTC_RTC_BASE_ARRAY_VIEW_H_
|
| +#endif // WEBRTC_API_ARRAY_VIEW_H_
|
|
|