---
name: "std::basic_string"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::basic_string/3cxx"
---

# std::basic\_string(3cxx)

Managing sequences of characters and character-like objects.

## NAME

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

## SYNOPSIS

`#include <string>`

Inherited by **\_\_gnu\_debug::basic\_string\< \_CharT, \_Traits, \_Allocator \>**.

### Public Types

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

### Public Member Functions

**basic\_string** () noexcept\
 Default constructor creates an empty string.  template\<**class** **\_InputIterator** \> **basic\_string** (**\_InputIterator** **\_\_beg**, **\_InputIterator** \_\_end, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a range.  **basic\_string** (**basic\_string** &&**\_\_str**) noexcept\
 Move construct string.  **basic\_string** (**basic\_string** &&**\_\_str**, const \_Alloc &\_\_a)\
 **basic\_string** (const \_Alloc &\_\_a)\
 Construct an empty string using allocator *a*.  template\<**typename**  = \_RequireAllocator\<\_Alloc\>\> **basic\_string** (const \_CharT \***\_\_s**, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as copy of a C string.  **basic\_string** (const \_CharT \***\_\_s**, size\_type \_\_n, const \_Alloc &\_\_a=\_Alloc())\
 Construct string initialized by a character array.  template\<**typename** \_Tp , **typename**  = \_If\_sv\<\_Tp, void\>\> **basic\_string** (const \_Tp &\_\_t, const \_Alloc &\_\_a=\_Alloc())\
 Construct string from a string\_view.  template\<**typename** \_Tp , **typename**  = enable\_if\_t\<is\_convertible\_v\<const \_Tp&, \_\_sv\_type\>\>\> **basic\_string** (const \_Tp &\_\_t, size\_type **\_\_pos**, size\_type \_\_n, const \_Alloc &\_\_a=\_Alloc())\
 Construct string from a substring of a string\_view.  **basic\_string** (const **basic\_string** &**\_\_str**)\
 Construct string with copy of value of *str*.  **basic\_string** (const **basic\_string** &**\_\_str**, const \_Alloc &\_\_a)\
 **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**, size\_type \_\_n)\
 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.  **basic\_string** (**initializer\_list**\< \_CharT \> **\_\_l**, const \_Alloc &\_\_a=\_Alloc())\
 Construct string from an initializer list.  **basic\_string** (size\_type \_\_n, \_CharT \_\_c, const \_Alloc &\_\_a=\_Alloc())\
 Construct string as multiple characters.  **~basic\_string** () noexcept\
 Destroy the string instance.  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** \> **basic\_string** & **append** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last)\
 Append a range of characters.  **basic\_string** & **append** (const \_CharT \***\_\_s**)\
 Append a C string.  **basic\_string** & **append** (const \_CharT \***\_\_s**, size\_type \_\_n)\
 Append a C substring.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **append** (const \_Tp &**\_\_svt**)\
 Append a string\_view.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **append** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**, size\_type \_\_n=**npos**)\
 Append a range of characters from a string\_view.  **basic\_string** & **append** (const **basic\_string** &**\_\_str**)\
 Append a string to this string.  **basic\_string** & **append** (const **basic\_string** &**\_\_str**, size\_type **\_\_pos**, size\_type \_\_n=**npos**)\
 Append a substring.  **basic\_string** & **append** (**initializer\_list**\< \_CharT \> **\_\_l**)\
 Append an initializer\_list of characters.  **basic\_string** & **append** (size\_type \_\_n, \_CharT \_\_c)\
 Append multiple characters.  template\<**class** **\_InputIterator** \> **basic\_string** & **assign** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last)\
 Set value to a range of characters.  **basic\_string** & **assign** (**basic\_string** &&**\_\_str**) noexcept(**allocator\_traits**\< \_Alloc \>::is\_always\_equal::value)\
 Set value to contents of another string.  **basic\_string** & **assign** (const \_CharT \***\_\_s**)\
 Set value to contents of a C string.  **basic\_string** & **assign** (const \_CharT \***\_\_s**, size\_type \_\_n)\
 Set value to a C substring.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **assign** (const \_Tp &**\_\_svt**)\
 Set value from a string\_view.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **assign** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**, size\_type \_\_n=**npos**)\
 Set value from a range of characters in a string\_view.  **basic\_string** & **assign** (const **basic\_string** &**\_\_str**)\
 Set value to contents of another string.  **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** (**initializer\_list**\< \_CharT \> **\_\_l**)\
 Set value to an initializer\_list of characters.  **basic\_string** & **assign** (size\_type \_\_n, \_CharT \_\_c)\
 Set value to multiple characters.  reference **at** (size\_type \_\_n)\
 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** ()\
 const\_reference **back** () const noexcept\
 iterator **begin** ()\
 const\_iterator **begin** () const noexcept\
 const \_CharT \* **c\_str** () const noexcept\
 Return const pointer to null-terminated contents.  size\_type **capacity** () const noexcept\
 const\_iterator **cbegin** () const noexcept\
 const\_iterator **cend** () const noexcept\
 **void** **clear** () noexcept\
 int **compare** (const \_CharT \***\_\_s**) const noexcept\
 Compare to a C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, int \> **compare** (const \_Tp &**\_\_svt**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Compare to a string\_view.  int **compare** (const **basic\_string** &**\_\_str**) const\
 Compare to a string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, int \> **compare** (size\_type **\_\_pos**, size\_type \_\_n, const \_Tp &**\_\_svt**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Compare to a string\_view.  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 **\_\_n1**, const \_CharT \***\_\_s**) const\
 Compare substring to a C string.  int **compare** (size\_type **\_\_pos**, size\_type **\_\_n1**, const \_CharT \***\_\_s**, size\_type **\_\_n2**) const\
 Compare substring against a character array.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, int \> **compare** (size\_type **\_\_pos1**, size\_type **\_\_n1**, const \_Tp &**\_\_svt**, size\_type **\_\_pos2**, size\_type **\_\_n2**=**npos**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Compare to a string\_view.  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.  size\_type **copy** (\_CharT \***\_\_s**, size\_type \_\_n, size\_type **\_\_pos**=0) const\
 Copy substring into C string.  **const\_reverse\_iterator** **crbegin** () const noexcept\
 **const\_reverse\_iterator** **crend** () const noexcept\
 const \_CharT \* **data** () const noexcept\
 Return const pointer to contents.  \_CharT \* **data** () noexcept\
 Return non-const pointer to contents.  bool **empty** () const noexcept\
 iterator **end** ()\
 const\_iterator **end** () const noexcept\
 bool **ends\_with** (\_CharT \_\_x) const noexcept\
 bool **ends\_with** (**basic\_string\_view**\< \_CharT, \_Traits \> \_\_x) const noexcept\
 bool **ends\_with** (const \_CharT \*\_\_x) const noexcept\
 iterator **erase** (iterator \_\_first, iterator \_\_last)\
 Remove a range of characters.  iterator **erase** (iterator **\_\_position**)\
 Remove one character.  **basic\_string** & **erase** (size\_type **\_\_pos**=0, size\_type \_\_n=**npos**)\
 Remove characters.  size\_type **find** (\_CharT \_\_c, size\_type **\_\_pos**=0) const noexcept\
 Find position of a character.  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**=0) const noexcept\
 Find position of a C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **find** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=0) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Find position of a string\_view.  size\_type **find** (const **basic\_string** &**\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 Find position of a string.  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** (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**=0) const noexcept\
 Find position of a character not in C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **find\_first\_not\_of** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=0) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Find position of a character not in a string\_view.  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\_of** (\_CharT \_\_c, size\_type **\_\_pos**=0) const noexcept\
 Find position of a character.  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**=0) const noexcept\
 Find position of a character of C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **find\_first\_of** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=0) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Find position of a character of a string\_view.  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\_last\_not\_of** (\_CharT \_\_c, size\_type **\_\_pos**=**npos**) const noexcept\
 Find last position of a different character.  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**=**npos**) const noexcept\
 Find last position of a character not in C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **find\_last\_not\_of** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=**npos**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Find last position of a character not in a string\_view.  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\_of** (\_CharT \_\_c, size\_type **\_\_pos**=**npos**) const noexcept\
 Find last position of a character.  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**=**npos**) const noexcept\
 Find last position of a character of C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **find\_last\_of** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=**npos**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 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** ()\
 const\_reference **front** () const noexcept\
 allocator\_type **get\_allocator** () const noexcept\
 Return copy of allocator used to construct this string.  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.  **basic\_string** & **insert** (size\_type **\_\_pos**, const \_CharT \***\_\_s**)\
 Insert a C string.  **basic\_string** & **insert** (size\_type **\_\_pos**, const \_CharT \***\_\_s**, size\_type \_\_n)\
 Insert a C substring.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **insert** (size\_type **\_\_pos**, const \_Tp &**\_\_svt**)\
 Insert a string\_view.  **basic\_string** & **insert** (size\_type **\_\_pos**, size\_type \_\_n, \_CharT \_\_c)\
 Insert multiple characters.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **insert** (size\_type **\_\_pos1**, const \_Tp &**\_\_svt**, size\_type **\_\_pos2**, size\_type \_\_n=**npos**)\
 Insert a string\_view.  **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**, size\_type **\_\_pos2**, size\_type \_\_n=**npos**)\
 Insert a substring.  size\_type **length** () const noexcept\
 Returns the number of characters in the string, not including any null-termination.  size\_type **max\_size** () const noexcept\
 Returns the size() of the largest possible string.  **operator \_\_sv\_type** () const noexcept\
 Convert to a string\_view.  **basic\_string** & **operator+=** (\_CharT \_\_c)\
 Append a character.  **basic\_string** & **operator+=** (const \_CharT \***\_\_s**)\
 Append a C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **operator+=** (const \_Tp &**\_\_svt**)\
 Append a string\_view.  **basic\_string** & **operator+=** (const **basic\_string** &**\_\_str**)\
 Append a string to this string.  **basic\_string** & **operator+=** (**initializer\_list**\< \_CharT \> **\_\_l**)\
 Append an initializer\_list of characters.  **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.  **basic\_string** & **operator=** (const \_CharT \***\_\_s**)\
 Copy contents of *s* into this string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **operator=** (const \_Tp &**\_\_svt**)\
 Set value to string constructed from a string\_view.  **basic\_string** & **operator=** (const **basic\_string** &**\_\_str**)\
 Assign the value of *str* to this string.  **basic\_string** & **operator=** (**initializer\_list**\< \_CharT \> **\_\_l**)\
 Set value to string constructed from initializer list.  reference **operator\[\]** (size\_type **\_\_pos**)\
 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.  **void** **push\_back** (\_CharT \_\_c)\
 Append a single character.  **reverse\_iterator** **rbegin** ()\
 **const\_reverse\_iterator** **rbegin** () const noexcept\
 **reverse\_iterator** **rend** ()\
 **const\_reverse\_iterator** **rend** () const noexcept\
 template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **replace** (const\_iterator **\_\_i1**, const\_iterator **\_\_i2**, const \_Tp &**\_\_svt**)\
 Replace range of characters with string\_view.  **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.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **replace** (size\_type **\_\_pos**, size\_type \_\_n, const \_Tp &**\_\_svt**)\
 Replace range of characters with string\_view.  **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 **\_\_n1**, const \_CharT \***\_\_s**)\
 Replace characters with value of a C string.  **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**, size\_type **\_\_n2**, \_CharT \_\_c)\
 Replace characters with multiple characters.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, **basic\_string** & \> **replace** (size\_type **\_\_pos1**, size\_type **\_\_n1**, const \_Tp &**\_\_svt**, size\_type **\_\_pos2**, size\_type **\_\_n2**=**npos**)\
 Replace range of characters with string\_view.  **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.  **void** **reserve** ()\
 Equivalent to shrink\_to\_fit().  **void** **reserve** (size\_type **\_\_res\_arg**)\
 Attempt to preallocate enough memory for specified number of characters.  **void** **resize** (size\_type \_\_n)\
 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.  size\_type **rfind** (\_CharT \_\_c, size\_type **\_\_pos**=**npos**) const noexcept\
 Find last position of a character.  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**=**npos**) const noexcept\
 Find last position of a C string.  template\<**typename** \_Tp \> **\_If\_sv**\< \_Tp, size\_type \> **rfind** (const \_Tp &**\_\_svt**, size\_type **\_\_pos**=**npos**) const noexcept(**is\_same**\< \_Tp, **\_\_sv\_type** \>::value)\
 Find last position of a string\_view.  size\_type **rfind** (const **basic\_string** &**\_\_str**, size\_type **\_\_pos**=**npos**) const noexcept\
 Find last position of a string.  **void** **shrink\_to\_fit** () noexcept\
 A non-binding request to reduce capacity() to size().  size\_type **size** () const noexcept\
 Returns the number of characters in the string, not including any null-termination.  bool **starts\_with** (\_CharT \_\_x) const noexcept\
 bool **starts\_with** (**basic\_string\_view**\< \_CharT, \_Traits \> \_\_x) const noexcept\
 bool **starts\_with** (const \_CharT \*\_\_x) const noexcept\
 **basic\_string** **substr** (size\_type **\_\_pos**=0, size\_type \_\_n=**npos**) const\
 Get a substring.  **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** iterator **\_\_const\_iterator**\

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

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

