Search Results

Search found 1 results on 1 pages for 'user519882'.

Page 1/1 | 1 

  • Printing factorial at compile time in C++

    - by user519882
    template<unsigned int n> struct Factorial { enum { value = n * Factorial<n-1>::value}; }; template<> struct Factorial<0> { enum {value = 1}; }; int main() { std::cout << Factorial<5>::value; std::cout << Factorial<10>::value; } above program computes factorial value during compile time. I want to print factorial value at compile time rather than at runtime using cout. How can we achive printing the factorial value at compile time? I am using VS2009. Thanks!

    Read the article

1