Concat two `const char` string literals

后端 未结 5 2144
北荒
北荒 2020-11-28 12:26

Is it possible to concat two string literals using a constexpr? Or put differently, can one eliminate macros in code like:

#define nl(str) str \         


        
5条回答
  •  佛祖请我去吃肉
    2020-11-28 12:42

    Nope, for constexpr you need a legal function in the first place, and functions can't do pasting etc. of string literal arguments.

    If you think about the equivalent expression in a regular function, it would be allocating memory and concatenating the strings - definitely not amenable to constexpr.

提交回复
热议问题