fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. template<typename T> constexpr inline T add(T val) { return val; }
  6.  
  7. template<typename T, typename ...Agrs>
  8. constexpr inline T add(T val, Agrs ...args) { return val + add(args...); }
  9.  
  10.  
  11. int main() {
  12.  
  13. cout << add(1, 2, 3) << endl;
  14.  
  15. volatile int a = 1, b = 2, c = 3;
  16.  
  17. cout << add(a, b, c) << endl;
  18.  
  19. for(volatile int i = 0; i < 10; ++i)
  20. cout << add(rand(), i) << endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
6
6
1804289383
846930887
1681692779
1714636918
1957747797
424238340
719885392
1649760499
596516657
1189641430