fork download
  1. template <unsigned long long i, char... d>
  2. struct ItoA { static const char *value; };
  3.  
  4. template <unsigned long long i, char... d>
  5. const char *ItoA<i, d...>::value = ItoA<i/10, ('0' + i%10), d...>::value;
  6.  
  7. template <char... d>
  8. struct ItoA<0, d...> { static const char value[]; };
  9.  
  10. template <char... d>
  11. const char ItoA<0, d...>::value[] = {d..., '\0'};
  12.  
  13.  
  14. #include <stdio.h>
  15.  
  16. int main() {
  17. printf(ItoA<3141592654>::value);
  18. }
  19.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
3141592654