20 Strings library [strings]

20.4 String view classes [string.view]

20.4.2 Class template basic_­string_­view [string.view.template]

20.4.2.4 Element access [string.view.access]

constexpr const_reference operator[](size_type pos) const;
Expects: pos < size().
Returns: data_­[pos].
Throws: Nothing.
[Note
:
Unlike basic_­string::operator[], basic_­string_­view::operator[](size()) has undefined behavior instead of returning charT().
end note
]
constexpr const_reference at(size_type pos) const;
Throws: out_­of_­range if pos >= size().
Returns: data_­[pos].
constexpr const_reference front() const;
Expects: !empty().
Returns: data_­[0].
Throws: Nothing.
constexpr const_reference back() const;
Expects: !empty().
Returns: data_­[size() - 1].
Throws: Nothing.
constexpr const_pointer data() const noexcept;
Returns: data_­.
[Note
:
Unlike basic_­string::data() and string literals, data() may return a pointer to a buffer that is not null-terminated.
Therefore it is typically a mistake to pass data() to a function that takes just a const charT* and expects a null-terminated string.
end note
]