Reading C++ Templates: The Complete Guide and it says
Note that templates cannot be declared in a function
It does not give e
My guess is that it is hard to implement, that's why it is not allowed (in Standard C++03). Writing class templates outside of functions is an acceptable solution from the other hand.