Reading C++ Templates: The Complete Guide and it says
Note that templates cannot be declared in a function
It does not give e
It means you cannot do something like the following
void foo()
{
template //Error
T something;
}
Template declarations are only permitted at global, namespace, or class scope. :)
What is the reasoning behind it?
It is not allowed because the Standard says so .
ISO C++-98 (Section 14.2)
A template declaration can appear only as a namespace or class scope declaration.
Does that make sense?