I have used an example from
http://en.wikipedia.org/wiki/Template_metaprogramming
const unsigned long long y = Factorial<0>::value; // == 1
I understand the compiler can do a type check but I did not think you could put 0 where the type should be and it would be taken as the value.
Could someone explain how this is working ?
Thanks
The problem is the assumption: it is not “where the type should be”. Rather, it is “where the template argument may be specified”.
In this case, there is a non-type template argument.
It works, simply because it is a different feature than type template arguments.
It is just that way. I can recommend C++ Templates: the Complete Guide or many other books on that list to read up on the basics of C++ templates.