what is this kind of code?
so i found this code a while back and i cant make heads or tails of it.
template <unsigned int exponent>
inline double intpow(double base)
return intpow<exponent-1>(base) * base;
inline double intpow<0>(double base)
cout << intpow<12>(1.2345) << " == " << pow(1.2345, 12) << endl;
obviously its templates of some kind, but lines 4 and and the second function confuse me
It's template meta-programming. I was going to try and explain it myself, but the wikipedia article does a much better job.
thanks. i think i understand. so in what cases can this be useful?
Topic archived. No new replies allowed.