Default constructor creates an empty string.

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::substr()**.

### 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 \> template\<typename \_Tp , typename = enable\_if\_t\<is\_convertible\_v\<const \_Tp&, \_\_sv\_type\>\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_Tp & \_\_t, size\_type \_\_pos, size\_type \_\_n, const \_Alloc & \_\_a = `_Alloc()`)` [inline]`

Construct string from a substring of a string\_view.

**Parameters**

*\_\_t* Source object convertible to string view. \
 *\_\_pos* The index of the first character to copy from \_\_t. \
 *\_\_n* The number of characters to copy from \_\_t. \
 *\_\_a* Allocator to use.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp , typename = \_If\_sv\<\_Tp, void\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string (const \_Tp & \_\_t, const \_Alloc & \_\_a = `_Alloc()`)` [inline]`, ` [explicit]`

Construct string from a string\_view.

**Parameters**

*\_\_t* Source object convertible to string view. \
 *\_\_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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::get\_allocator()**.

## Member Function Documentation

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

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

Append a C substring.

**Parameters**

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

**Returns**

Reference to this string.

References **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const \_Tp & \_\_svt)` [inline]`

Append a string\_view.

**Parameters**

*\_\_svt* The object convertible to string\_view to be appended.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append (const \_Tp & \_\_svt, size\_type \_\_pos, size\_type \_\_n = npos)` [inline]`

