fork(1) download
  1. #include<iostream>
  2.  
  3. template<unsigned int X, unsigned int N>
  4. struct Power
  5. {
  6. static const unsigned int value = X * Power<X,N-1>::value;
  7. };
  8.  
  9. template<unsigned int X>
  10. struct Power<X,0>
  11. {
  12. static const unsigned int value = 1;
  13. };
  14.  
  15. int main ()
  16. {
  17. std::cout << "Power<5,4> = " << Power<5,4>::value << "\n";
  18. }
  19.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
Power<5,4> = 625