Fix + test copying of fixed-sized ArrayView rvalues
Previously, only lvalues were tested, and only lvalues worked.
Bug: webrtc:11389
Change-Id: I524e9d63e0840c3ba274dbe2062d78f72d79019d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169347
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30644}
diff --git a/api/array_view.h b/api/array_view.h
index f7130dc..a66369a 100644
--- a/api/array_view.h
+++ b/api/array_view.h
@@ -213,6 +213,14 @@
: ArrayView(u.data(), u.size()) {
static_assert(U::size() == Size, "Sizes must match exactly");
}
+ template <
+ typename U,
+ typename std::enable_if<Size != impl::kArrayViewVarSize &&
+ HasDataAndSize<U, T>::value>::type* = nullptr>
+ ArrayView(const U& u) // NOLINT(runtime/explicit)
+ : ArrayView(u.data(), u.size()) {
+ static_assert(U::size() == Size, "Sizes must match exactly");
+ }
// (Only if size is variable.) Construct an ArrayView from any type U that
// has a size() method whose return value converts implicitly to size_t, and