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}
This commit is contained in:
Karl Wiberg
2020-02-28 10:01:18 +01:00
committed by Commit Bot
parent 6038383565
commit ff61f3a555
2 changed files with 77 additions and 2 deletions

View File

@ -213,6 +213,14 @@ class ArrayView final : public impl::ArrayViewBase<T, Size> {
: 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