std::basic_string
From Cppreference
Defined in header <string>
| ||
template<
typename CharT, | ||
The class template basic_string stores and manipulates sequences of characters.
Several specializations for common character types are provided:
Defined in header
<ostream> | |
Type | Definition |
string | basic_string<char> |
wstring | basic_string<wchar_t> |
u16string | basic_string<char16_t> |
u32string | basic_string<char32_t> |
Contents |
[edit] Member types
Member type | Definition |
traits_type | Traits |
value_type | Traits::char_type |
allocator_type | Allocator |
size_type | Unsigned integral type (usually size_t) |
difference_type | Signed integer type (usually ptrdiff_t) |
reference | Allocator::reference (pre-C++11 version) value_type& (C++11 version) |
const_reference | Allocator::const_reference (pre-C++11 version) const value_type& (C++11 version) |
pointer | T* (pre-C++11 version) std::allocator_traits<Allocator>::pointer (C++11 version) |
const_pointer | const T* (pre-C++11 version) std::allocator_traits<Allocator>::const_pointer (C++11 version) |
iterator | Random access iterator |
const_iterator | Constant random access iterator |
reverse_iterator
| std::reverse_iterator<iterator> |
const_reverse_iterator
| std::reverse_iterator<const_iterator> |
This section is incomplete |
Member functions | |||
| constructs the basic_string (public member function) | ||
| assigns values to the string (public member function) | ||
| assign characters to a string (public member function) | ||
| returns the associated allocator (public member function) | ||
Element access | |||
| access specified character with bounds checking (public member function) | ||
| access specified character (public member function) | ||
| accesses the first character (public member function) | ||
| accesses the last character (public member function) | ||
| returns a pointer to the first character of a string (public member function) | ||
| returns a non-modifiable standard C character array version of the string (public member function) | ||
Iterators | |||
| returns an iterator to the beginning (public member function) | ||
| returns an iterator to the end (public member function) | ||
| returns a reverse iterator to the beginning (public member function) | ||
| returns a reverse iterator to the end (public member function) | ||
Capacity | |||
| checks whether the string is empty (public member function) | ||
| returns the number of characters (public member function) | ||
| returns the length of the string (public member function) | ||
| returns the maximum number of characters (public member function) | ||
| reserves storage (public member function) | ||
| returns the number of characters that can be held in currently allocated storage (public member function) | ||
| reduces memory usage by freeing unused memory (public member function) | ||
Operations | |||
| clears the contents (public member function) | ||
| inserts characters (public member function) | ||
| removes characters (public member function) | ||
| inserts characters to the end (public member function) | ||
| removes the last character (public member function) | ||
| appends characters to the end (public member function) | ||
| compares two strings (public member function) | ||
| replaces every occurrence of specified characters (public member function) | ||
| returns a substring (public member function) | ||
| copies characters (public member function) | ||
| changes the number of characters stored (public member function) | ||
| swaps the contents (public member function) | ||
Search | |||
| find characters in the string (public member function) | ||
| find the last occurrence of a substring (public member function) | ||
| find first occurrence of characters (public member function) | ||
| find first absence of characters (public member function) | ||
| find last occurrence of characters (public member function) | ||
| find last absence of characters (public member function) | ||
Constants | |||
| special value. The exact meaning depends on the context (public static member constant) |
This section is incomplete Reason: missing comparison operators and std::swap |