Status of p0506r0 - use string_view for library function parameters....
I just had a lightbulb moment, thinking that the acceptance of string_view as parameters for std library functions would be great. As it turns out, Peter Sommerlad has already had this brain wave and has developed a proposal. Does anybody know the status of this paper? Are there any vendors looking at this?
Posted Nov 5, 2017, 9:00 AM UTC
Certainly having string_view overloads would be good. I have personally found that string_view doesn't work well with legacy code expecting c-strings because it doesn't necessarily have a null terminator. This is the one case I'm aware of where const string& can't be replaced with string_view in a function parameter.
I wrote a zstring_view that is only constructible from either a char* or std::string for just this purpose. It lets me call functions with either a std::string or a char* (without constructing a std::string from it).. and it has a c_str() member function.
I pretty much exclusively use it for input parameters for functions. It also works for suffixes of things that are NUL terminated..
zstring_view is also in the GSL.
https://github.com/Microsoft/GSL
good to know, thanks!