---
name: "std::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/std::basic_string"
---

# std::string(3)

Managing sequences of characters and character-like objects.

Part of [std::basic\_string(3)](/std::basic_string/3.md).

## NAME

std::basic\_string\< \_CharT, \_Traits, \_Alloc \> - Managing sequences of characters and character-like objects.

## SYNOPSIS

\#include \<string\>

Inherited by **\_\_gnu\_debug::basic\_string\< char \>**, **\_\_gnu\_debug::basic\_string\< wchar\_t \>**, **\_\_gnu\_debug::basic\_string\< char16\_t \>**, **\_\_gnu\_debug::basic\_string\< char32\_t \>**, and **\_\_gnu\_debug::basic\_string\< \_CharT, \_Traits, \_Allocator \>**.

### Public Types

typedef \_Char\_alloc\_type **allocator\_type**\
 typedef \_Alloc **allocator\_type**\
 typedef \_\_gnu\_cxx::\_\_normal\_iterator\< const\_pointer, **basic\_string** \> **const\_iterator**\
 typedef \_\_gnu\_cxx::\_\_normal\_iterator\< const\_pointer, **basic\_string** \> **const\_iterator**\
 typedef \_Alloc\_traits::const\_pointer **const\_pointer**\
 typedef \_CharT\_alloc\_traits::const\_pointer **const\_pointer**\
 typedef \_Alloc\_traits::const\_reference **const\_reference**\
 typedef const value\_type & **const\_reference**\
 typedef **std::reverse\_iterator**\< const\_iterator \> **const\_reverse\_iterator**\
 typedef **std::reverse\_iterator**\< const\_iterator \> **const\_reverse\_iterator**\
 typedef \_Alloc\_traits::difference\_type **difference\_type**\
 typedef \_CharT\_alloc\_traits::difference\_type **difference\_type**\
 typedef \_\_gnu\_cxx::\_\_normal\_iterator\< pointer, **basic\_string** \> **iterator**\
 typedef \_\_gnu\_cxx::\_\_normal\_iterator\< pointer, **basic\_string** \> **iterator**\
 typedef \_Alloc\_traits::pointer **pointer**\
 typedef \_CharT\_alloc\_traits::pointer **pointer**\
 typedef \_Alloc\_traits::reference **reference**\
 typedef value\_type & **reference**\
 typedef **std::reverse\_iterator**\< iterator \> **reverse\_iterator**\
 typedef **std::reverse\_iterator**\< iterator \> **reverse\_iterator**\
 typedef \_Alloc\_traits::size\_type **size\_type**\
 typedef \_CharT\_alloc\_traits::size\_type **size\_type**\
 typedef \_Traits **traits\_type**\
 typedef \_Traits **traits\_type**\
 typedef \_Traits::char\_type **value\_type**\
 typedef \_Traits::char\_type **value\_type**\

### Public Member Functions

