用于string_view的C ++ 17运算符? [英] C++17 operator""s for string_view?

查看:55
本文介绍了用于string_view的C ++ 17运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++ 17会包含从 const char * std :: string_view 转换的文字后缀吗?

Will C++17 contain a literal suffix for const char* to std::string_view conversion?

auto str = "asdf"s;

上述语句中 str 的类型是 std :: string 还是 std :: string_view ?

Will the type of str in the above statement be std::string or std::string_view?

推荐答案

如果我们相信

If we're to believe STL's comment, then yes, we'll have string view literal suffixes based on, I believe, P0403R0.

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

If I understand things correctly s will stay a std::string literal suffix, while std::string_view will use sv.

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

截至此提交 sv 在标准C ++草案中.

As of this commit sv is in the Standard C++ draft.

这篇关于用于string_view的C ++ 17运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