Which part of the standard says that this is wrong?
That would be ยง14.3.1/2 from the 2003 C++ Standard:
A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.
How can make this code work?
Don’t use a local type as a template argument.
Note that this restriction has been lifted in C++11, so using that language standard you are able to use a local type as a template argument.