**basic\_string** () noexcept\
 Default constructor creates an empty string.  constexpr **basic\_string** () noexcept(/\***conditional** \*/)\
 Default constructor creates an empty string.  template\<typename \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> constexpr **basic\_string** (\_InputIterator \_\_beg, \_InputIterator \_\_end, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a range.  template\<class \_InputIterator\> **basic\_string** (\_InputIterator \_\_beg, \_InputIterator \_\_end, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a range.  constexpr **basic\_string** (basic\_string &&\_\_str) noexcept\
 Move construct string.  **basic\_string** (basic\_string &&\_\_str) noexcept\
 Move construct string.  **basic\_string** (basic\_string &&\_\_str, const \_Alloc &\_\_a)\
 constexpr **basic\_string** (basic\_string &&\_\_str, const \_Alloc &\_\_a) noexcept(\_Alloc\_traits::\_S\_always\_equal())\
 constexpr **basic\_string** (basic\_string &&\_\_str, size\_type \_\_pos, const \_Alloc &\_\_a=\_Alloc())\
 constexpr **basic\_string** (basic\_string &&\_\_str, size\_type \_\_pos, size\_type \_\_n, const \_Alloc &\_\_a=\_Alloc())\
 **basic\_string** (const \_Alloc &\_\_a)\
 Construct an empty string using allocator *a*.  constexpr **basic\_string** (const \_Alloc &\_\_a) noexcept\
 Construct an empty string using allocator *a*.  template\<typename = \_RequireAllocator\<\_Alloc\>\> constexpr **basic\_string** (const \_CharT \*\_\_s, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a C string.  template\<typename = \_RequireAllocator\<\_Alloc\>\> **basic\_string** (const \_CharT \*\_\_s, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a C string.  constexpr **basic\_string** (const \_CharT \*\_\_s, size\_type \_\_n, const \_Alloc &\_\_a=\_Alloc())\
 Construct string initialized by a character array.  **basic\_string** (const \_CharT \*\_\_s, size\_type \_\_n, const \_Alloc &\_\_a=\_Alloc())\
 Construct string initialized by a character array.  constexpr **basic\_string** (const basic\_string &\_\_str)\
 Construct string with copy of value of *\_\_str*.  **basic\_string** (const basic\_string &\_\_str)\
 Construct string with copy of value of *str*.  constexpr **basic\_string** (const basic\_string &\_\_str, const \_Alloc &\_\_a)\
 **basic\_string** (const basic\_string &\_\_str, const \_Alloc &\_\_a)\
 constexpr **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a substring.  **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a substring.  constexpr **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n)\
 Construct string as copy of a substring.  **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n)\
 Construct string as copy of a substring.  constexpr **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n, const \_Alloc &\_\_a)\
 Construct string as copy of a substring.  **basic\_string** (const basic\_string &\_\_str, size\_type \_\_pos, size\_type \_\_n, const \_Alloc &\_\_a)\
 Construct string as copy of a substring.  constexpr **basic\_string** (**initializer\_list**\< \_CharT \> \_\_l, const \_Alloc &\_\_a=\_Alloc())\
 Construct string from an initializer list.  **basic\_string** (**initializer\_list**\< \_CharT \> \_\_l, const \_Alloc &\_\_a=\_Alloc())\
 Construct string from an initializer list.  **basic\_string** (nullptr\_t)=delete\
 **basic\_string** (nullptr\_t)=delete\
 template\<typename = \_RequireAllocator\<\_Alloc\>\> constexpr **basic\_string** (size\_type \_\_n, \_CharT \_\_c, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as multiple characters.  **basic\_string** (size\_type \_\_n, \_CharT \_\_c, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as multiple characters.  constexpr **~basic\_string** ()\
 Destroy the string instance.  **~basic\_string** () noexcept\
 Destroy the string instance.  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.  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\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> constexpr **basic\_string** & **append** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 Append a range of characters.  template\<class \_InputIterator\> **basic\_string** & **append** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 Append a range of characters.  constexpr **basic\_string** & **append** (const \_CharT \*\_\_s)\
 Append a C string.  **basic\_string** & **append** (const \_CharT \*\_\_s)\
 Append a C string.  constexpr **basic\_string** & **append** (const \_CharT \*\_\_s, size\_type \_\_n)\
 Append a C substring.  **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.  **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.  **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.  **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.  **basic\_string** & **append** (size\_type \_\_n, \_CharT \_\_c)\
 Append multiple characters.  template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> constexpr **basic\_string** & **assign** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 Set value to a range of characters.  template\<class \_InputIterator\> **basic\_string** & **assign** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 Set value to a range of characters.  constexpr **basic\_string** & **assign** (**basic\_string** &&\_\_str) noexcept(\_Alloc\_traits::\_S\_nothrow\_move())\
 Set value to contents of another string.  **basic\_string** & **assign** (**basic\_string** &&\_\_str) noexcept(**allocator\_traits**\< \_Alloc \>::is\_always\_equal::value)\
 Set value to contents of another string.  constexpr **basic\_string** & **assign** (const \_CharT \*\_\_s)\
 Set value to contents of a C string.  **basic\_string** & **assign** (const \_CharT \*\_\_s)\
 Set value to contents of a C string.  constexpr **basic\_string** & **assign** (const \_CharT \*\_\_s, size\_type \_\_n)\
 Set value to a C substring.  **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.  **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.  **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** (**initializer\_list**\< \_CharT \> \_\_l)\
 Set value to an initializer\_list of characters.  **basic\_string** & **assign** (**initializer\_list**\< \_CharT \> \_\_l)\
 Set value to an initializer\_list of characters.  constexpr **basic\_string** & **assign** (size\_type \_\_n, \_CharT \_\_c)\
 Set value to multiple characters.  **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.  reference **back** ()\
 constexpr const\_reference **back** () const noexcept\
 const\_reference **back** () const noexcept\
 constexpr reference **back** () noexcept\
 iterator **begin** ()\
 constexpr const\_iterator **begin** () const noexcept\
 const\_iterator **begin** () const noexcept\
 constexpr iterator **begin** () noexcept\
 constexpr const \_CharT \* **c\_str** () const noexcept\
 Return const pointer to null-terminated contents.  const \_CharT \* **c\_str** () const noexcept\
 Return const pointer to null-terminated contents.  constexpr size\_type **capacity** () const noexcept\
 size\_type **capacity** () const noexcept\
 constexpr const\_iterator **cbegin** () const noexcept\
 const\_iterator **cbegin** () const noexcept\
 constexpr const\_iterator **cend** () const noexcept\
 const\_iterator **cend** () const noexcept\
 constexpr void **clear** () noexcept\
 void **clear** () noexcept\
 constexpr int **compare** (const \_CharT \*\_\_s) const noexcept\
 Compare to a C string.  int **compare** (const \_CharT \*\_\_s) const noexcept\
 Compare to a C string.  constexpr int **compare** (const **basic\_string** &\_\_str) const\
 Compare to a string.  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.  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 **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 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\
 constexpr size\_type **copy** (\_CharT \*\_\_s, size\_type \_\_n, size\_type \_\_pos=0) const\
 Copy substring into C string.  size\_type **copy** (\_CharT \*\_\_s, size\_type \_\_n, size\_type \_\_pos=0) const\
 Copy substring into C string.  constexpr const\_reverse\_iterator **crbegin** () const noexcept\
 const\_reverse\_iterator **crbegin** () const noexcept\
 constexpr const\_reverse\_iterator **crend** () const noexcept\
 const\_reverse\_iterator **crend** () const noexcept\
 constexpr const \_CharT \* **data** () const noexcept\
 Return const pointer to contents.  const \_CharT \* **data** () const noexcept\
 Return const pointer to contents.  constexpr \_CharT \* **data** () noexcept\
 Return non-const pointer to contents.  \_CharT \* **data** () noexcept(false)\
 Return non-const pointer to contents.  constexpr bool **empty** () const noexcept\
 bool **empty** () const noexcept\
 iterator **end** ()\
 constexpr const\_iterator **end** () const noexcept\
 const\_iterator **end** () const noexcept\
 constexpr iterator **end** () 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\
 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.  **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\
 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\
 Find position of a C string.  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\_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\
 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\
 Find position of a character not in C string.  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\_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\
 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\
 Find position of a character of C string.  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\_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\
 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=**npos**) const noexcept\
 Find last position of a character not in C string.  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\_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\
 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=**npos**) const noexcept\
 Find last position of a character of C string.  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.  reference **front** ()\
 constexpr const\_reference **front** () const noexcept\
 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.  allocator\_type **get\_allocator** () const noexcept\
 Return copy of allocator used to construct this string.  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.  **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.  **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.  **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.  **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.  **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.  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.  size\_type **max\_size** () const noexcept\
 Returns the size() of the largest possible string.  constexpr **basic\_string** & **operator+=** (\_CharT \_\_c)\
 Append a character.  **basic\_string** & **operator+=** (\_CharT \_\_c)\
 Append a character.  constexpr **basic\_string** & **operator+=** (const \_CharT \*\_\_s)\
 Append a C string.  **basic\_string** & **operator+=** (const \_CharT \*\_\_s)\
 Append a C string.  constexpr **basic\_string** & **operator+=** (const **basic\_string** &\_\_str)\
 Append a string to this string.  **basic\_string** & **operator+=** (const **basic\_string** &\_\_str)\
 Append a string to this string.  constexpr **basic\_string** & **operator+=** (**initializer\_list**\< \_CharT \> \_\_l)\
 Append an initializer\_list of characters.  **basic\_string** & **operator+=** (**initializer\_list**\< \_CharT \> \_\_l)\
 Append an initializer\_list of characters.  constexpr **basic\_string** & **operator=** (\_CharT \_\_c)\
 Set value to string of length 1.  **basic\_string** & **operator=** (\_CharT \_\_c)\
 Set value to string of length 1.  **basic\_string** & **operator=** (**basic\_string** &&\_\_str) noexcept(/\***conditional** \*/)\
 Move assign the value of *str* to this string.  constexpr **basic\_string** & **operator=** (**basic\_string** &&\_\_str) noexcept(\_Alloc\_traits::\_S\_nothrow\_move())\
 Move assign the value of *str* to this string.  constexpr **basic\_string** & **operator=** (const \_CharT \*\_\_s)\
 Copy contents of *s* into this string.  **basic\_string** & **operator=** (const \_CharT \*\_\_s)\
 Copy contents of *s* into this string.  constexpr **basic\_string** & **operator=** (const **basic\_string** &\_\_str)\
 Assign the value of *str* to this string.  **basic\_string** & **operator=** (const **basic\_string** &\_\_str)\
 Assign the value of *str* to this string.  constexpr **basic\_string** & **operator=** (**initializer\_list**\< \_CharT \> \_\_l)\
 Set value to string constructed from initializer list.  **basic\_string** & **operator=** (**initializer\_list**\< \_CharT \> \_\_l)\
 Set value to string constructed from initializer list.  **basic\_string** & **operator=** (nullptr\_t)=delete\
 **basic\_string** & **operator=** (nullptr\_t)=delete\
 constexpr reference **operator\[\]** (size\_type \_\_pos)\
 Subscript access to the data contained in the string.  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.  const\_reference **operator\[\]** (size\_type \_\_pos) const noexcept\
 Subscript access to the data contained in the string.  void **pop\_back** ()\
 Remove the last character.  constexpr void **pop\_back** () noexcept\
 Remove the last character.  constexpr void **push\_back** (\_CharT \_\_c)\
 Append a single character.  void **push\_back** (\_CharT \_\_c)\
 Append a single character.  reverse\_iterator **rbegin** ()\
 constexpr const\_reverse\_iterator **rbegin** () const noexcept\
 const\_reverse\_iterator **rbegin** () const noexcept\
 constexpr reverse\_iterator **rbegin** () noexcept\
 reverse\_iterator **rend** ()\
 constexpr const\_reverse\_iterator **rend** () const noexcept\
 const\_reverse\_iterator **rend** () const noexcept\
 constexpr reverse\_iterator **rend** () noexcept\
 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.  **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.  **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.  **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.  **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.  **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** ()\
 void **reserve** ()\
 Equivalent to shrink\_to\_fit().  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 **resize** (size\_type \_\_n)\
 Resizes the string to the specified number of characters.  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.  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 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=**npos**) const\
 Find last position of a C string.  size\_type **rfind** (const \_CharT \*\_\_s, size\_type \_\_pos=**npos**) const noexcept\
 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 void **shrink\_to\_fit** () noexcept\
 A non-binding request to reduce capacity() to size().  void **shrink\_to\_fit** () noexcept\
 A non-binding request to reduce capacity() to size().  constexpr size\_type **size** () const noexcept\
 Returns the number of characters in the string, not including any null-termination.  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\
 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.  **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.  constexpr void **swap** (**basic\_string** &\_\_s) noexcept\
 Swap contents with another string.  void **swap** (**basic\_string** &\_\_s) noexcept(/\***conditional** \*/)\
 Swap contents with another string.

