【发布时间】:2017-06-24 06:15:24
【问题描述】:
如何定义可以与其他变量连接的多行原始字符串文字?以下不编译:
#define theValue 1000
static std::string str = R"(
foo )" + theValue + R"( bar
)";
【问题讨论】:
标签: c++ string variables multiline
如何定义可以与其他变量连接的多行原始字符串文字?以下不编译:
#define theValue 1000
static std::string str = R"(
foo )" + theValue + R"( bar
)";
【问题讨论】:
标签: c++ string variables multiline
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
)";
在一般情况下,您需要strings 或可以隐式转换为string 的东西才能使用std::string 的连接运算符。
【讨论】: