template <int N>
void foo(const long (&arr)[N]) {}
void bar() {
foo({1,2,3});
}
<source>: In function 'void bar()':
<source>:4:16: error: no matching function for call to 'foo(<brace-enclosed initializer list>)'
foo({1,2,3});
^
<source>:2:6: note: candidate: 'template<int N> void foo(const long int (&)[N])'
void foo(const long (&arr)[N]) {}
^~~
<source>:2:6: note: template argument deduction/substitution failed:
<source>:4:16: note: mismatched types 'long int' and 'int'
foo({1,2,3});
^
Compiler returned: 1
Compiler explorer link:
https://godbolt.org/g/rjqaq3
Which compiler is correct? The Clang behavior seems to be more desirable.
template<int N> void foo_(long, long, long);
void bar() { foo_<3>(1, 2, 3); }
template<class T, int N> void h(T x, decltype(x) const(&arr)[N]);
int main() { h(1l, {1, 2, 3}); }
template<int N, class T> void h_(T x, decltype(x), decltype(x), decltype(x));
int main() { h_<3>(1l, 1, 2, 3); }