### Static Public Attributes

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

### Protected Types

typedef const\_iterator **\_\_const\_iterator**\
 typedef iterator **\_\_const\_iterator**\

### Friends

template\<typename, typename, typename\> class **basic\_stringbuf**\

## Detailed Description

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\>

class std::basic\_string\< \_CharT, \_Traits, \_Alloc \>"Managing sequences of characters and character-like objects.

**Since**

C++98

**Template Parameters**

*\_CharT* Type of character \
 *\_Traits* Traits for character type, defaults to char\_traits\<\_CharT\>. \
 *\_Alloc* Allocator type, defaults to allocator\<\_CharT\>.

Meets the requirements of a container, a reversible container, and a sequence. Of the optional sequence requirements, only push\_back, at, and array access are supported.

**Since**

C++98

**Template Parameters**

*\_CharT* Type of character \
 *\_Traits* Traits for character type, defaults to char\_traits\<\_CharT\>. \
 *\_Alloc* Allocator type, defaults to allocator\<\_CharT\>.

Meets the requirements of a container, a reversible container, and a sequence. Of the optional sequence requirements, only push\_back, at, and array access are supported.

**Todo**

Needs documentation! See http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation\_style.html

Documentation? What's that? Nathan Myers ncm@cantrip.org.

A string looks like this:

