---
name: "__gnu_debug::basic_string"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_debug::basic_string"
---

# \_\_gnu\_debug::basic\_string(3)

Class std::basic\_string with safety/checking/debug instrumentation.

## NAME

\_\_gnu\_debug::basic\_string\< \_CharT, \_Traits, \_Allocator \> - Class std::basic\_string with safety/checking/debug instrumentation.

## SYNOPSIS

\#include \<string\>

Inherits **\_\_gnu\_debug::\_Safe\_container\< \_SafeContainer, \_Alloc, \_SafeBase, \_IsCxx11AllocatorAware \>**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>**.

### Public Types

typedef \_Allocator **allocator\_type**\
 typedef **\_\_gnu\_debug::\_Safe\_iterator**\< typename \_Base::const\_iterator, basic\_string \> **const\_iterator**\
 typedef \_Base::const\_pointer **const\_pointer**\
 typedef \_Base::const\_reference **const\_reference**\
 typedef **std::reverse\_iterator**\< const\_iterator \> **const\_reverse\_iterator**\
 typedef \_Base::difference\_type **difference\_type**\
 typedef **\_\_gnu\_debug::\_Safe\_iterator**\< typename \_Base::iterator, basic\_string \> **iterator**\
 typedef \_Base::pointer **pointer**\
 typedef \_Base::reference **reference**\
 typedef **std::reverse\_iterator**\< iterator \> **reverse\_iterator**\
 typedef \_Base::size\_type **size\_type**\
 typedef \_Traits **traits\_type**\
 typedef \_Traits::char\_type **value\_type**\

### Public Member Functions

