bitwise bitwise - 17 days ago 6
C++ Question

C++17 operator""s for string_view?

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
?

Answer

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;
Comments