5

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?

1 Answer 1

10

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"; 
Sign up to request clarification or add additional context in comments.

3 Comments

I always like the delimiter xyzzy :-)
@paxdiablo, what is xyzzy?
@codekaizer - xyzzy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.