Reputation: 349
I use R"(...)"
to define a raw string but, if the string actually contains a raw string terminator )"
, the compiler will complain.
For example:
auto tag = R"("(add)")"; // try to get string <"(add)">
How can I modify this so it works?
Upvotes: 5
Views: 277
Reputation: 170173
The syntax for a raw string literal is something like the following:
R"<delim>(...)<delim>"
The optional delimiter that is next to the parentheses is there exactly for the reason you just stumbled upon. It's to let you include the raw string's control characters inside the literal. So add a delimiter:
auto tag = R"tag("("add")")tag";
Upvotes: 10