**basic\_string** (\_Base &&**\_\_base**) noexcept\
 template\<typename \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> **basic\_string** (\_InputIterator \_\_begin, \_InputIterator \_\_end, const \_Allocator &\_\_a=\_Allocator())\
 **basic\_string** (basic\_string &&)=default\
 **basic\_string** (basic\_string &&\_\_s, const \_Allocator &\_\_a) noexcept(**std::is\_nothrow\_constructible**\< \_Base, \_Base, const \_Allocator & \>::value)\
 **basic\_string** (const \_Allocator &\_\_a) noexcept\
 **basic\_string** (const \_Base &**\_\_base**)\
 **basic\_string** (const \_CharT \*\_\_s, const \_Allocator &\_\_a=\_Allocator())\
 **basic\_string** (const \_CharT \*\_\_s, size\_type \_\_n, const \_Allocator &\_\_a=\_Allocator())\
 **basic\_string** (const basic\_string &)=default\
 **basic\_string** (const basic\_string &\_\_s, const \_Allocator &\_\_a)\
 **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n=**\_Base::npos**, const \_Allocator &\_\_a=\_Allocator())\
 **basic\_string** (size\_type \_\_n, \_CharT \_\_c, const \_Allocator &\_\_a=\_Allocator())\
 **basic\_string** (**std::initializer\_list**\< \_CharT \> \_\_l, const \_Allocator &\_\_a=\_Allocator())\
 template\<typename \_Operation\> constexpr void **\_\_resize\_and\_overwrite** (size\_type \_\_n, \_Operation \_\_op)\
 Non-standard version of resize\_and\_overwrite for C++11 and above.  template\<typename \_Operation\> void **\_\_resize\_and\_overwrite** (size\_type \_\_n, \_Operation \_\_op)\
 Non-standard version of resize\_and\_overwrite for C++11 and above.  const \_Base & **\_M\_base** () const noexcept\
 \_Base & **\_M\_base** () noexcept\
 template\<typename \_InputIterator\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & **\_M\_replace\_dispatch** (iterator \_\_i1, iterator \_\_i2, \_InputIterator \_\_k1, \_InputIterator \_\_k2, \_\_false\_type)\
 template\<typename \_InIterator\> \_CharT \* **\_S\_construct** (\_InIterator \_\_beg, \_InIterator \_\_end, const \_Alloc &\_\_a, forward\_iterator\_tag)\
 template\<typename \_InputIterator\> basic\_string & **append** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 basic\_string & **append** (const \_CharT \*\_\_s)\
 basic\_string & **append** (const \_CharT \*\_\_s, size\_type \_\_n)\
 basic\_string & **append** (const basic\_string &\_\_str)\
 basic\_string & **append** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n)\
 basic\_string & **append** (size\_type \_\_n, \_CharT \_\_c)\
 constexpr basic\_string & **append** (const \_CharT \*\_\_s, size\_type \_\_n)\
 Append a C substring.  constexpr basic\_string & **append** (const basic\_string &\_\_str)\
 Append a string to this string.  constexpr basic\_string & **append** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n=**npos**)\
 Append a substring.  constexpr basic\_string & **append** (initializer\_list\< \_CharT \> \_\_l)\
 Append an initializer\_list of characters.  constexpr basic\_string & **append** (size\_type \_\_n, \_CharT \_\_c)\
 Append multiple characters.  template\<typename \_InputIterator\> basic\_string & **assign** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 basic\_string & **assign** (basic\_string &&\_\_x) noexcept(noexcept(**std::declval**\< \_Base & \>().assign(**std::move**(\_\_x))))\
 basic\_string & **assign** (const \_CharT \*\_\_s)\
 basic\_string & **assign** (const \_CharT \*\_\_s, size\_type \_\_n)\
 basic\_string & **assign** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n)\
 basic\_string & **assign** (const basic\_string &\_\_x)\
 basic\_string & **assign** (size\_type \_\_n, \_CharT \_\_c)\
 basic\_string & **assign** (**std::initializer\_list**\< \_CharT \> \_\_l)\
 constexpr basic\_string & **assign** (basic\_string &&\_\_str) noexcept(\_Alloc\_traits::\_S\_nothrow\_move())\
 Set value to contents of another string.  constexpr basic\_string & **assign** (const \_CharT \*\_\_s, size\_type \_\_n)\
 Set value to a C substring.  constexpr basic\_string & **assign** (const basic\_string &\_\_str)\
 Set value to contents of another string.  constexpr basic\_string & **assign** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n=**npos**)\
 Set value to a substring of a string.  constexpr basic\_string & **assign** (size\_type \_\_n, \_CharT \_\_c)\
 Set value to multiple characters.  constexpr reference **at** (size\_type \_\_n)\
 Provides access to the data contained in the string.  reference **at** (size\_type \_\_n)\
 Provides access to the data contained in the string.  constexpr const\_reference **at** (size\_type \_\_n) const\
 Provides access to the data contained in the string.  const\_reference **at** (size\_type \_\_n) const\
 Provides access to the data contained in the string.  constexpr reference **at** (size\_type \_\_n)\
 Provides access to the data contained in the string.  constexpr const\_reference **at** (size\_type \_\_n) const\
 Provides access to the data contained in the string.  constexpr const\_reference **back** () const noexcept\
 constexpr reference **back** () noexcept\
 iterator **begin** ()\
 const\_iterator **begin** () const noexcept\
 const \_CharT \* **c\_str** () const noexcept\
 constexpr size\_type **capacity** () const noexcept\
 const\_iterator **cbegin** () const noexcept\
 const\_iterator **cend** () const noexcept\
 void **clear** ()\
 constexpr int **compare** (const \_CharT \*\_\_s) const noexcept\
 constexpr int **compare** (const basic\_string &\_\_str) const\
 Compare to a string.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n, const basic\_string &\_\_str) const\
 Compare substring to a string.  int **compare** (size\_type \_\_pos, size\_type \_\_n, const basic\_string &\_\_str) const\
 Compare substring to a string.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s) const\
 Compare substring to a C string.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2) const\
 Compare substring against a character array.  int **compare** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2) const\
 Compare substring against a character array.  constexpr int **compare** (size\_type \_\_pos1, size\_type \_\_n1, const \_CharT \*\_\_s) const\
 constexpr int **compare** (size\_type \_\_pos1, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2) const\
 constexpr int **compare** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n2=**npos**) const\
 Compare substring to a substring.  int **compare** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n2=**npos**) const\
 Compare substring to a substring.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n, const basic\_string &\_\_str) const\
 Compare substring to a string.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s) const\
 Compare substring to a C string.  constexpr int **compare** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2) const\
 Compare substring against a character array.  constexpr int **compare** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n2=**npos**) const\
 Compare substring to a substring.  constexpr bool **contains** (\_CharT \_\_x) const noexcept\
 bool **contains** (\_CharT \_\_x) const noexcept\
 constexpr bool **contains** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 bool **contains** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 constexpr bool **contains** (const \_CharT \*\_\_x) const noexcept\
 bool **contains** (const \_CharT \*\_\_x) const noexcept\
 size\_type **copy** (\_CharT \*\_\_s, size\_type \_\_n, size\_type \_\_pos=0) const\
 constexpr size\_type **copy** (\_CharT \*\_\_s, size\_type \_\_n, size\_type \_\_pos=0) const\
 Copy substring into C string.  const\_reverse\_iterator **crbegin** () const noexcept\
 const\_reverse\_iterator **crend** () const noexcept\
 const \_CharT \* **data** () const noexcept\
 constexpr \_CharT \* **data** () noexcept\
 Return non-const pointer to contents.  constexpr bool **empty** () const noexcept\
 iterator **end** ()\
 const\_iterator **end** () const noexcept\
 constexpr bool **ends\_with** (\_CharT \_\_x) const noexcept\
 bool **ends\_with** (\_CharT \_\_x) const noexcept\
 constexpr bool **ends\_with** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 bool **ends\_with** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 constexpr bool **ends\_with** (const \_CharT \*\_\_x) const noexcept\
 bool **ends\_with** (const \_CharT \*\_\_x) const noexcept\
 iterator **erase** (\_\_const\_iterator \_\_first, \_\_const\_iterator \_\_last)\
 iterator **erase** (\_\_const\_iterator \_\_position)\
 basic\_string & **erase** (size\_type \_\_pos=0, size\_type \_\_n=**\_Base::npos**)\
 constexpr iterator **erase** (\_\_const\_iterator \_\_first, \_\_const\_iterator \_\_last)\
 Remove a range of characters.  constexpr iterator **erase** (\_\_const\_iterator \_\_position)\
 Remove one character.  iterator **erase** (iterator \_\_first, iterator \_\_last)\
 Remove a range of characters.  iterator **erase** (iterator \_\_position)\
 Remove one character.  constexpr basic\_string & **erase** (size\_type \_\_pos=0, size\_type \_\_n=**npos**)\
 Remove characters.  constexpr size\_type **find** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  size\_type **find** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a C substring.  size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a C substring.  constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a C string.  constexpr size\_type **find** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a string.  size\_type **find** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a string.  constexpr size\_type **find** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a C substring.  constexpr size\_type **find** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a C string.  constexpr size\_type **find** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a string.  constexpr size\_type **find\_first\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a different character.  size\_type **find\_first\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a different character.  constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character not in C substring.  size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character not in C substring.  constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a character not in C string.  constexpr size\_type **find\_first\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character not in string.  size\_type **find\_first\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character not in string.  constexpr size\_type **find\_first\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a different character.  constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character not in C substring.  constexpr size\_type **find\_first\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a character not in C string.  constexpr size\_type **find\_first\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character not in string.  constexpr size\_type **find\_first\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  size\_type **find\_first\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character of C substring.  size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character of C substring.  constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a character of C string.  constexpr size\_type **find\_first\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character of string.  size\_type **find\_first\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character of string.  constexpr size\_type **find\_first\_of** (\_CharT \_\_c, size\_type \_\_pos=0) const noexcept\
 Find position of a character.  constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find position of a character of C substring.  constexpr size\_type **find\_first\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=0) const noexcept\
 Find position of a character of C string.  constexpr size\_type **find\_first\_of** (const basic\_string &\_\_str, size\_type \_\_pos=0) const noexcept\
 Find position of a character of string.  constexpr size\_type **find\_last\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a different character.  size\_type **find\_last\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a different character.  constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character not in C substring.  size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character not in C substring.  constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**\_Base::npos**) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character not in C string.  constexpr size\_type **find\_last\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character not in string.  size\_type **find\_last\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character not in string.  constexpr size\_type **find\_last\_not\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a different character.  constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character not in C substring.  constexpr size\_type **find\_last\_not\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character not in C string.  constexpr size\_type **find\_last\_not\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character not in string.  constexpr size\_type **find\_last\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  size\_type **find\_last\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character of C substring.  size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character of C substring.  constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**\_Base::npos**) const noexcept\
 constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character of C string.  constexpr size\_type **find\_last\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character of string.  size\_type **find\_last\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character of string.  constexpr size\_type **find\_last\_of** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a character of C substring.  constexpr size\_type **find\_last\_of** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character of C string.  constexpr size\_type **find\_last\_of** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character of string.  constexpr const\_reference **front** () const noexcept\
 constexpr reference **front** () noexcept\
 constexpr allocator\_type **get\_allocator** () const noexcept\
 Return copy of allocator used to construct this string.  iterator **insert** (\_\_const\_iterator \_\_p, \_CharT \_\_c)\
 template\<typename \_InputIterator\> iterator **insert** (\_\_const\_iterator \_\_p, \_InputIterator \_\_first, \_InputIterator \_\_last)\
 iterator **insert** (const\_iterator \_\_p, size\_type \_\_n, \_CharT \_\_c)\
 iterator **insert** (const\_iterator \_\_p, **std::initializer\_list**\< \_CharT \> \_\_l)\
 basic\_string & **insert** (size\_type \_\_pos, const \_CharT \*\_\_s)\
 basic\_string & **insert** (size\_type \_\_pos, const \_CharT \*\_\_s, size\_type \_\_n)\
 basic\_string & **insert** (size\_type \_\_pos, size\_type \_\_n, \_CharT \_\_c)\
 basic\_string & **insert** (size\_type \_\_pos1, const basic\_string &\_\_str)\
 basic\_string & **insert** (size\_type \_\_pos1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n)\
 constexpr iterator **insert** (\_\_const\_iterator \_\_p, \_CharT \_\_c)\
 Insert one character.  template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> constexpr iterator **insert** (const\_iterator \_\_p, \_InputIterator \_\_beg, \_InputIterator \_\_end)\
 Insert a range of characters.  constexpr iterator **insert** (const\_iterator \_\_p, initializer\_list\< \_CharT \> \_\_l)\
 Insert an initializer\_list of characters.  constexpr iterator **insert** (const\_iterator \_\_p, size\_type \_\_n, \_CharT \_\_c)\
 Insert multiple characters.  iterator **insert** (iterator \_\_p, \_CharT \_\_c)\
 Insert one character.  template\<class \_InputIterator\> void **insert** (iterator \_\_p, \_InputIterator \_\_beg, \_InputIterator \_\_end)\
 Insert a range of characters.  void **insert** (iterator \_\_p, initializer\_list\< \_CharT \> \_\_l)\
 Insert an initializer\_list of characters.  void **insert** (iterator \_\_p, size\_type \_\_n, \_CharT \_\_c)\
 Insert multiple characters.  constexpr basic\_string & **insert** (size\_type \_\_pos, const \_CharT \*\_\_s)\
 Insert a C string.  constexpr basic\_string & **insert** (size\_type \_\_pos, const \_CharT \*\_\_s, size\_type \_\_n)\
 Insert a C substring.  constexpr basic\_string & **insert** (size\_type \_\_pos, size\_type \_\_n, \_CharT \_\_c)\
 Insert multiple characters.  constexpr basic\_string & **insert** (size\_type \_\_pos1, const basic\_string &\_\_str)\
 Insert value of a string.  constexpr basic\_string & **insert** (size\_type \_\_pos1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n=**npos**)\
 Insert a substring.  constexpr size\_type **length** () const noexcept\
 Returns the number of characters in the string, not including any null-termination.  constexpr size\_type **max\_size** () const noexcept\
 Returns the size() of the largest possible string.  basic\_string & **operator+=** (\_CharT \_\_c)\
 basic\_string & **operator+=** (const \_CharT \*\_\_s)\
 basic\_string & **operator+=** (const basic\_string &\_\_str)\
 basic\_string & **operator+=** (**std::initializer\_list**\< \_CharT \> \_\_l)\
 constexpr basic\_string & **operator+=** (const basic\_string &\_\_str)\
 Append a string to this string.  basic\_string & **operator=** (\_CharT \_\_c)\
 basic\_string & **operator=** (basic\_string &&)=default\
 basic\_string & **operator=** (const \_CharT \*\_\_s)\
 basic\_string & **operator=** (const basic\_string &)=default\
 basic\_string & **operator=** (**std::initializer\_list**\< \_CharT \> \_\_l)\
 reference **operator\[\]** (size\_type \_\_pos)\
 const\_reference **operator\[\]** (size\_type \_\_pos) const noexcept\
 constexpr reference **operator\[\]** (size\_type \_\_pos)\
 Subscript access to the data contained in the string.  constexpr const\_reference **operator\[\]** (size\_type \_\_pos) const noexcept\
 Subscript access to the data contained in the string.  void **pop\_back** ()\
 void **push\_back** (\_CharT \_\_c)\
 reverse\_iterator **rbegin** ()\
 const\_reverse\_iterator **rbegin** () const noexcept\
 reverse\_iterator **rend** ()\
 const\_reverse\_iterator **rend** () const noexcept\
 template\<typename \_InputIterator\> basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, \_InputIterator \_\_j1, \_InputIterator \_\_j2)\
 basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \*\_\_s)\
 basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \*\_\_s, size\_type \_\_n)\
 basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const basic\_string &\_\_str)\
 basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, size\_type \_\_n, \_CharT \_\_c)\
 basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, **std::initializer\_list**\< \_CharT \> \_\_l)\
 basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s)\
 basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2)\
 basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, size\_type \_\_n2, \_CharT \_\_c)\
 basic\_string & **replace** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str)\
 basic\_string & **replace** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n2)\
 constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, \_CharT \*\_\_k1, \_CharT \*\_\_k2)\
 constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \*\_\_k1, const \_CharT \*\_\_k2)\
 constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \*\_\_s)\
 Replace range of characters with C string.  constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \*\_\_s, size\_type \_\_n)\
 Replace range of characters with C substring.  constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const basic\_string &\_\_str)\
 Replace range of characters with string.  constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const\_iterator \_\_k1, const\_iterator \_\_k2)\
 constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, iterator \_\_k1, iterator \_\_k2)\
 constexpr basic\_string & **replace** (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, size\_type \_\_n, \_CharT \_\_c)\
 Replace range of characters with multiple characters.  template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> constexpr basic\_string & **replace** (const\_iterator \_\_i1, const\_iterator \_\_i2, \_InputIterator \_\_k1, \_InputIterator \_\_k2)\
 Replace range of characters with range.  constexpr basic\_string & **replace** (const\_iterator \_\_i1, const\_iterator \_\_i2, initializer\_list\< \_CharT \> \_\_l)\
 Replace range of characters with initializer\_list.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, \_CharT \*\_\_k1, \_CharT \*\_\_k2)\
 template\<class \_InputIterator\> basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, \_InputIterator \_\_k1, \_InputIterator \_\_k2)\
 Replace range of characters with range.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, const \_CharT \*\_\_k1, const \_CharT \*\_\_k2)\
 basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, const \_CharT \*\_\_s)\
 Replace range of characters with C string.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, const \_CharT \*\_\_s, size\_type \_\_n)\
 Replace range of characters with C substring.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, const basic\_string &\_\_str)\
 Replace range of characters with string.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, const\_iterator \_\_k1, const\_iterator \_\_k2)\
 basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, initializer\_list\< \_CharT \> \_\_l)\
 Replace range of characters with initializer\_list.  basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, iterator \_\_k1, iterator \_\_k2)\
 basic\_string & **replace** (iterator \_\_i1, iterator \_\_i2, size\_type \_\_n, \_CharT \_\_c)\
 Replace range of characters with multiple characters.  constexpr basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n, const basic\_string &\_\_str)\
 Replace characters with value from another string.  constexpr basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s)\
 Replace characters with value of a C string.  constexpr basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \*\_\_s, size\_type \_\_n2)\
 Replace characters with value of a C substring.  constexpr basic\_string & **replace** (size\_type \_\_pos, size\_type \_\_n1, size\_type \_\_n2, \_CharT \_\_c)\
 Replace characters with multiple characters.  constexpr basic\_string & **replace** (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string &\_\_str, size\_type \_\_pos2, size\_type \_\_n2=**npos**)\
 Replace characters with value from another string.  constexpr void **reserve** ()\
 constexpr void **reserve** (size\_type \_\_res\_arg)\
 Attempt to preallocate enough memory for specified number of characters.  void **reserve** (size\_type \_\_res\_arg)\
 Attempt to preallocate enough memory for specified number of characters.  constexpr void **reserve** (size\_type \_\_res\_arg)\
 Attempt to preallocate enough memory for specified number of characters.  void **resize** (size\_type \_\_n)\
 void **resize** (size\_type \_\_n, \_CharT \_\_c)\
 constexpr void **resize** (size\_type \_\_n)\
 Resizes the string to the specified number of characters.  constexpr void **resize** (size\_type \_\_n, \_CharT \_\_c)\
 Resizes the string to the specified number of characters.  constexpr size\_type **rfind** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  size\_type **rfind** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const\
 constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a C substring.  size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a C substring.  constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos=**\_Base::npos**) const\
 constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const\
 Find last position of a C string.  constexpr size\_type **rfind** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a string.  size\_type **rfind** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a string.  constexpr size\_type **rfind** (\_CharT \_\_c, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a character.  constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos, size\_type \_\_n) const noexcept\
 Find last position of a C substring.  constexpr size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const\
 Find last position of a C string.  constexpr size\_type **rfind** (const basic\_string &\_\_str, size\_type \_\_pos=**npos**) const noexcept\
 Find last position of a string.  void **shrink\_to\_fit** () noexcept\
 constexpr size\_type **size** () const noexcept\
 Returns the number of characters in the string, not including any null-termination.  constexpr bool **starts\_with** (\_CharT \_\_x) const noexcept\
 bool **starts\_with** (\_CharT \_\_x) const noexcept\
 constexpr bool **starts\_with** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 bool **starts\_with** (basic\_string\_view\< \_CharT, \_Traits \> \_\_x) const noexcept\
 constexpr bool **starts\_with** (const \_CharT \*\_\_x) const noexcept\
 bool **starts\_with** (const \_CharT \*\_\_x) const noexcept\
 basic\_string **substr** (size\_type \_\_pos=0, size\_type \_\_n=**\_Base::npos**) const\
 constexpr basic\_string **substr** (size\_type \_\_pos, size\_type \_\_n) &&\
 constexpr basic\_string **substr** (size\_type \_\_pos=0) &&\
 constexpr basic\_string **substr** (size\_type \_\_pos=0, size\_type \_\_n=**npos**) const\
 Get a substring.  constexpr basic\_string\_view\< \_CharT, \_Traits \> **subview** (size\_type \_\_pos=0, size\_type \_\_n=**npos**) const\
 Get a subview.  constexpr basic\_string\_view\< \_CharT, \_Traits \> **subview** (size\_type \_\_pos=0, size\_type \_\_n=**npos**) const\
 Get a subview.  void **swap** (basic\_string &\_\_x) noexcept(/\*conditional \*/)\
 constexpr void **swap** (basic\_string &\_\_s) noexcept\
 Swap contents with another string.

