# basic_string.h File Reference

## Detailed Description

This is an internal header file, included by other library headers. You should not attempt to use it directly.

Definition in file basic_string.h.

Go to the source code of this file.

## Namespaces

- namespace std

## Defines

- #define _BASIC_STRING_H

## Functions

- template<> basic_istream< wchar_t > & getline (basic_istream< wchar_t > &__in, basic_string< wchar_t > &__str, wchar_t __delim)
- template<> basic_istream< char > & getline (basic_istream< char > &__in, basic_string< char > &__str, char __delim)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_istream< _CharT, _Traits > & getline (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_istream< _CharT, _Traits > & getline (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator!= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator!= (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator!= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_string< _CharT, _Traits,
  _Alloc > operator+ (const basic_string< _CharT, _Traits, _Alloc > &__lhs, _CharT __rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_string< _CharT, _Traits,
  _Alloc > operator+ (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_string< _CharT, _Traits,
  _Alloc > operator+ (_CharT __lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_string< _CharT, _Traits,
  _Alloc > operator+ (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_string< _CharT, _Traits,
  _Alloc > operator+ (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator< (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator< (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator< (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__str)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator<= (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator<= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator<= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator== (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator== (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator== (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator> (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator> (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator> (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator>= (const _CharT *__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator>= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const _CharT *__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> bool operator>= (const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
- template<typename _CharT, typename _Traits, typename _Alloc> basic_istream< _CharT, _Traits > & operator>> (basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str)
- template<typename _CharT, typename _Traits, typename _Alloc> void swap (basic_string< _CharT, _Traits, _Alloc > &__lhs, basic_string< _CharT, _Traits, _Alloc > &__rhs)

## Function Documentation

basic_istream< _CharT, _Traits > & getline | ( | basic_istream< _CharT, _Traits > & | __is,
|  | basic_string< _CharT, _Traits, _Alloc > & | __str
| ) | `[inline]`

Read a line from stream into a string.

Parameters:

  | is | Input stream.
  | str | Buffer to store into.

Returns:
  Reference to the input stream.

Stores characters from is into str until '
' is found, the end of the stream is encountered, or str.max_size() is reached. If is.width() is non-zero, that is the limit on the number of characters stored into str. Any previous contents of str are erased. If end of line was encountered, it is extracted but not stored into str.

Definition at line 1256 of file istream.tcc.

References std::getline().

basic_istream< _CharT, _Traits > & getline | ( | basic_istream< _CharT, _Traits > & | __is,
|  | basic_string< _CharT, _Traits, _Alloc > & | __str,
|  | _CharT | __delim
| ) |

Read a line from stream into a string.

Parameters:

  | is | Input stream.
  | str | Buffer to store into.
  | delim | Character marking end of line.

Returns:
  Reference to the input stream.

Stores characters from is into str until delim is found, the end of the stream is encountered, or str.max_size() is reached. If is.width() is non-zero, that is the limit on the number of characters stored into str. Any previous contents of str are erased. If delim was encountered, it is extracted but not stored into str.

Definition at line 1196 of file istream.tcc.

References ios_base::badbit, ios_base::eofbit, basic_string::erase(), ios_base::failbit, ios_base::goodbit, and basic_string::max_size().

Referenced by std::getline().

bool std::operator!= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test difference of string and C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs.compare(rhs) != 0. False otherwise.

Definition at line 2189 of file basic_string.h.

bool std::operator!= | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test difference of C string and string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if rhs.compare(lhs) != 0. False otherwise.

Definition at line 2177 of file basic_string.h.

References basic_string::compare().

bool std::operator!= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test difference of two strings.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs.compare(rhs) != 0. False otherwise.

Definition at line 2165 of file basic_string.h.

References basic_string::compare().

basic_string<_CharT, _Traits, _Alloc> std::operator+ | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | _CharT | __rhs
| ) | `[inline]`

Concatenate string and character.

Parameters:

  | lhs | First string.
  | rhs | Last string.

Returns:
  New string with lhs followed by rhs.

Definition at line 2110 of file basic_string.h.

basic_string<_CharT, _Traits, _Alloc> std::operator+ | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Concatenate string and C string.

Parameters:

  | lhs | First string.
  | rhs | Last string.

Returns:
  New string with lhs followed by rhs.

Definition at line 2094 of file basic_string.h.

References basic_string::append().

basic_string< _CharT, _Traits, _Alloc > operator+ | ( | _CharT | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) |

Concatenate character and string.

Parameters:

  | lhs | First string.
  | rhs | Last string.

Returns:
  New string with lhs followed by rhs.

Definition at line 681 of file basic_string.tcc.

References basic_string::size().

basic_string< _CharT, _Traits, _Alloc > operator+ | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) |

Concatenate C string and string.

Parameters:

  | lhs | First string.
  | rhs | Last string.

Returns:
  New string with value of lhs followed by rhs.

Definition at line 665 of file basic_string.tcc.

References basic_string::size().

basic_string<_CharT, _Traits, _Alloc> std::operator+ | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) |

Concatenate two strings.

Parameters:

  | lhs | First string.
  | rhs | Last string.

Returns:
  New string with value of lhs followed by rhs.

Definition at line 2057 of file basic_string.h.

References basic_string::append().

bool std::operator< | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if C string precedes string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if lhs precedes rhs. False otherwise.

Definition at line 2226 of file basic_string.h.

References basic_string::compare().

bool std::operator< | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test if string precedes C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs precedes rhs. False otherwise.

Definition at line 2214 of file basic_string.h.

bool std::operator< | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if string precedes string.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs precedes rhs. False otherwise.

Definition at line 2202 of file basic_string.h.

basic_ostream< _CharT, _Traits > & operator<< | ( | basic_ostream< _CharT, _Traits > & | __os,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __str
| ) |

Write string to a stream.

Parameters:

  | os | Output stream.
  | str | String to write out.

Returns:
  Reference to the output stream.

Output characters of str into os following the same rules as for writing a C string.

Definition at line 648 of file ostream.tcc.

bool std::operator<= | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if C string doesn't follow string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if lhs doesn't follow rhs. False otherwise.

Definition at line 2300 of file basic_string.h.

References basic_string::compare().

bool std::operator<= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test if string doesn't follow C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs doesn't follow rhs. False otherwise.

Definition at line 2288 of file basic_string.h.

bool std::operator<= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if string doesn't follow string.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs doesn't follow rhs. False otherwise.

Definition at line 2276 of file basic_string.h.

bool std::operator== | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test equivalence of string and C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs.compare(rhs) == 0. False otherwise.

Definition at line 2152 of file basic_string.h.

bool std::operator== | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test equivalence of C string and string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if rhs.compare(lhs) == 0. False otherwise.

Definition at line 2140 of file basic_string.h.

References basic_string::compare().

bool std::operator== | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test equivalence of two strings.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs.compare(rhs) == 0. False otherwise.

Definition at line 2128 of file basic_string.h.

bool std::operator> | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if C string follows string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if lhs follows rhs. False otherwise.

Definition at line 2263 of file basic_string.h.

References basic_string::compare().

bool std::operator> | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test if string follows C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs follows rhs. False otherwise.

Definition at line 2251 of file basic_string.h.

bool std::operator> | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if string follows string.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs follows rhs. False otherwise.

Definition at line 2239 of file basic_string.h.

bool std::operator>= | ( | const _CharT * | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if C string doesn't precede string.

Parameters:

  | lhs | C string.
  | rhs | String.

Returns:
  True if lhs doesn't precede rhs. False otherwise.

Definition at line 2337 of file basic_string.h.

References basic_string::compare().

bool std::operator>= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const _CharT * | __rhs
| ) | `[inline]`

Test if string doesn't precede C string.

Parameters:

  | lhs | String.
  | rhs | C string.

Returns:
  True if lhs doesn't precede rhs. False otherwise.

Definition at line 2325 of file basic_string.h.

bool std::operator>= | ( | const basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | const basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Test if string doesn't precede string.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Returns:
  True if lhs doesn't precede rhs. False otherwise.

Definition at line 2313 of file basic_string.h.

basic_istream< _CharT, _Traits > & operator>> | ( | basic_istream< _CharT, _Traits > & | __is,
|  | basic_string< _CharT, _Traits, _Alloc > & | __str
| ) |

Read stream into a string.

Parameters:

  | is | Input stream.
  | str | Buffer to store into.

Returns:
  Reference to the input stream.

Stores characters from is into str until whitespace is found, the end of the stream is encountered, or str.max_size() is reached. If is.width() is non-zero, that is the limit on the number of characters stored into str. Any previous contents of str are erased.

Definition at line 1130 of file istream.tcc.

References basic_string::append(), ios_base::badbit, ios_base::eofbit, basic_string::erase(), ios_base::failbit, ios_base::goodbit, and basic_string::max_size().

void std::swap | ( | basic_string< _CharT, _Traits, _Alloc > & | __lhs,
|  | basic_string< _CharT, _Traits, _Alloc > & | __rhs
| ) | `[inline]`

Swap contents of two strings.

Parameters:

  | lhs | First string.
  | rhs | Second string.

Exchanges the contents of lhs and rhs in constant time.

Definition at line 2350 of file basic_string.h.

Referenced by vector< _Node *, _Nodeptr_Alloc >::swap(), list::swap(), deque::swap(), and std::tr1::swap().