Append a range of characters from a string\_view.

**Parameters**

*\_\_svt* The object convertible to string\_view to be appended from. \
 *\_\_pos* The position in the string\_view to append from. \
 *\_\_n* The number of characters to append from the string\_view.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

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

Append a string to this string.

**Parameters**

*\_\_str* The string to append.

**Returns**

Reference to this string.

References **std::size()**.

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+=()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+=()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+=()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+=()**.

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

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.

References **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> basic\_string\< \_CharT, \_Traits, \_Alloc \> & 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.

References **std::size()**.

### 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).

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::swap()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

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.

References **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const \_Tp & \_\_svt)` [inline]`

Set value from a string\_view.

**Parameters**

*\_\_svt* The source object convertible to string\_view.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign (const \_Tp & \_\_svt, size\_type \_\_pos, size\_type \_\_n = npos)` [inline]`

Set value from a range of characters in a string\_view.

**Parameters**

*\_\_svt* The source object convertible to string\_view. \
 *\_\_pos* The position in the string\_view to assign from. \
 *\_\_n* The number of characters to assign.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

Set value to contents of another string.

**Parameters**

*\_\_str* Source string to use.

**Returns**

Reference to this string.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crend()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rend()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

Referenced by **std::experimental::filesystem::v1::filesystem\_error::what()**.

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

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::push\_back()**.