### Static Public Attributes

static const size\_type **npos**\
 Value returned by various member functions when they fail.

### Protected Member Functions

constexpr void **\_M\_swap** (const \_Safe\_container &\_\_x) const noexcept\

### Friends

template\<typename \_ItT, typename \_SeqT, typename \_CatT\> class **::\_\_gnu\_debug::\_Safe\_iterator**\

## Detailed Description

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\>

class \_\_gnu\_debug::basic\_string\< \_CharT, \_Traits, \_Allocator \>"Class std::basic\_string with safety/checking/debug instrumentation.

## Member Function Documentation

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<typename \_Operation\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::\_\_resize\_and\_overwrite (size\_type \_\_n, \_Operation \_\_op) \[constexpr\], \[inherited\]

Non-standard version of resize\_and\_overwrite for C++11 and above.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<typename \_Operation\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::\_\_resize\_and\_overwrite (size\_type \_\_n, \_Operation \_\_op) \[inherited\]

Non-standard version of resize\_and\_overwrite for C++11 and above.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[constexpr\], \[inherited\]

Append a C substring.

**Parameters**

*\_\_s* The C string to append. \
 *\_\_n* The number of characters to append.

**Returns**

Reference to this string.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

Append a string to this string.

**Parameters**

*\_\_str* The string to append.

