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