fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. template <uint_fast64_t MAX_RAND>
  7. struct RandomLimit
  8. {
  9. static const uint_fast64_t steps =
  10. RAND_MAX >= MAX_RAND ?
  11. 1 :
  12. RandomLimit<MAX_RAND / ((uint_fast64_t)RAND_MAX + 1)>::steps + 1;
  13. };
  14.  
  15. int main() {
  16. cout << RandomLimit<10>::steps << endl;
  17. cout << RandomLimit<1000000>::steps << endl;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘const uint_fast64_t RandomLimit<0ul>::steps’:
prog.cpp:12:74:   recursively required from ‘const uint_fast64_t RandomLimit<0ul>::steps’
prog.cpp:12:74:   required from ‘const uint_fast64_t RandomLimit<10ul>::steps’
prog.cpp:16:27:   required from here
prog.cpp:12:74: fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)
             RandomLimit<MAX_RAND / ((uint_fast64_t)RAND_MAX + 1)>::steps + 1;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
compilation terminated.
stdout
Standard output is empty