Strings library


library

C++ Strings library

The C++ strings library provides the definitions of the basic_string class, which is a class template specifically designed to manipulate strings of characters of any character type. It also include two specific instantiations: string and wstring, which respectively use char and wchar_t as character types.


The characteristics of characters taken into consideration in these classes are not only the type itself, but also a set of traits. These traits are defined by specializing the class template char_traits for the specific type. Default specifications exist for both char and wchar_t:


This reference uses as a base the string class, even though this is only one of the possible template instantiations (we believe this provides a better readability):

A set of global functions provide some additional functionality for strings to interact either with other string objects or with objects of other types, mainly through the overloading of operators:


The header also declares some functions that extend the functionality of streams (iostream library) to string objects:


Notice that some other operators are also overloaded as members of class string (+=, =, []).