A static analysis tool I'm using prompts me that I need to std::forward the argument of the following function down the call chain:
template<typename T, std::size_t size>
constexpr void f(T (&& arr)[size]) { /* linter: use std::forward on 'arr' here */ }
as it identifies the function parameter type as a forwarding reference.
A simple test on several compilers show, however, that this is not a forwarding reference. The following example
void g() {
int a[3]{1, 2, 3};
f(a); // #1
}
is rejected at #1 (DEMO), explicitly pointing our that the function parameter is an rvalue reference:
error: cannot bind rvalue reference of type 'int (&&)[3]' to lvalue of type 'int [3]'
Question
- What language rules governs that
T&&in a templated array-by-&&function argument as infabove is not a forwarding reference?