用于string_view的C ++ 17运算符“”?

时间:2016-11-18 00:53:21

标签: c++ c++17

C ++ 17是否包含const char*std::string_view转换的文字后缀?

auto str = "asdf"s;

上述陈述中str的类型是std::string还是std::string_view

1 个答案:

答案 0 :(得分:22)

如果我们要相信STL's comment,那么是的,我们会根据P0403R0提供字符串视图字面后缀。

如果我理解正确,s将保留std::string字面后缀,而std::string_view将使用sv

cout << "Hello, string_view literals!"sv << endl;
cout << "Hello, string literals!"s << endl;

this commit sv开始,在标准C ++草案中。