In C++ Extensions for Library Fundamentals, Version 2, it is stated that, for string_view
constructor:
constexpr basic_string_view(const charT* str, size_type len);
Requires: [str,str + len) is a valid range.
But it is not defined what a “valid range” is. Is it undefined behavior if a string_view
is constructed with a pointer to non-owned memory?
Also, is it required that a string_view
always point to owned memory for its entire lifetime, or does it apply only to constructor?
If so, what is the rationale for this decision?