When you declare a template specialization, what's the difference between the syntax with (1) and without angular brackets (2).
Why the version 1 fails if an implementation (definition) of the method is not provided (like in this case) with the error: undefined reference to int f<int>(int)
while the version 2 works as expected?
template <typename T> T f(T val) {
return val;
}
template<> int f<int>(int val); // 1
template int f<int>(int val); // 2
int main() {
cout << f(555);
}
I've seen this answer but it does not explicitly descrive the difference between these different syntax.