fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<char... Ch>
  5. struct CString
  6. {
  7. static const char value[sizeof...(Ch) + 1];
  8. };
  9.  
  10. template<char... Ch>
  11. const char CString<Ch...>::value[sizeof...(Ch) + 1] = { Ch..., '\0' };
  12.  
  13. template<typename S0, typename S1> struct Strcat;
  14.  
  15. template<char... Ch0, char... Ch1>
  16. struct Strcat<CString<Ch0...>, CString<Ch1...>>
  17. {
  18. typedef CString<Ch0..., Ch1...> type;
  19. };
  20.  
  21. int main() {
  22. typedef CString<'C', 'h', 'a', 'r'> T0;
  23. typedef CString<'F', 'l', 'o', 'a', 't'> T1;
  24. typedef Strcat<Strcat<T0, CString<',', ' '>>::type, T1>::type T2;
  25. cout << T2::value << endl;
  26. return 0;
  27. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Char, Float