C++ code that is written with template parameters. In particular, allows data types and software algorithms to be easily changed.
// power() is templatized by P and T
template<int P, typename T>
T power(int a)
{
T val = 1;
for (int i=0; i<P; i++)
val = val * val;
return val;
}
10👍 1👎