[#absl-StringResizeAndOverwrite]
= xref:absl.adoc[absl]::StringResizeAndOverwrite
:relfileprefix: ../
:mrdocs:

Resizes `str` to contain at most `n` characters, using the user&hyphen;provided operation `op` to modify the possibly indeterminate contents&period; `op` must return the finalized length of `str`&period;

== Synopsis

Declared in `&lt;absl&sol;strings&sol;resize&lowbar;and&lowbar;overwrite&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    typename Op&gt;
void
StringResizeAndOverwrite(
    T& str,
    T::size&lowbar;type n,
    Op op);
----

== Description

Invalidates all iterators, pointers, and references into `str`, regardless of whether reallocation occurs&period;

`op(value&lowbar;type&ast; buf, size&lowbar;t buf&lowbar;size)` is allowed to write `value&lowbar;type&lcub;&rcub;` to `buf&lsqb;buf&lowbar;size&rsqb;`, which facilitiates interoperation with functions that write a trailing NUL&period; Please note that this requirement is more strict than `basic&lowbar;string&colon;&colon;resize&lowbar;and&lowbar;overwrite()`, which allows writing an abitrary value to `buf&lsqb;buf&lowbar;size&rsqb;`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *str*
| The string to resize and overwrite&period;
| *n*
| The maximum number of characters `str` will contain&period;
| *op*
| The operation used to modify the contents of `str`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
