fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template<typename T, T b, T e>
  5. struct constexpr_pow : std::integral_constant<T, b*constexpr_pow<T, b, e-1>::value>
  6. {
  7. };
  8. template<typename T, T b>
  9. struct constexpr_pow<T, b, 1> : std::integral_constant<T, b>
  10. {
  11. };
  12.  
  13. int main()
  14. {
  15. std::cout << constexpr_pow<unsigned, 2, 8>::value << std::endl;
  16. }
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:9:8: error: type ‘T’ of template argument ‘1’ depends on a template parameter
 struct constexpr_pow<T, b, 1> : std::integral_constant<T, b>
        ^
stdout
Standard output is empty