fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7. #define DBG(x) { cout << left << setw(30) << #x << (x) << endl; }
  8.  
  9. typedef unsigned long long u64;
  10.  
  11. constexpr u64 ct_pow(u64 base, u64 exp){
  12. return exp ? base * ct_pow(base,exp-1): 1;
  13. }
  14.  
  15. template<typename T> T f(T&& last);
  16.  
  17. template<typename T, typename... Os>
  18. int f(T&& first, Os&&... o)
  19. {
  20. return first* ct_pow(10,sizeof...(Os)) + f(forward<Os>(o)...);
  21. }
  22.  
  23. template<typename T>
  24. T f(T&& last){
  25. return last;
  26. }
  27.  
  28. auto main() -> int
  29. {
  30. DBG(f(1));
  31. DBG(f(1,0));
  32. DBG(f(5,1,7,8));
  33.  
  34. DBG(f(true,false,true));
  35. }
  36.  
  37.  
  38.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
f(1)                          1
f(1,0)                        10
f(5,1,7,8)                    5178
f(true,false,true)            101