[#bsl-basic_string-0f3-erase-0b] = xref:bsl.adoc[bsl]::xref:bsl/basic_string-0f3.adoc[basic_string<char32_t>]::erase :relfileprefix: ../../ :mrdocs: `erase` overloads == Synopses Declared in `<bslstl_string.h>` Erase a character at the specified `position` from this string, and return an iterator providing modifiable access to the character at `position` prior to erasing. If no such character exists, return `end()`. The behavior is undefined unless `position` is within the half‐open range `[cbegin() .. cend())]`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/erase-05.adoc[erase](xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] position); ---- [.small]#xref:bsl/basic_string-0f3/erase-05.adoc[_» more..._]# Erase from this string a substring defined by the specified pair of `first` and `last` iterators within this string. Return an iterator providing modifiable access to the character at the `last` position prior to erasing. If no such character exists, return `end()`. This method invalidates existing iterators pointing to `first` or a subsequent position. The behavior is undefined unless `first` and `last` are both within the range `[cbegin() .. cend()]` and `first <= last`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0f3/iterator.adoc[iterator] xref:bsl/basic_string-0f3/erase-07.adoc[erase]( xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] first, xref:bsl/basic_string-0f3/const_iterator.adoc[const_iterator] last); ---- [.small]#xref:bsl/basic_string-0f3/erase-07.adoc[_» more..._]# Erase from this string the substring of length the optionally specified `numChars` or `original.length() ‐ position`, whichever is smaller, starting at the optionally specified `position`. If `position` is not specified, the first position is used (i.e., `position` is set to 0). Return a reference providing modifiable access to this string. If `numChars` equals `npos`, then the remaining length of the string is erased (i.e., `numChars` is set to `length() ‐ position`). Throw `out_of_range` if `position > length()`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/basic_string-0faf.adoc[basic_string<char32_t>]& xref:bsl/basic_string-0f3/erase-03.adoc[erase]( xref:bsl/basic_string-0f3/size_type.adoc[size_type] position = 0, xref:bsl/basic_string-0f3/size_type.adoc[size_type] numChars = npos); ---- [.small]#xref:bsl/basic_string-0f3/erase-03.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#