I recently learnt about parameter packs. Then I wrote the following program that compiles with msvc but not with clang and gcc. Live demo:
#include <array>
template<typename T, std::size_t... rows> int func(T (&arr...)[rows])
{
return 5;
}
int main()
{
int arr[2][3][4];
auto a = func(arr);
}
As can be seen in the above demo, msvc compiles it but gcc says:
<source>:3:56: error: 'arr' was not declared in this scope
3 | template<typename T, std::size_t... rows> int func(T (&arr...)[rows])
| ^~~
<source>:3:69: error: parameter packs not expanded with '...':
3 | template<typename T, std::size_t... rows> int func(T (&arr...)[rows])
| ^
<source>:3:69: note: 'rows'
<source>:6:2: error: expected ';' before 'int'
6 | }
| ^
| ;
7 | int main()
| ~~~
Compiler returned: 1
I want to know which compiler is correct and the reason.