Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

<string>

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at <string>.

Defines the container template class basic_string and various supporting templates.

For more information about basic_string, see basic_string Class

#include <string>  

The C++ language and the Standard C++ Library support two types of strings:

  • Null-terminated character arrays often referred to as C strings.

  • Template class objects, of type basic_string, that handle all char-like template arguments.

Typedefs

stringA type that describes a specialization of the template class basic_string with elements of type char as a string.
wstringA type that describes a specialization of the template class basic_string with elements of type wchar_t as a wstring.
u16stringA type that describes a specialization of the template class basic_string based on elements of type char16_t.
u32stringA type that describes a specialization of the template class basic_string based on elements of type char32_t.

Operators

operator+Concatenates two string objects.
operator!=Tests if the string object on the left side of the operator is not equal to the string object on the right side.
operator==Tests if the string object on the left side of the operator is equal to the string object on the right side.
operator<Tests if the string object on the left side of the operator is less than to the string object on the right side.
operator<=Tests if the string object on the left side of the operator is less than or equal to the string object on the right side.
operator<<A template function that inserts a string into the output stream.
operator>Tests if the string object on the left side of the operator is greater than to the string object on the right side.
operator>=Tests if the string object on the left side of the operator is greater than or equal to the string object on the right side.
operator>>A template function that extracts a string from the input stream.

Specialized Template Functions

swapExchanges the arrays of characters of two strings.
stodConverts a character sequence to a double.
stofConverts a character sequence to a float.
stoiConverts a character sequence to an integer.
stoldConverts a character sequence to a long double.
stollConverts a character sequence to a long long.
stoulConverts a character sequence to an unsigned long.
stoullConverts a character sequence to an unsigned long long.
to_stringConverts a value to a string.
to_wstringConverts a value to a wide string.

Functions

getline Template FunctionExtract strings from the input stream line by line.

Classes

basic_string ClassA template class that describes objects that can store a sequence of arbitrary character-like objects.
char_traits StructA template class that describes attributes associated with a character of type CharType

Specializations

char_traits<char> StructA struct that is a specialization of the template struct char_traits<CharType> to an element of type char.
char_traits<wchar_t> StructA struct that is a specialization of the template struct char_traits<CharType> to an element of type wchar_t.
char_traits<char16_t> StructA struct that is a specialization of the template struct char_traits<CharType> to an element of type char16_t.
char_traits<char32_t> StructA struct that is a specialization of the template struct char_traits<CharType> to an element of type char32_t.
  • Header: <string>

  • Namespace: std

Header Files Reference
Thread Safety in the C++ Standard Library

Show:
© 2017 Microsoft