1

How can I define a multiline raw string literal that can be concatenated with other variables? The following does not compile:

#define theValue 1000

static std::string str = R"(

foo )" + theValue + R"( bar

)";

1 Answer 1

1

std::to_string should help you out with this one

#define theValue 1000

static std::string str = R"(

foo )" + std::to_string(theValue) + R"( bar

)";

In the general case, you need strings or something that can be implicitly converted into a string in order to use std::string's concatenation operator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.