Здравствуйте, mr_jek, Вы писали:
_>Имелась ввиду простейщая конструкция вида:
_>_>#include <cstdio>
_>template<unsigned int i> struct factorial;
_>template<> struct factorial<0> { enum { value = 1 }; };
_>template<> struct factorial<1> { enum { value = 1 }; };
_>template<unsigned int i> struct factorial { enum { value = factorial<i - 1>::value * i }; };
_>int main()
_>{
_> printf("10! = %d\n", factorial<10>::value);
_> return 0;
_>}
_>
_>простейший тест на знание шаблонов, что вам так не понравилось?
Угу... Потом пишем
int main()
{
printf("-10! = %d\n", factorial<-10>::value);
return 0;
}
[/code]
и радуемся, как загибается компилятор...