This is not allowed right now. But it is supported in C ++ 0x. Current standard says 14.3.1/2
A local type, a type without a binding, an unnamed type, or a type made up of any of these types should not be used as a template argument for a template type parameter.
However, if the function is also local, there is no problem
void f() { class L {} local; struct C { static void function(L &l) {
source share