fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int add_() {
  6. return 0;
  7. }
  8.  
  9. template <typename T> T add_(const T& t) {
  10. return t;
  11. }
  12.  
  13. template <typename First, typename... Rest> First add_(const First& first, const Rest&... rest) {
  14. return first + add_(rest...);
  15. }
  16.  
  17. int main()
  18. {
  19. cout << add_(10, 20) << endl;
  20. cout << add_(100, 200, 300) << endl;
  21. cout << add_(2.5, 3.14159) << endl;
  22. }
  23.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Standard output is empty