...

/

Other Operations

Other Operations

A string_view borrows a limited number of methods from the string type. Check them out below.

string_view is modelled to be very similar to std::string. The view, however, is non-owning, so any operation that modifies the data cannot go into the API. Here’s a brief list of methods that you can use with this new type:

Iterators

Method Description
cbegin(), begin() Return an iterator to the first character
crbegin(), rbegin() Return a reverse iterator to the first character of the reversed view. It corresponds to the last character of the sequence.
cend(), end() Returns an iterator to a place after the last character of a sequence
crend(), rend() Returns an iterator to the end of reversed sequence. It corresponds to a place before the first character

Note: all of the above methods are constexpr and const, so you always get a const iterator (even for begin() or end()). ...

Accessing Elements

Method Description
operator[] Returns a const reference to the character at the specified position. Bounds are