1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> template <char... > struct Literal; template <char v> struct Literal<v> { static void print() { std::cout << v << std::endl; } }; template <char f, char ... rest> struct Literal<f, rest...> { static void print() { std::cout << f; Literal<rest...>::print(); } }; #define TO_STRING(x) #x #define CHAR_LIST_7(x) TO_STRING(x)[0] \ , TO_STRING(x)[1] \ , TO_STRING(x)[2] \ , TO_STRING(x)[3] \ , TO_STRING(x)[4] \ , TO_STRING(x)[5] \ , TO_STRING(x)[6] int main() { Literal<CHAR_LIST_7(chicken)>::print(); return 0; } |