I just ran into some misunderstanding: at least in libc++ implementation std::experimental::string_view has the following concise implementation:
template <class _CharT, class _Traits....>
class basic_string_view {
public:
typedef _CharT value_type;
...
template <class _Allocator>
basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& str):
__data(str.data()), __size(str.size())
{
}
private:
const value_type* __data;
size_type __size;
};
Does this implementation imply that if we pass rvalue expression to this constructor, we will get undefined behaviour when using __data after construction?
string_view
is just a glorified reference. – Illfavored