fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <string>
  4.  
  5. template <typename T>
  6. T paramTest(const T* arr, std::size_t index)
  7. {
  8. return arr[index];
  9. }
  10.  
  11. template<typename T, typename... Args>
  12. T paramTest(const T* arr, std::size_t index, Args... args)
  13. {
  14. return arr[index] + paramTest(arr, args...);
  15. }
  16.  
  17. int main()
  18. {
  19. int p[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  20. int sum = paramTest(p, 5, 4, 7);
  21. std::cout << sum;
  22.  
  23. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
16