Case 1)
template <typename T>
void f(const T& x)
{
f(x.next);
}
void f(const chain<last>&)
{
}
You need to make sure that it #2is a specialized template #1by specifying template<>abovevoid f(const chain<last>&) // #2
Without template<> void f(const chain<last>&)will be interpreted as overload f. Therefore, the call f(x.next);will be poorly formed due to the missing announcement void f(const chain<last>&).
.
:
1)
template <typename T>
void f(const T& x)
{
f(x.next);
}
template<>
void f(const chain<last>&)
{
}
2)
void f(const chain<last>&);
template <typename T>
void f(const T& x)
{
f(x.next);
}
void f(const chain<last>&)
{
}
2)
void f(const chain<last>&)
{
}
template <typename T>
void f(const T& x)
{
f(x.next);
}