C++ macro to convert a string to list of characters

后端 未结 2 1463
我寻月下人不归
我寻月下人不归 2021-01-12 22:12

Is it possible to have a macro to have:

CHAR_LIST(chicken)

to expand to:

\'c\', \'h\', \'i\', \'c\', \'k\', \'e\', \'n\'

[Reason I want it: b

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 22:38

    Nope, sorry, can't be done. There is no operation to split a string into characters. The closest you could get is through recursive metaprogramming, but that will give you the array as an object, not the actual text representation.

提交回复
热议问题