### 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]`, ` [noexcept]`

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

Erases the string, making it empty.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::get\_allocator()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> int std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (const \_CharT \* \_\_s) const` [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.

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

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, int \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (const \_Tp & \_\_svt) const` [inline]`, ` [noexcept]`

Compare to a string\_view.

**Parameters**

*\_\_svt* An object convertible to string\_view to compare against.

**Returns**

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

References **std::min()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::min()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, int \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos, size\_type \_\_n, const \_Tp & \_\_svt) const` [inline]`, ` [noexcept]`

Compare to a string\_view.

**Parameters**

*\_\_pos* A position in the string to start comparing from. \
 *\_\_n* The number of characters to compare. \
 *\_\_svt* An object convertible to string\_view to compare against.

**Returns**

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

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

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.

References **std::min()**.

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

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.

References **std::min()**.

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

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.

References **std::min()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, int \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare (size\_type \_\_pos1, size\_type \_\_n1, const \_Tp & \_\_svt, size\_type \_\_pos2, size\_type \_\_n2 = npos) const` [inline]`, ` [noexcept]`

Compare to a string\_view.

**Parameters**

*\_\_pos1* A position in the string to start comparing from. \
 *\_\_n1* The number of characters to compare. \
 *\_\_svt* An object convertible to string\_view to compare against. \
 *\_\_pos2* A position in the string\_view to start comparing from. \
 *\_\_n2* The number of characters to compare.

**Returns**

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

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

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.

References **std::min()**.

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

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]`, ` [noexcept]`

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin()**.