```
                                     [_Rep]
                                     _M_length
[basic_string<char_type>]            _M_capacity
_M_dataplus                          _M_refcount
_M_p ---------------->               unnamed array of char_type
```

Where the \_M\_p points to the first character in the string, and you cast it to a pointer-to-\_Rep and subtract 1 to get a pointer to the header.

This approach has the enormous advantage that a string object requires only one allocation. All the ugliness is confined within a single pair of inline functions, which each compile to a single *add* instruction: \_Rep::\_M\_data(), and string::\_M\_rep(); and the allocation function which gets a block of raw bytes and with room enough and constructs a \_Rep object at the front.

The reason you want \_M\_data pointing to the character array and not the \_Rep is so that the debugger can see the string contents. (Probably we should add a non-inline member to get the \_Rep for the debugger to use, so users can check the actual string length.)

Note that the \_Rep object is a POD so that you can have a static *empty string* \_Rep object already *constructed* before static constructors have run. The reference-count encoding is chosen so that a 0 indicates one reference, so you never try to destroy the empty-string \_Rep object.

All but the last paragraph is considered pretty conventional for a Copy-On-Write C++ string implementation.

## Constructor & Destructor Documentation

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

Default constructor creates an empty string.

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_Alloc & \_\_a) \[inline\], \[explicit\], \[constexpr\], \[noexcept\]

Construct an empty string using allocator *a*.

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

Construct string with copy of value of *\_\_str*.

**Parameters**

*\_\_str* Source string.

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

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_a* Allocator to use.

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

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_n* Number of characters to copy.

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

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_n* Number of characters to copy. \
 *\_\_a* Allocator to use.

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

Construct string initialized by a character array.

**Parameters**

*\_\_s* Source character array. \
 *\_\_n* Number of characters to copy. \
 *\_\_a* Allocator to use (default is default allocator).

NB: *\_\_s* must have at least *\_\_n* characters, '\\0' has no special meaning.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<typename = \_RequireAllocator\<\_Alloc\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_CharT \* \_\_s, const \_Alloc & \_\_a = \_Alloc()) \[inline\], \[constexpr\]

Construct string as copy of a C string.

**Parameters**

*\_\_s* Source C string. \
 *\_\_a* Allocator to use (default is default allocator).

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

Construct string as multiple characters.

**Parameters**

*\_\_n* Number of characters. \
 *\_\_c* Character to use. \
 *\_\_a* Allocator to use (default is default allocator).

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

Move construct string.

**Parameters**

*\_\_str* Source string.

The newly-created string contains the exact contents of *\_\_str*. *\_\_str* is a valid, but unspecified string.

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

Construct string from an initializer list.

**Parameters**

*\_\_l* std::initializer\_list of characters. \
 *\_\_a* Allocator to use (default is default allocator).

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<typename \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (\_InputIterator \_\_beg, \_InputIterator \_\_end, const \_Alloc & \_\_a = \_Alloc()) \[inline\], \[constexpr\]

Construct string as copy of a range.

**Parameters**

*\_\_beg* Start of range. \
 *\_\_end* End of range. \
 *\_\_a* Allocator to use (default is default allocator).

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::~basic\_string () \[inline\], \[constexpr\]

Destroy the string instance.

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

Default constructor creates an empty string.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_Alloc & \_\_a) \[inline\], \[explicit\]

Construct an empty string using allocator *a*.

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

Construct string with copy of value of *str*.

**Parameters**

*\_\_str* Source string.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, const \_Alloc & \_\_a = \_Alloc())

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_a* Allocator to use.

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

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_n* Number of characters to copy.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, size\_type \_\_n, const \_Alloc & \_\_a)

Construct string as copy of a substring.

**Parameters**

*\_\_str* Source string. \
 *\_\_pos* Index of first character to copy from. \
 *\_\_n* Number of characters to copy. \
 *\_\_a* Allocator to use.

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

Construct string initialized by a character array.

**Parameters**

*\_\_s* Source character array. \
 *\_\_n* Number of characters to copy. \
 *\_\_a* Allocator to use (default is default allocator).

