我跌倒了this page其中作者谈到运营商的标准化“”:
The decision of the C++ standards committee to standardise
operator ""
was [...]
他/她在说什么?我找不到任何关于此的信息,我不明白它可能意味着什么(常量字符串的重载?或者更概念性的东西,不会影响语言的最终使用?)
最佳答案
这些是 user-defined literals .它们允许您在适当的位置创建 std::string
、std::chrono::durations
或任何用户定义的类型(您可以制作自己的文字)之类的东西:
auto str = "Hello"s; // str is std::string("Hello")
auto sec = 5s; // sec is 5 std::chrono::seconds
标准库提供的文字运算符列表及其文档可以在我链接的文档页面的底部找到。
关于c++ - C++ 中的运算符 ""是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42833747/