Namespaces
Variants

Talk:cpp/experimental/basic string view/data

From cppreference.com

Why is this function present in the proposal when not c_str() is ?

It would be locical in C++03 when std::basic_string::data() was not guaranteed to return a nullterminated character array, but since C++11 the functions are equivalent and thus data() should have the same "problems" as c_str() (e.g. dangerous in a generic function)

string_view is really an array_view<char> (with string's interface, more or less), there is no extra terminating null like in std::string. So .c_str() can't be implemented but .data() can, with the same meaning as for array_view. --Cubbi (talk) 12:20, 15 October 2015 (PDT)