fork download
  1. #include <cstdint>
  2.  
  3. template<uint64_t Cur, uint64_t Goal>
  4. struct adder{
  5. static uint64_t const sub_goal = (Cur + Goal) / 2;
  6. static uint64_t const tmp = adder<Cur, sub_goal>::value;
  7. static uint64_t const value = tmp + adder<sub_goal+1, Goal>::value;
  8. };
  9.  
  10. template<uint64_t Goal>
  11. struct adder<Goal, Goal>{
  12. static uint64_t const value = Goal;
  13. };
  14.  
  15. template<uint64_t Start>
  16. struct sum_from{
  17. template<uint64_t Goal>
  18. struct to{
  19. template<uint64_t N>
  20. struct equals;
  21.  
  22. typedef equals<adder<Start, Goal>::value> result;
  23. };
  24. };
  25.  
  26. int main(){
  27. sum_from<1>::to<250000>::result();
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:27:35: error: invalid use of incomplete type 'struct sum_from<1ull>::to<250000ull>::result'
prog.cpp:20:12: error: declaration of 'struct sum_from<1ull>::to<250000ull>::result'
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
stdout
Standard output is empty