NB: *\_\_s* must have at least *\_\_n* characters, '\\0' has no special meaning.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<typename = \_RequireAllocator\<\_Alloc\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_CharT \* \_\_s, const \_Alloc & \_\_a = \_Alloc()) \[inline\]

Construct string as copy of a C string.

**Parameters**

*\_\_s* Source C string. \
 *\_\_a* Allocator to use (default is default allocator).

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

Construct string as multiple characters.

**Parameters**

*\_\_n* Number of characters. \
 *\_\_c* Character to use. \
 *\_\_a* Allocator to use (default is default allocator).

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

Move construct string.

**Parameters**

*\_\_str* Source string.

The newly-created string contains the exact contents of *\_\_str*. *\_\_str* is a valid, but unspecified string.

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

Construct string from an initializer list.

**Parameters**

*\_\_l* std::initializer\_list of characters. \
 *\_\_a* Allocator to use (default is default allocator).

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (\_InputIterator \_\_beg, \_InputIterator \_\_end, const \_Alloc & \_\_a = \_Alloc()) \[inline\]

Construct string as copy of a range.

**Parameters**

*\_\_beg* Start of range. \
 *\_\_end* End of range. \
 *\_\_a* Allocator to use (default is default allocator).

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::~basic\_string () \[inline\], \[noexcept\]

Destroy the string instance.

## 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\]

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)

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\], \[constexpr\]

Append a range of characters.

**Parameters**

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

**Returns**

Reference to this string.

Appends characters in the range \[\_\_first,\_\_last) to this string.

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\]

Append a range of characters.

**Parameters**

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

**Returns**

Reference to this string.

Appends characters in the range \[\_\_first,\_\_last) to this string.

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

Append a C string.

**Parameters**

*\_\_s* The C string to append.

**Returns**

Reference to this string.

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

Append a C string.

**Parameters**

*\_\_s* The C string 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 \_CharT \* \_\_s, size\_type \_\_n) \[inline\], \[constexpr\]

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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const \_CharT \* \_\_s, size\_type \_\_n)

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\]

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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str)

Append a string to this string.

**Parameters**

*\_\_str* The string 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, size\_type \_\_pos, size\_type \_\_n = npos) \[inline\], \[constexpr\]

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 (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, size\_type \_\_n = npos)

**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\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (initializer\_list\< \_CharT \> \_\_l) \[inline\]

**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\]

**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 \>::append (size\_type \_\_n, \_CharT \_\_c)

**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\> template\<class \_InputIterator, typename = std::\_RequireInputIter\<\_InputIterator\>\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\], \[constexpr\]

**Set value to a range of characters.**

**Parameters**

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

**Returns**

**Reference to this string.**

**Sets value of string to characters in the range \[\_\_first,\_\_last).**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> template\<class \_InputIterator\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\]

**Set value to a range of characters.**

**Parameters**

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

**Returns**

**Reference to this string.**

**Sets value of string to characters in the range \[\_\_first,\_\_last).**

### 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\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (basic\_string\< \_CharT, \_Traits, \_Alloc \> && \_\_str) \[inline\], \[noexcept\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const \_CharT \* \_\_s) \[inline\], \[constexpr\]

**Set value to contents of a C string.**

**Parameters**

*\_\_s* **The C string to use.**

**Returns**

**Reference to this string.**

**This function sets the value of this string to the value of** *\_\_s***. The data is copied, so there is no dependence on** *\_\_s* **once the function returns.**

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

**Set value to contents of a C string.**

**Parameters**

*\_\_s* **The C string to use.**

**Returns**

**Reference to this string.**

**This function sets the value of this string to the value of** *\_\_s***. The data is copied, so there is no dependence on** *\_\_s* **once the function returns.**

### 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\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const \_CharT \* \_\_s, size\_type \_\_n)

**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\]

**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)

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

**Parameters**

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

**Returns**

**Reference to this string.**

### 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\]

**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 (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str, size\_type \_\_pos, size\_type \_\_n = npos) \[inline\]

**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 (initializer\_list\< \_CharT \> \_\_l) \[inline\], \[constexpr\]

**Set value to an initializer\_list of characters.**

**Parameters**

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

**Returns**

**Reference to this string.**

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

**Set value to an initializer\_list of characters.**

**Parameters**

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

**Returns**

**Reference to this string.**

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

**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, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (size\_type \_\_n, \_CharT \_\_c) \[inline\]

**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, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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 \>::back () \[inline\]

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::back () const \[inline\], \[noexcept\]

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin () \[inline\]

**Returns a read/write iterator that points to the first character in the string. Unshares the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) iterator that points to the first character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin () const \[inline\], \[noexcept\]

**Returns a read-only (constant) iterator that points to the first character in the string.**

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

**Returns a read/write iterator that points to the first character in the string.**

