Templates - whut?

I decided to tinker with templates and, as usual, am getting nowhere. I copied this snippet below and jiggered it to - I thought - work in Arduinoland. It doesn’t. The error given is : ‘T’ does not name a type.

Guidance?

/*
   http://www.cplusplus.com/doc/oldtutorial/templates/
*/

template <class T> 
T GetMax (T a, T b) {  // error in this line
  T result;
  result = (a > b) ? a : b;
  return (result);
}

void setup() {
  int i = 5, j = 6, k;
  long l = 10, m = 5, n;
  k = GetMax<int>(i, j);
  n = GetMax<long>(l, m);
  //  cout << k << endl;
  //  cout << n << endl;
}

void loop() {
  // put your main code here, to run repeatedly:
}

Unfortunately, using templates in .ino files only works if the signature is all on one line. Try this:

/*
   http://www.cplusplus.com/doc/oldtutorial/templates/
*/

template <class T>T GetMax (T a, T b) {  // error in this line
  T result;
  result = (a > b) ? a : b;
  return (result);
}

void setup() {
  int i = 5, j = 6, k;
  long l = 10, m = 5, n;
  k = GetMax<int>(i, j);
  n = GetMax<long>(l, m);
  //  cout << k << endl;
  //  cout << n << endl;
}

void loop() {
  // put your main code here, to run repeatedly:
}

If you want to split the signature across two lines you need to put it in a .h file.

Did the trick. Thank you!