The following code fail to compile because function g
but I don't know why.
template <int N>
struct A{
template <int n>
int f() {return n;}
};
template <int N>
int g(A<N>& a)
{
return a.f<10>();
}
int main()
{
A<1> a;
g(a);
}
You can compile it in: https://godbolt.org/z/sysQwj
The error is
error: expected primary-expression before ')' token return a.f<10>();
In instantiation of 'int g(A<N>&) [with int N = 1]':
error: invalid operands of types '<unresolved overloaded function type>'
and 'int' to binary 'operator<': return a.f<10>();