Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++17 operator""s for string_view?

Tags:

c++

c++17

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

auto str = "asdf"s;

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

like image 317
CuriousGeorge Avatar asked Nov 18 '16 00:11

CuriousGeorge


1 Answers

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

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;

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

like image 108
krzaq Avatar answered Sep 27 '22 19:09

krzaq