Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
string raw_str = R"(R"(foo)")";
如果我有R"()"一个原始字符串,这会导致解析器混淆。(即,它认为最左边)"是原始字符串的结尾。
R"()"
)"
我该如何逃脱呢?
原始字符串文字[ 2 ]的格式为:R"delimiter( raw_characters )delimiter"
R"delimiter( raw_characters )delimiter"
因此您可以使用不在字符串中的其他分隔符,例如:
string raw_str = R"~(R"(foo)")~";
原始字符串将在)"它看到的第一个之后终止。您可以将分隔符更改***为例如:
***
string raw_str = R"***(R"(foo)")***";