**Returns**

Reference to this string.

Referenced by **std::basic\_string\< \_CharT \>::append()**, **std::basic\_string\< \_CharT \>::append()**, **std::basic\_string\< \_CharT \>::append()**, **std::basic\_string\< \_CharT \>::append()**, **std::\_\_cxx11::collate\< \_CharT \>::do\_transform()**, **std::basic\_string\< \_CharT \>::operator+=()**, **std::basic\_string\< \_CharT \>::operator+=()**, **std::basic\_string\< \_CharT \>::operator+=()**, **std::operator\>\>()**, and **resize()**.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, size\_type \_\_n = npos) \[inline\], \[constexpr\], \[inherited\]

Append a substring.

**Parameters**

*\_\_str* The string to append. \
 *\_\_pos* Index of the first character of str to append. \
 *\_\_n* The number of characters to append.

**Returns**

Reference to this string.

**Exceptions**

**std::out\_of\_range if** *\_\_pos* **is not a valid index.**

**This function appends** *\_\_n* **characters from** *\_\_str* **starting at** *\_\_pos* **to this string. If** *\_\_n* **is is larger than the number of available characters in** *\_\_str***, the remainder of** *\_\_str* **is appended.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (initializer\_list\< \_CharT \> \_\_l) \[inline\], \[constexpr\], \[inherited\]

**Append an initializer\_list of characters.**

**Parameters**

*\_\_l* **The initializer\_list of characters to append.**

**Returns**

**Reference to this string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (size\_type \_\_n, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Append multiple characters.**

**Parameters**

*\_\_n* **The number of characters to append.** \
 *\_\_c* **The character to use.**

**Returns**

**Reference to this string.**

**Appends \_\_n copies of \_\_c to this string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (basic\_string\< \_CharT, \_Traits, \_Alloc \> && \_\_str) \[inline\], \[constexpr\], \[noexcept\], \[inherited\]

**Set value to contents of another string.**

**Parameters**

*\_\_str* **Source string to use.**

**Returns**

**Reference to this string.**

**This function sets this string to the exact contents of** *\_\_str***.** *\_\_str* **is a valid, but unspecified string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[constexpr\], \[inherited\]

**Set value to a C substring.**

**Parameters**

*\_\_s* **The C string to use.** \
 *\_\_n* **Number of characters to use.**

**Returns**

**Reference to this string.**

**This function sets the value of this string to the first** *\_\_n* **characters of** *\_\_s***. If** *\_\_n* **is is larger than the number of available characters in** *\_\_s***, the remainder of** *\_\_s* **is used.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

**Set value to contents of another string.**

**Parameters**

*\_\_str* **Source string to use.**

**Returns**

**Reference to this string.**

**Referenced by std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::operator=(), std::basic\_string\< \_CharT \>::operator=(), std::basic\_string\< \_CharT \>::operator=(), std::basic\_string\< \_CharT \>::operator=(), std::basic\_stringbuf\< \_CharT, \_Traits, \_Alloc \>::overflow(), std::basic\_stringbuf\< char \>::str(), and std::basic\_stringbuf\< char \>::str().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, size\_type \_\_n = npos) \[inline\], \[constexpr\], \[inherited\]

**Set value to a substring of a string.**

**Parameters**

*\_\_str* **The string to use.** \
 *\_\_pos* **Index of the first character of str.** \
 *\_\_n* **Number of characters to use.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range if** *pos* **is not a valid index.**