### 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).

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator \_\_sv\_type()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind()**.

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

Returns true if the string is empty. Equivalent to `*this == ''`.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::crbegin()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rbegin()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

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::basic\_string\< \_CharT, \_Traits, \_Alloc \>::pop\_back()**.

### 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` [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 **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const` [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()**, and **std::size()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find (const \_Tp & \_\_svt, size\_type \_\_pos = `0`) const` [inline]`, ` [noexcept]`

Find position of a string\_view.

**Parameters**

*\_\_svt* The object convertible to string\_view to locate. \
 *\_\_pos* Index of character to search from (default 0).

**Returns**

Index of start of first occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find()**.

### 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` [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 **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const` [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 **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of (const \_Tp & \_\_svt, size\_type \_\_pos = `0`) const` [inline]`, ` [noexcept]`

Find position of a character not in a string\_view.

**Parameters**

*\_\_svt* An object convertible to string\_view containing characters to avoid. \
 *\_\_pos* Index of character to search from (default 0).

**Returns**

Index of first occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_not\_of()**.

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

### 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).

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find()**.

### 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` [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 **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of (const \_Tp & \_\_svt, size\_type \_\_pos = `0`) const` [inline]`, ` [noexcept]`

Find position of a character of a string\_view.

**Parameters**

*\_\_svt* An object convertible to string\_view containing characters to locate. \
 *\_\_pos* Index of character to search from (default 0).

**Returns**

Index of first occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_first\_of()**.

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

### 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` [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 **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const` [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 **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const \_CharT \* \_\_s, size\_type \_\_pos = npos) const` [inline]`, ` [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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of (const \_Tp & \_\_svt, size\_type \_\_pos = npos) const` [inline]`, ` [noexcept]`

Find last position of a character not in a string\_view.

**Parameters**

*\_\_svt* An object convertible to string\_view containing characters to avoid. \
 *\_\_pos* Index of character to search back from (default end).

**Returns**

Index of last occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_not\_of()**.

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

### 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).

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind()**.

### 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` [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 **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of (const \_Tp & \_\_svt, size\_type \_\_pos = npos) const` [inline]`, ` [noexcept]`

Find last position of a character of string.

**Parameters**

*\_\_svt* An object convertible to string\_view containing characters to locate. \
 *\_\_pos* Index of character to search back from (default end).

**Returns**

Index of last occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::find\_last\_of()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**.

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

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::~basic\_string()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::clear()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

### 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()`.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert()**.

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

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 \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos, const \_Tp & \_\_svt)` [inline]`

