Resizes str to contain at most n characters, using the user-provided operation op to modify the possibly indeterminate contents. op must return the finalized length of str.
Declared in <absl/strings/resize_and_overwrite.h>
template<
typename T,
typename Op>
void
StringResizeAndOverwrite(
T& str,
T::size_type n,
Op op);
Invalidates all iterators, pointers, and references into str, regardless of whether reallocation occurs.
op(value_type* buf, size_t buf_size) is allowed to write value_type{} to buf[buf_size], which facilitiates interoperation with functions that write a trailing NUL. Please note that this requirement is more strict than basic_string::resize_and_overwrite(), which allows writing an abitrary value to buf[buf_size].
| Name | Description |
|---|---|
| str | The string to resize and overwrite. |
| n | The maximum number of characters str will contain. |
| op | The operation used to modify the contents of str. |