繁体   English   中英

C ++:带连接的多行字符串文字?

[英]C++: multiline string literal with concatenation?

如何定义可以与其他变量串联的多行原始字符串文字? 以下内容无法编译:

#define theValue 1000

static std::string str = R"(

foo )" + theValue + R"( bar

)";

std::to_string应该可以帮助您解决这一问题

#define theValue 1000

static std::string str = R"(

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

)";

在一般情况下,你需要string可以隐式转换为S或东西string才能使用std::string的连接符。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM