C++ 11中的原始字符串文字是非常好的,除了显示它们的明显方法导致冗余换行\n作为第一个字符.
考虑这个例子:
some_code();
std::string text = R"(
This is the first line.
This is the second line.
This is the third line.
)";
more_code();
Run Code Online (Sandbox Code Playgroud)
明显的解决方法看起来很难看:
some_code();
std::string text = R"(This is the first line.
This is the second line.
This is the third line.
)";
more_code();
Run Code Online (Sandbox Code Playgroud)
有没有人找到一个优雅的解决方案?
通常在SO(以及其他地方),我已经看到C++标准中的注释和示例不是规范性的说法 - 我可能已经多次提出这个主张.
但是,我在C++标准的核心语言规范中找不到这个事实的证据(目前我在查看n3979 C++ 14工作草案).
我能找到的最接近的报价见第17.5.1.2/2段:
标有"注释:"或"示例:"的段落是提供信息的,其他段落是规范性的.
但是,除非我错误地认为该段只适用于图书馆部分(即第18至30条和附件D).
因此,问题是:C++标准中的所有注释和示例都是非规范性的吗?脚注怎么样?