**Referenced by std::basic\_string\< \_CharT \>::crend(), std::basic\_string\< \_CharT \>::erase(), std::basic\_string\< \_CharT \>::erase(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::regex\_match(), std::regex\_match(), std::regex\_replace(), std::regex\_replace(), std::regex\_search(), std::basic\_string\< \_CharT \>::rend(), std::basic\_string\< \_CharT \>::rend(), std::basic\_string\< \_CharT \>::rend(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), and std::basic\_string\< \_CharT \>::replace().**

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

**Return const pointer to null-terminated contents. This is a handle to internal data. Do not modify or dire things may happen.**

**Referenced by std::\_\_cxx11::collate\< \_CharT \>::do\_compare(), std::money\_get\< \_CharT, \_InIter \>::do\_get(), std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::num\_get\< \_CharT, \_InIter \>::do\_get(), std::\_\_cxx11::collate\< \_CharT \>::do\_transform(), std::basic\_filebuf\< char\_type, traits\_type \>::open(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), std::regex\_replace(), and std::regex\_traits\< \_CharT \>::transform\_primary().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const \_CharT \* std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::c\_str () const \[inline\], \[noexcept\]

**Return const pointer to null-terminated contents. This is a handle to internal data. Do not modify or dire things may happen.**

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

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

**Referenced by std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::push\_back(), reserve(), and reserve().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::capacity () const \[inline\], \[noexcept\]

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::cbegin () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) iterator that points to the first character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::cbegin () const \[inline\], \[noexcept\]

**Returns a read-only (constant) iterator that points to the first character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::cend () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) iterator that points one past the last character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::cend () const \[inline\], \[noexcept\]

**Returns a read-only (constant) iterator that points one past the last character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::clear () \[inline\], \[constexpr\], \[noexcept\]

**Erases the string, making it empty.**

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::clear () \[inline\], \[noexcept\]

**Erases the string, making it empty.**

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

**Compare to a C string.**

**Parameters**

*\_\_s* **C string to compare against.**

**Returns**

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

**Returns an integer \< 0 if this string is ordered before** *\_\_s***, 0 if their values are equivalent, or \> 0 if this string is ordered after** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of size() and the length of a string constructed from** *\_\_s***. The function then compares the two strings by calling traits::compare(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 (const \_CharT \* \_\_s) const \[inline\], \[noexcept\]

**Compare to a C string.**

**Parameters**

*\_\_s* **C string to compare against.**

**Returns**

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

**Returns an integer \< 0 if this string is ordered before** *\_\_s***, 0 if their values are equivalent, or \> 0 if this string is ordered after** *\_\_s***. Determines the effective length rlen of the strings to compare as the smallest of size() and the length of a string constructed from** *\_\_s***. The function then compares the two strings by calling traits::compare(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 (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_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, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) const \[inline\]

**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, 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\]

**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 \_\_n, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_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, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s) const \[inline\]

**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\]

**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 \_\_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, 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\]

**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 \_\_pos1, size\_type \_\_n1, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_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\> 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\]

**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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::copy (\_CharT \* \_\_s, size\_type \_\_n, size\_type \_\_pos = 0) const

**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\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crbegin () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to the last character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crbegin () const \[inline\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to the last character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crend () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crend () const \[inline\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order.**

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

**Return const pointer to contents. This is a pointer to internal data. It is undefined to modify the contents through the returned pointer. To get a pointer that allows modifying the contents use** &str**\[0\] instead, (or in C++17 the non-const** str.data() **overload).**

**Referenced by std::basic\_regex\< char \>::assign(), std::basic\_string\< \_CharT \>::compare(), std::basic\_string\< \_CharT \>::compare(), std::basic\_string\< \_CharT \>::compare(), std::\_\_cxx11::collate\< \_CharT \>::do\_compare(), std::\_\_cxx11::collate\< \_CharT \>::do\_transform(), std::basic\_string\< \_CharT \>::find(), std::basic\_string\< \_CharT \>::find\_first\_not\_of(), std::basic\_string\< \_CharT \>::find\_first\_of(), std::basic\_string\< \_CharT \>::find\_last\_of(), std::match\_results\< \_BidirectionalIterator, polymorphic\_allocator\< sub\_match\< \_BidirectionalIterator \> \> \>\< const char \* \>::format(), std::wstring\_convert\< \_Codecvt, \_Elem, \_Wide\_alloc, \_Byte\_alloc \>::from\_bytes(), std::operator==(), std::basic\_stringbuf\< char \>::str(), std::wstring\_convert\< \_Codecvt, \_Elem, \_Wide\_alloc, \_Byte\_alloc \>::to\_bytes(), and std::regex\_traits\< \_CharT \>::transform().**

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

**Return const pointer to contents. This is a pointer to internal data. It is undefined to modify the contents through the returned pointer. To get a pointer that allows modifying the contents use** &str**\[0\] instead, (or in C++17 the non-const** str.data() **overload).**

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

**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, typename \_Alloc\> \_CharT \* std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data () \[inline\]

**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.**

**The standard requires this function to be** noexcept **but for the Copy-On-Write string implementation it can throw. This function allows modifying the string contents directly, which means we must copy-on-write to unshare it, which requires allocating memory.**

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

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

**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(), std::basic\_string\< \_CharT \>::front(), std::regex\_traits\< \_Ch\_type \>::lookup\_collatename(), std::tr2::operator\>\>(), std::basic\_string\< \_CharT \>::pop\_back(), and std::basic\_string\< \_CharT \>::pop\_back().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> bool std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty () const \[inline\], \[nodiscard\], \[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 \>::end () \[inline\]

**Returns a read/write iterator that points one past the last character in the string. Unshares the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) iterator that points one past the last character in the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end () const \[inline\], \[noexcept\]

**Returns a read-only (constant) iterator that points one past the last character in the string.**

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

**Returns a read/write iterator that points one past the last character in the string.**

**Referenced by std::basic\_string\< \_CharT \>::append(), std::basic\_string\< \_CharT \>::crbegin(), std::basic\_string\< \_CharT \>::erase(), std::basic\_string\< \_CharT \>::erase(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::rbegin(), std::basic\_string\< \_CharT \>::rbegin(), std::basic\_string\< \_CharT \>::rbegin(), std::regex\_match(), std::regex\_match(), std::regex\_replace(), std::regex\_replace(), std::regex\_search(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), and std::basic\_string\< \_CharT \>::replace().**

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

**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\]

**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)

**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\]

