char foo(const std::string& str)
char foo(std::string_view sv)
Unlike std::basic_string::operator, std::basic_string_view::operator
(size()) has undefined behavior instead of returning CharT().
The difference is a std::string is guaranteed to be NUL terminated - a view is not. Therefor a std::string always has a valid value at the 0th position.
For a std::string:
If pos == size(), a reference to the character with value CharT() (the null character) is returned.