From 6b89130d45b1cdedbfc5e223300f8db074ef88f4 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 16 Aug 2021 14:51:40 +0200 Subject: [PATCH] Fix array_view nested namespace. Bug: webrtc:13075 Change-Id: I4160966487b5a596ade78033081e8dc0a4e11c99 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228944 Reviewed-by: Danil Chapovalov Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#34771} --- api/array_view.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/api/array_view.h b/api/array_view.h index df365cb740..2d68f1650f 100644 --- a/api/array_view.h +++ b/api/array_view.h @@ -84,7 +84,7 @@ namespace rtc { // a pointer if fix-sized) and trivially copyable, so it's probably cheaper to // pass it by value than by const reference. -namespace impl { +namespace array_view_internal { // Magic constant for indicating that the size of an ArrayView is variable // instead of fixed. @@ -125,7 +125,7 @@ class ArrayViewBase { // Specialized base class for ArrayViews of variable size. template -class ArrayViewBase { +class ArrayViewBase { public: ArrayViewBase(T* data, size_t size) : data_(size == 0 ? nullptr : data), size_(size) {} @@ -142,10 +142,11 @@ class ArrayViewBase { size_t size_; }; -} // namespace impl +} // namespace array_view_internal -template -class ArrayView final : public impl::ArrayViewBase { +template +class ArrayView final : public array_view_internal::ArrayViewBase { public: using value_type = T; using const_iterator = const T*; @@ -153,7 +154,7 @@ class ArrayView final : public impl::ArrayViewBase { // Construct an ArrayView from a pointer and a length. template ArrayView(U* data, size_t size) - : impl::ArrayViewBase::ArrayViewBase(data, size) { + : array_view_internal::ArrayViewBase::ArrayViewBase(data, size) { RTC_DCHECK_EQ(size == 0 ? nullptr : data, this->data()); RTC_DCHECK_EQ(size, this->size()); RTC_DCHECK_EQ(!this->data(), @@ -167,7 +168,8 @@ class ArrayView final : public impl::ArrayViewBase { : ArrayView() {} ArrayView(std::nullptr_t, size_t size) : ArrayView(static_cast(nullptr), size) { - static_assert(Size == 0 || Size == impl::kArrayViewVarSize, ""); + static_assert(Size == 0 || Size == array_view_internal::kArrayViewVarSize, + ""); RTC_DCHECK_EQ(0, size); } @@ -175,7 +177,7 @@ class ArrayView final : public impl::ArrayViewBase { template ArrayView(U (&array)[N]) // NOLINT : ArrayView(array, N) { - static_assert(Size == N || Size == impl::kArrayViewVarSize, + static_assert(Size == N || Size == array_view_internal::kArrayViewVarSize, "Array size must match ArrayView size"); } @@ -208,7 +210,7 @@ class ArrayView final : public impl::ArrayViewBase { // N> when M != N. template < typename U, - typename std::enable_if::value>::type* = nullptr> ArrayView(U& u) // NOLINT : ArrayView(u.data(), u.size()) { @@ -216,7 +218,7 @@ class ArrayView final : public impl::ArrayViewBase { } template < typename U, - typename std::enable_if::value>::type* = nullptr> ArrayView(const U& u) // NOLINT(runtime/explicit) : ArrayView(u.data(), u.size()) { @@ -236,13 +238,13 @@ class ArrayView final : public impl::ArrayViewBase { // const rtc::Buffer to ArrayView. template < typename U, - typename std::enable_if::value>::type* = nullptr> ArrayView(U& u) // NOLINT : ArrayView(u.data(), u.size()) {} template < typename U, - typename std::enable_if::value>::type* = nullptr> ArrayView(const U& u) // NOLINT(runtime/explicit) : ArrayView(u.data(), u.size()) {}