fork(1) download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. T sum(T v)
  5. {
  6. return v;
  7. }
  8.  
  9. template<typename T, typename... Args>
  10. T sum(T first, Args... args)
  11. {
  12. return first + sum(args...);
  13. }
  14.  
  15. int main()
  16. {
  17. long lsum = sum(1, 2, 3, 4, 5);
  18.  
  19. std::string s1 = "He", s2 = "llo ", s3 = "Wor", s4 = "ld";
  20. std::string ssum = sum(s1, s2, s3, s4);
  21.  
  22. std::cout << lsum << std::endl
  23. << ssum << std::endl;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
15
Hello World