Insert a string\_view.

**Parameters**

*\_\_pos* Position in string to insert at. \
 *\_\_svt* The object convertible to string\_view to insert.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert()**.

### 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 \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert (size\_type \_\_pos1, const \_Tp & \_\_svt, size\_type \_\_pos2, size\_type \_\_n = npos)` [inline]`

Insert a string\_view.

**Parameters**

*\_\_pos1* Position in string to insert at. \
 *\_\_svt* The object convertible to string\_view to insert from. \
 *\_\_pos2* Position in string\_view to insert from. \
 *\_\_n* The number of characters to insert.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::insert()**.

### 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]`, ` [noexcept]`

Returns the size() of the largest possible string.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator \_\_sv\_type () const` [inline]`, ` [noexcept]`

Convert to a string\_view.

**Returns**

A string\_view.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::push\_back()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+= (const \_Tp & \_\_svt)` [inline]`

Append a string\_view.

**Parameters**

*\_\_svt* The object convertible to string\_view to be appended.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::append()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::swap()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator= (const \_Tp & \_\_svt)` [inline]`

Set value to string constructed from a string\_view.

**Parameters**

*\_\_svt* An object convertible to string\_view.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::erase()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::capacity()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::reserve()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size()**.

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator+=()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (const\_iterator \_\_i1, const\_iterator \_\_i2, const \_Tp & \_\_svt)` [inline]`

Replace range of characters with string\_view.

**Parameters**

*\_\_i1* An iterator referencing the start position to replace at. \
 *\_\_i2* An iterator referencing the end position for the replace. \
 *\_\_svt* The object convertible to string\_view to insert from.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::begin()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

### 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 \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos, size\_type \_\_n, const \_Tp & \_\_svt)` [inline]`

Replace range of characters with string\_view.

**Parameters**

*\_\_pos* The position to replace at. \
 *\_\_n* The number of characters to replace. \
 *\_\_svt* The object convertible to string\_view to insert.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

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

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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

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

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 \> template\<typename \_Tp \> \_If\_sv\< \_Tp, basic\_string & \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace (size\_type \_\_pos1, size\_type \_\_n1, const \_Tp & \_\_svt, size\_type \_\_pos2, size\_type \_\_n2 = npos)` [inline]`

Replace range of characters with string\_view.

**Parameters**

*\_\_pos1* The position to replace at. \
 *\_\_n1* The number of characters to replace. \
 *\_\_svt* The object convertible to string\_view to insert from. \
 *\_\_pos2* The position in the string\_view to insert from. \
 *\_\_n2* The number of characters to insert.

**Returns**

Reference to this string.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::replace()**.

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

Equivalent to shrink\_to\_fit().

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

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

References **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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*.

References **std::size()**.

Referenced by **std::money\_get\< \_CharT, \_InIter \>::do\_get()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::resize()**.

### 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` [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 **std::size()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> basic\_string\< \_CharT, \_Traits, \_Alloc \>::size\_type std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const \_CharT \* \_\_s, size\_type \_\_pos, size\_type \_\_n) const` [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()**, and **std::size()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind()**.

### template\<typename \_CharT , typename \_Traits , typename \_Alloc \> template\<typename \_Tp \> \_If\_sv\< \_Tp, size\_type \> std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind (const \_Tp & \_\_svt, size\_type \_\_pos = npos) const` [inline]`, ` [noexcept]`

Find last position of a string\_view.

**Parameters**

*\_\_svt* The object convertible to string\_view to locate. \
 *\_\_pos* Index of character to search back from (default end).

**Returns**

Index of start of last occurrence.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::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.

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::data()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::rfind()**.

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

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::reserve()**.

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

Referenced by **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::assign()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::at()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::at()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::back()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::back()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::cend()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::compare()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::empty()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::end()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator \_\_sv\_type()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::operator\[\]()**, **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::pop\_back()**, and **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::push\_back()**.

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

References **std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::basic\_string()**.

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

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

## Member Data Documentation

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

Value returned by various member functions when they fail.

## Author

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