fork download
  1. template<int I, int... Remainder>
  2. struct sum
  3. {
  4. constexpr static int value = I + sum<Remainder...>::value;
  5. };
  6.  
  7. template<int I>
  8. struct sum<I>
  9. {
  10. constexpr static int value = I;
  11. };
  12.  
  13. static_assert(sum<1, 2, 3, 4>::value == 10, "");
  14.  
  15.  
  16. int main() {
  17. // your code goes here
  18. return 0;
  19. }
Success #stdin #stdout 0s 3092KB
stdin
Standard input is empty
stdout
Standard output is empty