pastebin

Paste Search Dynamic
Recent pastes
factorial
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <unsigned n>
  5. struct factorial : std::integral_constant<int,n * factorial<n-1>::value> {};
  6.  
  7. template <>
  8. struct factorial<0> : std::integral_constant<int,3> {};
  9.  
  10. int main() {
  11.   std::cout << factorial<10>::value;  // constexpr (no calculations on runtime)
  12.   return 0;
  13. }
Parsed in 0.005 seconds