On 20 Sep 2006 08:35:28 -0700 in comp.lang.c++, "shuisheng"
<> wrote,
>I got some compiler error for the second function Power<Type, 0> to
>particularize the Power function.
By the way, it's called "specialize" instead of "particularize".
Specialization of function templates is not allowed, only of class
templates. In most cases, ordinary function overloading serves
instead of specialization. Here is an example with class templates:
#include <iostream>
template<class Type, size_t order>
class p {
public: static inline Type Power(Type base)
{
return base * p<Type, order-1>:

ower(base);
}
};
template<class Type>
class p<Type,0> {
public: static inline Type Power(Type base)
{
return 1;
}
};
int main()
{
int b = 5;
std::cout << p<int,3>:

ower(b);
}