As titled, why is the template instantiation in the main function wrong? I use Clang++ with flag "-std=c++2a". Did I use anything in a wrong way here?
template<int, int>
void f(int) { std::cout << "int"; };
template<class T>
void g() { // dependent-name.
f<0, T()>(0);
}
int main() {
g<int>(); // wrong here, why?
}
Error messages from Clang:
test.cc:41:3: error: no matching function for call to 'f'
f<0, T()>(0);
^~~~~~~~~
test.cc:48:3: note: in instantiation of function template specialization 'g<int>' requested here
g<int>(); // "int";
^
test.cc:35:6: note: candidate template ignored: invalid explicitly-specified argument for 2nd
template parameter
void f(int) { std::cout << "int"; };
^
1 error generated.