簡體   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