**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\]

**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, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase (size\_type \_\_pos = 0, size\_type \_\_n = npos) \[inline\]

**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.**

### 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\]

**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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[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, 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\]

**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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_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\_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.**

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, 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\]

**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 \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[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, 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\]

**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, 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\], \[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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, 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\]

**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 \_CharT \* \_\_s, size\_type \_\_pos = 0) const \[inline\], \[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, 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\]

**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, 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\], \[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\> 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\]

**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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, 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\]

**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 \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[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, 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\]

**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, 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\], \[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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, 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\]

**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 \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[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, 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\]

**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, 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\], \[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\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::front () \[inline\]

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::front () const \[inline\], \[noexcept\]

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> allocator\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::get\_allocator () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

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

**Referenced by std::basic\_string\< \_CharT \>::~basic\_string(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::clear(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), reserve(), reserve(), and swap().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> allocator\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::get\_allocator () const \[inline\], \[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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos, const \_CharT \* \_\_s) \[inline\]

**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\]

**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, const \_CharT \* \_\_s, size\_type \_\_n)

**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\]

**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 \_\_pos, size\_type \_\_n, \_CharT \_\_c) \[inline\]

**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\]

**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) \[inline\]

**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\]

**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, 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\]

**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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::length () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

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

**Referenced by std::basic\_string\< \_CharT \>::basic\_string(), std::basic\_string\< \_CharT \>::basic\_string(), std::\_\_cxx11::collate\< \_CharT \>::do\_compare(), std::\_\_cxx11::collate\< \_CharT \>::do\_transform(), std::basic\_string\< \_CharT \>::operator=(), std::regex\_replace(), and reserve().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::length () const \[inline\], \[noexcept\]

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

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

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

**Referenced by std::getline(), and std::operator\>\>().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::max\_size () const \[inline\], \[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+= (\_CharT \_\_c) \[inline\], \[constexpr\]

**Append a character.**

**Parameters**

*\_\_c* **The character to append.**

**Returns**

**Reference to this string.**

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

**Append a character.**

**Parameters**

*\_\_c* **The character to append.**

**Returns**

**Reference to this string.**

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

**Append a C string.**

**Parameters**

*\_\_s* **The C string to append.**

**Returns**

**Reference to this string.**

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

**Append a C string.**

**Parameters**

*\_\_s* **The C string to append.**

**Returns**

**Reference to this 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\]

**Append a string to this string.**

**Parameters**

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

**Returns**

**Reference to this 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\]

**Append a string to this string.**

**Parameters**

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

**Returns**

**Reference to this string.**

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

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

**Parameters**

*\_\_l* **The initializer\_list of characters to be appended.**

**Returns**

**Reference to this string.**

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

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

**Parameters**

*\_\_l* **The initializer\_list of characters to be appended.**

**Returns**

**Reference to this string.**

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

**Set value to string of length 1.**

**Parameters**

*\_\_c* **Source character.**

**Assigning to a character makes this string length 1 and (\*this)\[0\] ==** *c***.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> basic\_string & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator= (\_CharT \_\_c) \[inline\]

**Set value to string of length 1.**

**Parameters**

*\_\_c* **Source character.**

**Assigning to a character makes this string length 1 and (\*this)\[0\] ==** *c***.**

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

**Move assign the value of** *str* **to this string.**

**Parameters**

*\_\_str* **Source string.**

**The contents of** *str* **are moved into this string (without copying).** *str* **is a valid, but unspecified string.**

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

**Move assign the value of** *str* **to this string.**

**Parameters**

*\_\_str* **Source string.**

**The contents of** *str* **are moved into this string (without copying).** *str* **is a valid, but unspecified string.**

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

**Copy contents of** *s* **into this string.**

**Parameters**

*\_\_s* **Source null-terminated string.**

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

**Copy contents of** *s* **into this string.**

**Parameters**

*\_\_s* **Source null-terminated 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\]

**Assign the value of** *str* **to this string.**

**Parameters**

*\_\_str* **Source 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\]

**Assign the value of** *str* **to this string.**

**Parameters**

*\_\_str* **Source string.**

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

**Set value to string constructed from initializer list.**

**Parameters**

*\_\_l* **std::initializer\_list.**

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

**Set value to string constructed from initializer list.**

**Parameters**

*\_\_l* **std::initializer\_list.**

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

**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\> reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\] (size\_type \_\_pos) \[inline\]

**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().) Unshares the string.**

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

**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\> const\_reference std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\] (size\_type \_\_pos) const \[inline\], \[noexcept\]

**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().)**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::pop\_back () \[inline\]

**Remove the last character. The string must be non-empty.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::pop\_back () \[inline\], \[constexpr\], \[noexcept\]

**Remove the last character. The string must be non-empty.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::push\_back (\_CharT \_\_c) \[inline\], \[constexpr\]

