escape R“()” in a raw string in C++

前端 未结 2 1639
星月不相逢
星月不相逢 2021-02-13 19:30
  string raw_str = R\"(R\"(foo)\")\";

If I have R\"()\" inside a raw string, and that causes the parser to confuse. (ie., it thought the l

相关标签:
2条回答
  • 2021-02-13 20:02

    The raw string will terminate after the first )" it sees. You can change the delimiter to *** for example:

    string raw_str = R"***(R"(foo)")***";
    
    0 讨论(0)
  • 2021-02-13 20:12

    The format for the raw-string literals[2] is: R"delimiter( raw_characters )delimiter"

    so you can use a different delimiter that is not in the string like:

    string raw_str = R"~(R"(foo)")~";
    
    0 讨论(0)
提交回复
热议问题