For the people perhaps reading this thread who are actually interested in templates, or at least curious as to what they do, here's an example.
My old header file looked like this:
void addDebugVar(String, String&);
void addDebugVar(String, long&);
void addDebugVar(const __FlashStringHelper *, int&, int = false);
void addDebugVar(String, byte&, int = false);
void addDebugVar(String, int&, int = false);
void addDebugPin(const __FlashStringHelper *, int&);
void addDebugPin(String, byte&, int);
void addDebugPin(String, int&);
void addDebugPin(String, byte&);
void debug(String, String);
void debug(String, long);
void debug(String, byte);
void debug(const __FlashStringHelper *, int);
void debug(String, int);
void debug(String &);
void debug(byte &);
void debug(long &);
void debug(int &);
The basic pattern of the functions is:
void [function name](, ); AND
void function name;
The could be supplied as a String, or pointer to char, or F() macro, etc.
The could be any basic type, including - potentially - arrays.
The header file is obviously incomplete, as each function requires versions for the different types, at least 2 of (char * and F()) and then a version of the function for each variable type people may be using. And I don't even know all the variable types! Then there are different functions (overloaded, of course) for handling whether the variable being added is a pin or a normal variable. etc, etc, etc.
The same header file, using templates, can be written as follows:
template <typename T1, typename T2>
void addDebugVar(T1, T2);
template <typename T1, typename T2>
void addDebugPin(T1, T2);
template <typename T1, typename T2>
void debug(T1, T2);
template <typename T1>
void debug(T1);
The beauty of this new header file, is that every possible combination of type and type is generated for you, on the fly, based on usage of calls to those functions in the code. If you don't call that version of the function, it doesn't get compiled.
Very cool.
If this is old hat to you and you have a good website or ebook describing C++ templates, with examples, I really would appreciate a link!