Like s.substr(pos, n), but clips pos to an upper bound of s.size().
Declared in <absl/strings/string_view.h>
std::string_view
ClippedSubstr(
std::string_view s,
size_t pos,
size_t n = string_view::npos);
Provided because std::string_view::substr throws if pos > size().
A view of the clipped substring.
| Name | Description |
|---|---|
| s | The string view to take a substring of. |
| pos | The starting position, clipped to s.size(). |
| n | The number of characters to include in the substring. |