Support for templates

Does the Arduino compiler support templates? (I’m using ver 1.0.3)

I get the following error message when compiling the attached code ???
“UsingMax:4: error: ‘T’ does not name a type”

Thanks for any comment.

#include <Arduino.h>

template<class T>
T kmax(T x, T y) {
   return(x > y) ? x : y;
}   

void setup() {
   Serial.begin(9600);
   Serial.println(kmax(25,9));
}
void loop() {}

Its a feature of the IDE pre processing.

Try this:

#include <Arduino.h>

template<class T>
T kmax(T x, T y) throw(){
   return(x > y) ? x : y;
}   

void setup() {
   Serial.begin(9600);
   Serial.println(kmax(25,9));
}
void loop() {}

Long story short, the throw() tricks the IDE and it doesn’t produce a prototype. It incorrectly prototypes templates. My throw() trick or adding a prototype manually will fix the issue.

I have written some articles on this if you’re interested:

Thanks pYro_65. That worked! Very helpful.

I'll spend more time with the articles. No telling what else I will learn!