**Append a single character.**

**Parameters**

*\_\_c* **Character to append.**

**Referenced by std::\_\_cxx11::collate\< \_CharT \>::do\_transform(), std::basic\_string\< \_CharT \>::operator+=(), 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 \>::push\_back (\_CharT \_\_c) \[inline\]

**Append a single character.**

**Parameters**

*\_\_c* **Character to append.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin () \[inline\]

**Returns a read/write reverse iterator that points to the last character in the string. Iteration is done in reverse element order. Unshares the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to the last character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin () const \[inline\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to the last character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin () \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read/write reverse iterator that points to the last character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend () \[inline\]

**Returns a read/write reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order. Unshares the string.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend () const \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const\_reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend () const \[inline\], \[noexcept\]

**Returns a read-only (constant) reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order.**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> reverse\_iterator std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend () \[inline\], \[nodiscard\], \[constexpr\], \[noexcept\]

**Returns a read/write reverse iterator that points to one before the first character in the string. Iteration is done in reverse element order.**

### 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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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\]

**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 \_\_n, const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_str) \[inline\]

**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.**

### 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\]

**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 & std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n1, const \_CharT \* \_\_s) \[inline\]

**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\]

**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, const \_CharT \* \_\_s, size\_type \_\_n2)

**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\]

**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 \_\_pos, size\_type \_\_n1, size\_type \_\_n2, \_CharT \_\_c) \[inline\]

**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\]

**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, 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\]

**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, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::reserve () \[constexpr\]

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

**References capacity(), get\_allocator(), and length().**

**Referenced by std::basic\_string\< \_CharT \>::push\_back(), and std::basic\_string\< \_CharT \>::shrink\_to\_fit().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::reserve ()

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

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.**

**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 \>::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 \>::resize (size\_type \_\_n) \[inline\], \[constexpr\]

**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) \[inline\]

**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\]

**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, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::resize (size\_type \_\_n, \_CharT \_\_c)

**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***.**

### 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\]

**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\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, 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\]

**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, 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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const \[inline\], \[noexcept\]

**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\]

**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, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const basic\_string\< \_CharT, \_Traits, \_Alloc \> & \_\_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\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::shrink\_to\_fit () \[inline\], \[constexpr\], \[noexcept\]

**A non-binding request to reduce capacity() to size().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> void std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::shrink\_to\_fit () \[inline\], \[noexcept\]

**A non-binding request to reduce capacity() to size().**

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

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

**Referenced by std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset(), std::basic\_string\< \_CharT \>::append(), std::basic\_string\< \_CharT \>::append(), std::basic\_regex\< char \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::assign(), std::basic\_string\< \_CharT \>::at(), std::basic\_string\< \_CharT \>::at(), std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::back(), std::basic\_string\< \_CharT \>::cend(), std::basic\_string\< \_CharT \>::compare(), std::basic\_string\< \_CharT \>::compare(), std::basic\_string\< \_CharT \>::compare(), std::basic\_string\< \_CharT \>::empty(), std::basic\_string\< \_CharT \>::end(), std::basic\_string\< \_CharT \>::end(), std::basic\_string\< \_CharT \>::end(), std::basic\_string\< \_CharT \>::find(), std::basic\_string\< \_CharT \>::find\_first\_not\_of(), std::basic\_string\< \_CharT \>::find\_first\_of(), std::basic\_string\< \_CharT \>::find\_last\_of(), std::match\_results\< \_BidirectionalIterator, polymorphic\_allocator\< sub\_match\< \_BidirectionalIterator \> \> \>\< const char \* \>::format(), std::wstring\_convert\< \_Codecvt, \_Elem, \_Wide\_alloc, \_Byte\_alloc \>::from\_bytes(), std::basic\_string\< \_CharT \>::insert(), std::basic\_string\< \_CharT \>::length(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), std::operator+(), std::basic\_string\< \_CharT \>::operator=(), std::operator==(), std::tr2::operator\>\>(), std::basic\_string\< \_CharT \>::operator\[\](), std::basic\_string\< \_CharT \>::operator\[\](), std::basic\_string\< \_CharT \>::pop\_back(), std::basic\_string\< \_CharT \>::pop\_back(), std::basic\_string\< \_CharT \>::push\_back(), std::basic\_string\< \_CharT \>::replace(), std::basic\_string\< \_CharT \>::replace(), resize(), std::basic\_stringbuf\< char \>::str(), std::wstring\_convert\< \_Codecvt, \_Elem, \_Wide\_alloc, \_Byte\_alloc \>::to\_bytes(), std::regex\_traits\< \_CharT \>::transform(), and std::regex\_traits\< \_CharT \>::transform\_primary().**

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size () const \[inline\], \[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\]

**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 std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::substr (size\_type \_\_pos = 0, size\_type \_\_n = npos) const \[inline\]

**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\]

**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\]

**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\]

**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=().**

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

**Swap contents with another string.**

**Parameters**

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

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

## Member Data Documentation

### template\<typename \_CharT, typename \_Traits, typename \_Alloc\> const size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::npos \[static\]

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

**Referenced by std::bitset\< \_Nb \>::bitset(), std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset(), find(), find(), find\_first\_not\_of(), find\_first\_not\_of(), find\_first\_of(), find\_last\_not\_of(), find\_last\_not\_of(), find\_last\_of(), rfind(), and rfind().**

## Author

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