**This function sets this string to the substring of** *\_\_str* **consisting of** *\_\_n* **characters at** *\_\_pos***. If** *\_\_n* **is is larger than the number of available characters in** *\_\_str***, the remainder of** *\_\_str* **is used.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (size\_type \_\_n, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Set value to multiple characters.**

**Parameters**

*\_\_n* **Length of the resulting string.** \
 *\_\_c* **The character to use.**

**Returns**

**Reference to this string.**

**This function sets the value of this string to** *\_\_n* **copies of character** *\_\_c***.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::at (size\_type \_\_n) \[inline\], \[nodiscard\], \[constexpr\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read/write reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::at (size\_type \_\_n) \[inline\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read/write reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails. Success results in unsharing the string.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::at (size\_type \_\_n) const \[inline\], \[nodiscard\], \[constexpr\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read-only (const) reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::at (size\_type \_\_n) const \[inline\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read-only (const) reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::at (size\_type \_\_n) \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read/write reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::at (size\_type \_\_n) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Provides access to the data contained in the string.**

**Parameters**

*\_\_n* **The index of the character to access.**

**Returns**

**Read-only (const) reference to the character.**

**Exceptions**

**std::out\_of\_range If** *n* **is an invalid index.**

**This function provides for safer data access. The parameter is first checked that it is in the range of the string. The function throws out\_of\_range if the check fails.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::back () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reference to the data at the last element of the string.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::back () \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read/write reference to the data at the last element of the string.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::capacity () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns the total number of characters that the string can hold before needing to allocate more memory.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str) const \[inline\], \[nodiscard\], \[constexpr\]

**Compare to a string.**

**Parameters**

*\_\_str* **String to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Returns an integer \< 0 if this string is ordered before** *\_\_str***, 0 if their values are equivalent, or \> 0 if this string is ordered after** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of size() and str.size(). The function then compares the two strings by calling traits::compare(data(), str.data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos, size\_type \_\_n, const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str) const \[inline\], \[nodiscard\], \[constexpr\]

**Compare substring to a string.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n* **Number of characters in substring.** \
 *\_\_str* **String to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n* **characters starting at** *\_\_pos***. Returns an integer \< 0 if the substring is ordered before** *\_\_str***, 0 if their values are equivalent, or \> 0 if the substring is ordered after** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_str.size()***. The function then compares the two strings by calling traits::compare(substring.data(),str.data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos, size\_type \_\_n, const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str) const \[inline\]

**Compare substring to a string.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n* **Number of characters in substring.** \
 *\_\_str* **String to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n* **characters starting at** *\_\_pos***. Returns an integer \< 0 if the substring is ordered before** *\_\_str***, 0 if their values are equivalent, or \> 0 if the substring is ordered after** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_str.size()***. The function then compares the two strings by calling traits::compare(substring.data(),str.data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s) const \[inline\], \[nodiscard\], \[constexpr\]

**Compare substring to a C string.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_s* **C string to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *pos***. Returns an integer \< 0 if the substring is ordered before** *\_\_s***, 0 if their values are equivalent, or \> 0 if the substring is ordered after** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and the length of a string constructed from** *\_\_s***. The function then compares the two string by calling traits::compare(substring.data(),\_\_s,rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s, size\_type \_\_n2) const \[inline\], \[nodiscard\], \[constexpr\]

**Compare substring against a character array.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_s* **character array to compare against.** \
 *\_\_n2* **Number of characters of s.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos***. Form a string from the first** *\_\_n2* **characters of** *\_\_s***. Returns an integer \< 0 if this substring is ordered before the string from** *\_\_s***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the string from** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_n2***. The function then compares the two strings by calling traits::compare(substring.data(),s,rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

**NB: s must have at least n2 characters, '\\0' has no special meaning.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s, size\_type \_\_n2) const \[inline\]

**Compare substring against a character array.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_s* **character array to compare against.** \
 *\_\_n2* **Number of characters of s.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos***. Form a string from the first** *\_\_n2* **characters of** *\_\_s***. Returns an integer \< 0 if this substring is ordered before the string from** *\_\_s***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the string from** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_n2***. The function then compares the two strings by calling traits::compare(substring.data(),s,rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

**NB: s must have at least n2 characters, '\\0' has no special meaning.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos2, size\_type \_\_n2 = npos) const \[inline\], \[nodiscard\], \[constexpr\]

**Compare substring to a substring.**

**Parameters**

*\_\_pos1* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_str* **String to compare against.** \
 *\_\_pos2* **Index of first character of substring of str.** \
 *\_\_n2* **Number of characters in substring of str.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos1***. Form the substring of** *\_\_str* **from the** *\_\_n2* **characters starting at** *\_\_pos2***. Returns an integer \< 0 if this substring is ordered before the substring of** *\_\_str***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the substring of** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the lengths of the substrings. The function then compares the two strings by calling traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> int std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::compare (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos2, size\_type \_\_n2 = npos) const \[inline\]

**Compare substring to a substring.**

**Parameters**

*\_\_pos1* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_str* **String to compare against.** \
 *\_\_pos2* **Index of first character of substring of str.** \
 *\_\_n2* **Number of characters in substring of str.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos1***. Form the substring of** *\_\_str* **from the** *\_\_n2* **characters starting at** *\_\_pos2***. Returns an integer \< 0 if this substring is ordered before the substring of** *\_\_str***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the substring of** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the lengths of the substrings. The function then compares the two strings by calling traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos, size\_type \_\_n, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Compare substring to a string.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n* **Number of characters in substring.** \
 *\_\_str* **String to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n* **characters starting at** *\_\_pos***. Returns an integer \< 0 if the substring is ordered before** *\_\_str***, 0 if their values are equivalent, or \> 0 if the substring is ordered after** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_str.size()***. The function then compares the two strings by calling traits::compare(substring.data(),str.data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Compare substring to a C string.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_s* **C string to compare against.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *pos***. Returns an integer \< 0 if the substring is ordered before** *\_\_s***, 0 if their values are equivalent, or \> 0 if the substring is ordered after** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and the length of a string constructed from** *\_\_s***. The function then compares the two string by calling traits::compare(substring.data(),\_\_s,rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s, size\_type \_\_n2) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Compare substring against a character array.**

**Parameters**

*\_\_pos* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_s* **character array to compare against.** \
 *\_\_n2* **Number of characters of s.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos***. Form a string from the first** *\_\_n2* **characters of** *\_\_s***. Returns an integer \< 0 if this substring is ordered before the string from** *\_\_s***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the string from** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of the length of the substring and** *\_\_n2***. The function then compares the two strings by calling traits::compare(substring.data(),s,rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

**NB: s must have at least n2 characters, '\\0' has no special meaning.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos2, size\_type \_\_n2 = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Compare substring to a substring.**

**Parameters**

*\_\_pos1* **Index of first character of substring.** \
 *\_\_n1* **Number of characters in substring.** \
 *\_\_str* **String to compare against.** \
 *\_\_pos2* **Index of first character of substring of str.** \
 *\_\_n2* **Number of characters in substring of str.**

**Returns**

**Integer \< 0, 0, or \> 0.**

**Form the substring of this string from the** *\_\_n1* **characters starting at** *\_\_pos1***. Form the substring of** *\_\_str* **from the** *\_\_n2* **characters starting at** *\_\_pos2***. Returns an integer \< 0 if this substring is ordered before the substring of** *\_\_str***, 0 if their values are equivalent, or \> 0 if this substring is ordered after the substring of** *\_\_str***. Determines the effective length rlen of the strings to compare as the smallest of the lengths of the substrings. The function then compares the two strings by calling traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). If the result of the comparison is nonzero returns it, otherwise the shorter one is ordered first.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::copy (\_CharT \* \_\_s, size\_type \_\_n, size\_type \_\_pos = 0) const \[constexpr\], \[inherited\]

**Copy substring into C string.**

**Parameters**

*\_\_s* **C string to copy value into.** \
 *\_\_n* **Number of characters to copy.** \
 *\_\_pos* **Index of first character to copy.**

**Returns**

**Number of characters actually copied**

**Exceptions**

**std::out\_of\_range If \_\_pos \> size().**

**Copies up to** *\_\_n* **characters starting at** *\_\_pos* **into the C string** *\_\_s***. If** *\_\_pos* **is greater than size(), out\_of\_range is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> \_CharT \* std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data () \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Return non-const pointer to contents. This is a pointer to the character sequence held by the string. Modifying the characters in the sequence is allowed.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> bool std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::empty () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns true if the string is empty. Equivalent to** \*this == ""**.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (\_\_const\_iterator \_\_first, \_\_const\_iterator \_\_last) \[inline\], \[constexpr\], \[inherited\]

**Remove a range of characters.**

**Parameters**

*\_\_first* **Iterator referencing the first character to remove.** \
 *\_\_last* **Iterator referencing the end of the range.**

**Returns**

**Iterator referencing location of first after removal.**

**Removes the characters in the range \[first,last) from this string. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (\_\_const\_iterator \_\_position) \[inline\], \[constexpr\], \[inherited\]

**Remove one character.**

**Parameters**

*\_\_position* **Iterator referencing the character to remove.**

**Returns**

**iterator referencing same location after removal.**

**Removes the character at** *\_\_position* **from this string. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (iterator \_\_first, iterator \_\_last) \[inherited\]

**Remove a range of characters.**

**Parameters**

*\_\_first* **Iterator referencing the first character to remove.** \
 *\_\_last* **Iterator referencing the end of the range.**

**Returns**

**Iterator referencing location of first after removal.**

**Removes the characters in the range \[first,last) from this string. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (iterator \_\_position) \[inline\], \[inherited\]

**Remove one character.**

**Parameters**

*\_\_position* **Iterator referencing the character to remove.**

**Returns**

**iterator referencing same location after removal.**

**Removes the character at** *\_\_position* **from this string. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (size\_type \_\_pos = 0, size\_type \_\_n = npos) \[inline\], \[constexpr\], \[inherited\]

**Remove characters.**

**Parameters**

*\_\_pos* **Index of first character to remove (default 0).** \
 *\_\_n* **Number of characters to remove (default remainder).**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *pos* **is beyond the end of this string.**

**Removes** *\_\_n* **characters from this string starting at** *\_\_pos***. The length of the string is reduced by** *\_\_n***. If there are \<** *\_\_n* **characters to remove, the remainder of the string is truncated. If** *\_\_p* **is beyond end of string, out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

**Referenced by std::getline(), std::operator\>\>(), std::basic\_string\< \_CharT \>::pop\_back(), and resize().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (\_CharT \_\_c, size\_type \_\_pos = 0) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (\_CharT \_\_c, size\_type \_\_pos = 0) const \[noexcept\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from** *s* **to search for.**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from** *s* **to search for.**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a C string.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the value of** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[noexcept\]

**Find position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (\_CharT \_\_c, size\_type \_\_pos = 0) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from** *s* **to search for.**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

**References std::data(), npos, and std::size().**

**Referenced by std::basic\_string\< \_CharT \>::find(), std::basic\_string\< \_CharT \>::find(), std::basic\_string\< \_CharT \>::find(), and std::basic\_string\< \_CharT \>::find\_first\_of().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a C string.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the value of** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of start of first occurrence.**

**Starting from** *\_\_pos***, searches forward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[noexcept\]

**Find position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from \_\_s to consider.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from \_\_s to consider.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character not in C string.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[noexcept\]

**Find position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from \_\_s to consider.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character not in C string.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Referenced by std::basic\_string\< \_CharT \>::find\_first\_not\_of(), std::basic\_string\< \_CharT \>::find\_first\_not\_of(), and std::basic\_string\< \_CharT \>::find\_first\_not\_of().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the character** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to find(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[inline\], \[noexcept\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the character** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to find(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character of C substring.**

**Parameters**

*\_\_s* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find position of a character of C substring.**

**Parameters**

*\_\_s* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character of C string.**

**Parameters**

*\_\_s* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_first\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[noexcept\]

**Find position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of (\_CharT \_\_c, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for the character** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to find(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character of C substring.**

**Parameters**

*\_\_s* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character of C string.**

**Parameters**

*\_\_s* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = 0) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search from (default 0).**

**Returns**

**Index of first occurrence.**

**Starting from** *\_\_pos***, searches forward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Referenced by std::basic\_string\< \_CharT \>::find\_first\_of(), and std::basic\_string\< \_CharT \>::find\_first\_of().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[noexcept\]

**Find last position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to consider.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find last position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to consider.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character not in C string.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[noexcept\]

**Find last position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a different character.**

**Parameters**

*\_\_c* **Character to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character other than** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character not in C substring.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to consider.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character not in C string.**

**Parameters**

*\_\_s* **C string containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character not in string.**

**Parameters**

*\_\_str* **String containing characters to avoid.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for a character not contained in** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Referenced by std::basic\_string\< \_CharT \>::find\_last\_not\_of(), std::basic\_string\< \_CharT \>::find\_last\_not\_of(), and std::basic\_string\< \_CharT, std::char\_traits\< \_CharT \>, std::allocator\< \_CharT \> \>::swap().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to rfind(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[inline\], \[noexcept\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to rfind(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character of C substring.**

**Parameters**

*\_\_s* **C string containing characters to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find last position of a character of C substring.**

**Parameters**

*\_\_s* **C string containing characters to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character of C string.**

**Parameters**

*\_\_s* **C string containing characters to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::find\_last\_of (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[noexcept\]

**Find last position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of (\_CharT \_\_c, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Note: equivalent to rfind(\_\_c, \_\_pos).**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character of C substring.**

**Parameters**

*\_\_s* **C string containing characters to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the first** *\_\_n* **characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character of C string.**

**Parameters**

*\_\_s* **C string containing characters to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the characters of** *\_\_s* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character of string.**

**Parameters**

*\_\_str* **String containing characters to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for one of the characters of** *\_\_str* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**Referenced by std::basic\_string\< \_CharT \>::find\_last\_of(), and std::basic\_string\< \_CharT \>::find\_last\_of().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::front () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reference to the data at the first element of the string.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> reference std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::front () \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read/write reference to the data at the first element of the string.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> allocator\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::get\_allocator () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Return copy of allocator used to construct this string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (\_\_const\_iterator \_\_p, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Insert one character.**

**Parameters**

*\_\_p* **Iterator referencing position in string to insert at.** \
 *\_\_c* **The character to insert.**

**Returns**

**Iterator referencing newly inserted char.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts character** *\_\_c* **at position referenced by** *\_\_p***. If adding character causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_p* **is beyond end of string, out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (const\_iterator \_\_p, \_InputIterator \_\_beg, \_InputIterator \_\_end) \[inline\], \[constexpr\], \[inherited\]

**Insert a range of characters.**

**Parameters**

*\_\_p* **Const\_iterator referencing location in string to insert at.** \
 *\_\_beg* **Start of range.** \
 *\_\_end* **End of range.**

**Returns**

**Iterator referencing the first inserted char.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts characters in range \[beg,end). If adding characters causes the length to exceed max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (const\_iterator \_\_p, initializer\_list\< \_CharT \> \_\_l) \[inline\], \[constexpr\], \[inherited\]

**Insert an initializer\_list of characters.**

**Parameters**

*\_\_p* **Iterator referencing location in string to insert at.** \
 *\_\_l* **The initializer\_list of characters to insert.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (const\_iterator \_\_p, size\_type \_\_n, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Insert multiple characters.**

**Parameters**

*\_\_p* **Const\_iterator referencing location in string to insert at.** \
 *\_\_n* **Number of characters to insert** \
 *\_\_c* **The character to insert.**

**Returns**

**Iterator referencing the first inserted char.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts** *\_\_n* **copies of character** *\_\_c* **starting at the position referenced by iterator** *\_\_p***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

**Referenced by std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), and std::basic\_string\< \_CharT \>::insert().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (iterator \_\_p, \_CharT \_\_c) \[inline\], \[inherited\]

**Insert one character.**

**Parameters**

*\_\_p* **Iterator referencing position in string to insert at.** \
 *\_\_c* **The character to insert.**

**Returns**

**Iterator referencing newly inserted char.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts character** *\_\_c* **at position referenced by** *\_\_p***. If adding character causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_p* **is beyond end of string, out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (iterator \_\_p, \_InputIterator \_\_beg, \_InputIterator \_\_end) \[inline\], \[inherited\]

**Insert a range of characters.**

**Parameters**

*\_\_p* **Iterator referencing location in string to insert at.** \
 *\_\_beg* **Start of range.** \
 *\_\_end* **End of range.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts characters in range \[\_\_beg,\_\_end). If adding characters causes the length to exceed max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (iterator \_\_p, initializer\_list\< \_CharT \> \_\_l) \[inline\], \[inherited\]

**Insert an initializer\_list of characters.**

**Parameters**

*\_\_p* **Iterator referencing location in string to insert at.** \
 *\_\_l* **The initializer\_list of characters to insert.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (iterator \_\_p, size\_type \_\_n, \_CharT \_\_c) \[inline\], \[inherited\]

**Insert multiple characters.**

**Parameters**

*\_\_p* **Iterator referencing location in string to insert at.** \
 *\_\_n* **Number of characters to insert** \
 *\_\_c* **The character to insert.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts** *\_\_n* **copies of character** *\_\_c* **starting at the position referenced by iterator** *\_\_p***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos, const \_CharT \* \_\_s) \[inline\], \[constexpr\], \[inherited\]

**Insert a C string.**

**Parameters**

*\_\_pos* **Position in string to insert at.** \
 *\_\_s* **The C string to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.** \
 **std::out\_of\_range If** *pos* **is beyond the end of this string.**

**Inserts the first** *n* **characters of** *\_\_s* **starting at** *\_\_pos***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_pos* **is beyond end(), out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos, const \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[constexpr\], \[inherited\]

**Insert a C substring.**

**Parameters**

*\_\_pos* **Position in string to insert at.** \
 *\_\_s* **The C string to insert.** \
 *\_\_n* **The number of characters to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.** \
 **std::out\_of\_range If** *\_\_pos* **is beyond the end of this string.**

**Inserts the first** *\_\_n* **characters of** *\_\_s* **starting at** *\_\_pos***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_pos* **is beyond end(), out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos, size\_type \_\_n, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Insert multiple characters.**

**Parameters**

*\_\_pos* **Index in string to insert at.** \
 *\_\_n* **Number of characters to insert** \
 *\_\_c* **The character to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.** \
 **std::out\_of\_range If** *\_\_pos* **is beyond the end of this string.**

**Inserts** *\_\_n* **copies of character** *\_\_c* **starting at index** *\_\_pos***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_pos* **\> length(), out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos1, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

**Insert value of a string.**

**Parameters**

*\_\_pos1* **Position in string to insert at.** \
 *\_\_str* **The string to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Inserts value of** *\_\_str* **starting at** *\_\_pos1***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos1, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos2, size\_type \_\_n = npos) \[inline\], \[constexpr\], \[inherited\]

**Insert a substring.**

**Parameters**

*\_\_pos1* **Position in string to insert at.** \
 *\_\_str* **The string to insert.** \
 *\_\_pos2* **Start of characters in str to insert.** \
 *\_\_n* **Number of characters to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.** \
 **std::out\_of\_range If** *pos1* **\> size() or** *\_\_pos2* **\>** *str.size()***.**

**Starting at** *pos1***, insert** *\_\_n* **character of** *\_\_str* **beginning with** *\_\_pos2***. If adding characters causes the length to exceed max\_size(), length\_error is thrown. If** *\_\_pos1* **is beyond the end of this string or** *\_\_pos2* **is beyond the end of** *\_\_str***, out\_of\_range is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::length () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns the number of characters in the string, not including any null-termination.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::max\_size () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns the size() of the largest possible string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+= (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

**Append a string to this string.**

**Parameters**

*\_\_str* **The string to append.**

**Returns**

**Reference to this string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\] (size\_type \_\_pos) \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Subscript access to the data contained in the string.**

**Parameters**

*\_\_pos* **The index of the character to access.**

**Returns**

**Read/write reference to the character.**

**This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out\_of\_range lookups are not defined. (For checked lookups see at().)**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\] (size\_type \_\_pos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Subscript access to the data contained in the string.**

**Parameters**

*\_\_pos* **The index of the character to access.**

**Returns**

**Read-only (constant) reference to the character.**

**This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out\_of\_range lookups are not defined. (For checked lookups see at().)**

**Referenced by std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::front(), std::basic\_string\< \_CharT \>::front(), and std::basic\_string\< \_CharT \>::front().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \* \_\_s) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with C string.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_s* **C string value to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the characters of** *\_\_s* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with C substring.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_s* **C string value to insert.** \
 *\_\_n* **Number of characters from s to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the first** *\_\_n* **characters of** *\_\_s* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with string.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_str* **String value to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the value of** *\_\_str* **is inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (\_\_const\_iterator \_\_i1, \_\_const\_iterator \_\_i2, size\_type \_\_n, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with multiple characters.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_n* **Number of characters to insert.** \
 *\_\_c* **Character to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place,** *\_\_n* **copies of** *\_\_c* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (const\_iterator \_\_i1, const\_iterator \_\_i2, \_InputIterator \_\_k1, \_InputIterator \_\_k2) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with range.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_k1* **Iterator referencing start of range to insert.** \
 *\_\_k2* **Iterator referencing end of range to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, characters in the range \[\_\_k1,\_\_k2) are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (const\_iterator \_\_i1, const\_iterator \_\_i2, initializer\_list\< \_CharT \> \_\_l) \[inline\], \[constexpr\], \[inherited\]

**Replace range of characters with initializer\_list.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_l* **The initializer\_list of characters to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, characters in the range \[\_\_k1,\_\_k2) are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, \_InputIterator \_\_k1, \_InputIterator \_\_k2) \[inline\], \[inherited\]

**Replace range of characters with range.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_k1* **Iterator referencing start of range to insert.** \
 *\_\_k2* **Iterator referencing end of range to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, characters in the range \[\_\_k1,\_\_k2) are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, const \_CharT \* \_\_s) \[inline\], \[inherited\]

**Replace range of characters with C string.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_s* **C string value to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the characters of** *\_\_s* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, const \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[inherited\]

**Replace range of characters with C substring.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_s* **C string value to insert.** \
 *\_\_n* **Number of characters from s to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the first** *\_\_n* **characters of** *\_\_s* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[inherited\]

**Replace range of characters with string.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_str* **String value to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, the value of** *\_\_str* **is inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, initializer\_list\< \_CharT \> \_\_l) \[inline\], \[inherited\]

**Replace range of characters with initializer\_list.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_l* **The initializer\_list of characters to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place, characters in the range \[\_\_k1,\_\_k2) are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (iterator \_\_i1, iterator \_\_i2, size\_type \_\_n, \_CharT \_\_c) \[inline\], \[inherited\]

**Replace range of characters with multiple characters.**

**Parameters**

*\_\_i1* **Iterator referencing start of range to replace.** \
 *\_\_i2* **Iterator referencing end of range to replace.** \
 *\_\_n* **Number of characters to insert.** \
 *\_\_c* **Character to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_i1,\_\_i2). In place,** *\_\_n* **copies of** *\_\_c* **are inserted. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\], \[constexpr\], \[inherited\]

**Replace characters with value from another string.**

**Parameters**

*\_\_pos* **Index of first character to replace.** \
 *\_\_n* **Number of characters to be replaced.** \
 *\_\_str* **String to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *pos* **is beyond the end of this string.** \
 **std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_pos,\_\_pos+\_\_n) from this string. In place, the value of** *\_\_str* **is inserted. If** *\_\_pos* **is beyond end of string, out\_of\_range is thrown. If the length of the result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

**Referenced by std::basic\_string\< \_CharT \>::append(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), and std::basic\_string\< \_CharT \>::replace().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s) \[inline\], \[constexpr\], \[inherited\]

**Replace characters with value of a C string.**

**Parameters**

*\_\_pos* **Index of first character to replace.** \
 *\_\_n1* **Number of characters to be replaced.** \
 *\_\_s* **C string to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *pos* **\> size().** \
 **std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_pos,\_\_pos + \_\_n1) from this string. In place, the characters of** *\_\_s* **are inserted. If** *\_\_pos* **is beyond end of string, out\_of\_range is thrown. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \> & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s, size\_type \_\_n2) \[inline\], \[constexpr\], \[inherited\]

**Replace characters with value of a C substring.**

**Parameters**

*\_\_pos* **Index of first character to replace.** \
 *\_\_n1* **Number of characters to be replaced.** \
 *\_\_s* **C string to insert.** \
 *\_\_n2* **Number of characters from** *s* **to use.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *pos1* **\> size().** \
 **std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_pos,\_\_pos + \_\_n1) from this string. In place, the first** *\_\_n2* **characters of** *\_\_s* **are inserted, or all of** *\_\_s* **if** *\_\_n2* **is too large. If** *\_\_pos* **is beyond end of string, out\_of\_range is thrown. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n1, size\_type \_\_n2, \_CharT \_\_c) \[inline\], \[constexpr\], \[inherited\]

**Replace characters with multiple characters.**

**Parameters**

*\_\_pos* **Index of first character to replace.** \
 *\_\_n1* **Number of characters to be replaced.** \
 *\_\_n2* **Number of characters to insert.** \
 *\_\_c* **Character to insert.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos* **\> size().** \
 **std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[pos,pos + n1) from this string. In place,** *\_\_n2* **copies of** *\_\_c* **are inserted. If** *\_\_pos* **is beyond end of string, out\_of\_range is thrown. If the length of result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos1, size\_type \_\_n1, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos2, size\_type \_\_n2 = npos) \[inline\], \[constexpr\], \[inherited\]

**Replace characters with value from another string.**

**Parameters**

*\_\_pos1* **Index of first character to replace.** \
 *\_\_n1* **Number of characters to be replaced.** \
 *\_\_str* **String to insert.** \
 *\_\_pos2* **Index of first character of str to use.** \
 *\_\_n2* **Number of characters from str to use.**

**Returns**

**Reference to this string.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos1* **\> size() or** *\_\_pos2* **\> \_\_str.size().** \
 **std::length\_error If new length exceeds** max\_size()**.**

**Removes the characters in the range \[\_\_pos1,\_\_pos1 + n) from this string. In place, the value of** *\_\_str* **is inserted. If** *\_\_pos* **is beyond end of string, out\_of\_range is thrown. If the length of the result exceeds max\_size(), length\_error is thrown. The value of the string doesn't change if an error is thrown.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> void std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::reserve () \[constexpr\]

**Equivalent to shrink\_to\_fit().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> void std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::reserve (size\_type \_\_res\_arg) \[constexpr\]

**Attempt to preallocate enough memory for specified number of characters.**

**Parameters**

*\_\_res\_arg* **Number of characters required.**

**Exceptions**

**std::length\_error If** *\_\_res\_arg* **exceeds** max\_size()**.**

**This function attempts to reserve enough memory for the string to hold the specified number of characters. If the number requested is more than max\_size(), length\_error is thrown.**

**The advantage of this function is that if optimal code is a necessity and the user can determine the string length that will be required, the user can reserve the memory in advance, and thus prevent a possible reallocation of memory and copying of string data.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> void std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::reserve (size\_type \_\_res\_arg)

**Attempt to preallocate enough memory for specified number of characters.**

**Parameters**

*\_\_res\_arg* **Number of characters required.**

**Exceptions**

**std::length\_error If** *\_\_res\_arg* **exceeds** max\_size()**.**

**This function attempts to reserve enough memory for the string to hold the specified number of characters. If the number requested is more than max\_size(), length\_error is thrown.**

**The advantage of this function is that if optimal code is a necessity and the user can determine the string length that will be required, the user can reserve the memory in advance, and thus prevent a possible reallocation of memory and copying of string data.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::reserve (size\_type \_\_res\_arg) \[constexpr\], \[inherited\]

**Attempt to preallocate enough memory for specified number of characters.**

**Parameters**

*\_\_res\_arg* **Number of characters required.**

**Exceptions**

**std::length\_error If** *\_\_res\_arg* **exceeds** max\_size()**.**

**This function attempts to reserve enough memory for the string to hold the specified number of characters. If the number requested is more than max\_size(), length\_error is thrown.**

**The advantage of this function is that if optimal code is a necessity and the user can determine the string length that will be required, the user can reserve the memory in advance, and thus prevent a possible reallocation of memory and copying of string data.**

**References capacity(), get\_allocator(), and std::size().**

**Referenced by std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::tr2::operator\>\>(), and std::basic\_stringbuf\< \_CharT, \_Traits, \_Alloc \>::overflow().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::resize (size\_type \_\_n) \[inline\], \[constexpr\], \[inherited\]

**Resizes the string to the specified number of characters.**

**Parameters**

*\_\_n* **Number of characters the string should contain.**

**This function will resize the string to the specified length. If the new size is smaller than the string's current size the string is truncated, otherwise the string is extended and new characters are default-constructed. For basic types such as char, this means setting them to 0.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::resize (size\_type \_\_n, \_CharT \_\_c) \[constexpr\], \[inherited\]

**Resizes the string to the specified number of characters.**

**Parameters**

*\_\_n* **Number of characters the string should contain.** \
 *\_\_c* **Character to fill any new elements.**

**This function will resize the string to the specified number of characters. If the number is smaller than the string's current size the string is truncated, otherwise the string is extended and new elements are set to** *\_\_c***.**

**References append(), erase(), and size().**

**Referenced by std::basic\_string\< \_CharT \>::resize().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (\_CharT \_\_c, size\_type \_\_pos = npos) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (\_CharT \_\_c, size\_type \_\_pos = npos) const \[noexcept\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[noexcept\]

**Find last position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\]

**Find last position of a C string.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to start search at (default end).**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for the value of** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Find last position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::rfind (const basic\_string\< \_CharT, \_Traits, \_Allocator \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[noexcept\]

**Find last position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (\_CharT \_\_c, size\_type \_\_pos = npos) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a character.**

**Parameters**

*\_\_c* **Character to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of last occurrence.**

**Starting from** *\_\_pos***, searches backward for** *\_\_c* **within this string. If found, returns the index where it was found. If not found, returns npos.**

**References npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a C substring.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to search back from.** \
 *\_\_n* **Number of characters from s to search for.**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for the first** *\_\_n* **characters in** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

**References std::min(), npos, and std::size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Find last position of a C string.**

**Parameters**

*\_\_s* **C string to locate.** \
 *\_\_pos* **Index of character to start search at (default end).**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for the value of** *\_\_s* **within this string. If found, returns the index where it begins. If not found, returns npos.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\], \[inherited\]

**Find last position of a string.**

**Parameters**

*\_\_str* **String to locate.** \
 *\_\_pos* **Index of character to search back from (default end).**

**Returns**

**Index of start of last occurrence.**

**Starting from** *\_\_pos***, searches backward for value of** *\_\_str* **within this string. If found, returns the index where it begins. If not found, returns npos.**

**Referenced by std::basic\_string\< \_CharT \>::find\_last\_of(), std::basic\_string\< \_CharT \>::rfind(), std::basic\_string\< \_CharT \>::rfind(), std::basic\_string\< \_CharT \>::rfind(), and std::basic\_string\< \_CharT \>::rfind().**

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::size () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns the number of characters in the string, not including any null-termination.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::substr (size\_type \_\_pos = 0, size\_type \_\_n = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Get a substring.**

**Parameters**

*\_\_pos* **Index of first character (default 0).** \
 *\_\_n* **Number of characters in substring (default remainder).**

**Returns**

**The new string.**

**Exceptions**

**std::out\_of\_range If \_\_pos \> size().**

**Construct and return a new string using the** *\_\_n* **characters starting at** *\_\_pos***. If the string is too short, use the remainder of the characters. If** *\_\_pos* **is beyond the end of the string, out\_of\_range is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\_view\< \_CharT, \_Traits \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::subview (size\_type \_\_pos = 0, size\_type \_\_n = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Get a subview.**

**Parameters**

*\_\_pos* **Index of first character (default 0).** \
 *\_\_n* **Number of characters in subview (default remainder).**

**Returns**

**The subview.**

**Exceptions**

**std::out\_of\_range If \_\_pos \> size().**

**Construct and return a subview using the** \_\_n **characters starting at** \_\_pos**. If the string is too short, use the remainder of the characters. If** \_\_pos **is beyond the end of the string, out\_of\_range is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string\_view\< \_CharT, \_Traits \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::subview (size\_type \_\_pos = 0, size\_type \_\_n = npos) const \[inline\], \[nodiscard\], \[constexpr\], \[inherited\]

**Get a subview.**

**Parameters**

*\_\_pos* **Index of first character (default 0).** \
 *\_\_n* **Number of characters in subview (default remainder).**

**Returns**

**The subview.**

**Exceptions**

**std::out\_of\_range If \_\_pos \> size().**

**Construct and return a subview using the** \_\_n **characters starting at** \_\_pos**. If the string is too short, use the remainder of the characters. If** \_\_pos **is beyond the end of the string, out\_of\_range is thrown.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::swap (basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_s) \[constexpr\], \[noexcept\], \[inherited\]

**Swap contents with another string.**

**Parameters**

*\_\_s* **String to swap with.**

**Exchanges the contents of this string with that of** *\_\_s* **in constant time.**

**References basic\_string(), and get\_allocator().**

**Referenced by std::basic\_string\< \_CharT \>::assign(), and std::basic\_string\< \_CharT \>::operator=().**

## Member Data Documentation

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Allocator = std::allocator\<\_CharT\>\> const size\_type std::basic\_string\< \_CharT, \_Traits, \_Allocator \>::npos \[static\]

**Value returned by various member functions when they fail.**

## Author

**Generated automatically by Doxygen for libstdc++ from the source code.**
