[#bsl-basic_string-01d-erase-04]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-01d.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]::erase
:relfileprefix: ../../
:mrdocs:

Erase from this string the substring of length the optionally specified `numChars` or `original&period;length() &hyphen; position`, whichever is smaller, starting at the optionally specified `position`&period; If `position` is not specified, the first position is used (i&period;e&period;, `position` is set to 0)&period; Return a reference providing modifiable access to this string&period; If `numChars` equals `npos`, then the remaining length of the string is erased (i&period;e&period;, `numChars` is set to `length() &hyphen; position`)&period; Throw `out&lowbar;of&lowbar;range` if `position &gt; length()`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]&
erase(
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position = 0,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars = npos);
----


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