Strange compiler error

It feels like I’m losing my mind. The following code will not compile in the Arduino 1.0.1 IDE. I get the error message 'U' does not name a type. What’s wrong? I know this code “does nothing.” This minimal test case illustrates a problem I’m having with a larger program.

template<typename T>
void foo() {}

template<typename U>
U bar(U v) { return v; }

void setup(){}
void loop(){}

The IDE does some preprocessing for you to add prototypes and it doesn't like templates. If you make a new tab in the IDE and name it with a .cpp extension, the IDE won't touch it. Of course, then you have to generate your own prototypes.

Thanks that fixed it. I created a header file.