std::basic_string::substr

basic_string substr( size_type pos = 0, size_type count = npos ) const; Returns a substring [pos, pos+count). If the requested substring extends past the end of the string, or if count == npos, the returned substring is [pos, size()). Parameters pos - position of the first character to include count - length of the substring Return value An empty string if pos == size(). String containing the substring [pos, pos+count). Exceptions std::

std::basic_string::rend

reverse_iterator rend(); const_reverse_iterator rend() const; const_reverse_iterator crend() const; (since C++11) Returns a reverse iterator to the character following the last character of the reversed string. It corresponds to the character preceding the first character of the non-reversed string. This character acts as a placeholder, attempting to access it results in undefined behavior. Parameters (none). Return value reverse iterator to the character following the

std::basic_string::rbegin

reverse_iterator rbegin(); const_reverse_iterator rbegin() const; const_reverse_iterator crbegin() const; (since C++11) Returns a reverse iterator to the first character of the reversed string. It corresponds to the last character of the non-reversed string. Parameters (none). Return value reverse iterator to the first character. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example #include <iostr

std::basic_string::resize

void resize( size_type count ); (1) void resize( size_type count, CharT ch ); (2) Resizes the string to contain count characters. If the current size is less than count, additional characters are appended. If the current size is greater than count, the string is reduced to its first count elements. The first version initializes new characters to CharT(), the second version initializes new characters to ch. Parameters count - new size of the string ch - character to i

std::basic_string::replace

basic_string& replace( size_type pos, size_type count, const basic_string& str ); (1) basic_string& replace( const_iterator first, const_iterator last, const basic_string& str ); (1) (2) basic_string& replace( size_type pos, size_type count, const basic_string& str, size_type pos2, size_type count2 ); (until C++14) basic_string& replace( size_type pos, size

std::basic_string::reserve

void reserve( size_type new_cap = 0 ); Informs a std::basic_string object of a planned change in size, so that it can manage the storage allocation appropriately. If new_cap is greater than the current capacity(), new storage is allocated, and capacity() is made equal or greater than new_cap. If new_cap is less than the current capacity(), this is a non-binding shrink request. If new_cap is less than the current size(), this is a non-binding shrink-to-fit request equivalent to shri

std::basic_string::operator[]

reference operator[]( size_type pos ); (1) const_reference operator[]( size_type pos ) const; (2) Returns a reference to the character at specified location pos. No bounds checking is performed. 1) If pos == size(), the behavior is undefined. 2) If pos == size(), a reference to the character with value CharT() (the null character) is returned. (until C++11) If pos == size(), a reference to the character with value CharT() (the null character) is returned. For the first

std::basic_string::npos

static const size_type npos = -1; This is a special value equal to the maximum value representable by the type size_type. The exact meaning depends on context, but it is generally used either as end of string indicator by the functions that expect a string index or as the error indicator by the functions that return a string index. Example #include <iostream> #include <bitset> #include <string> int main() { // string search functions return npos if nothing i

std::basic_string::max_size

size_type max_size() const; Returns the maximum number of elements the string is able to hold due to system or library implementation limitations, i.e. ​std::distance(begin(), end())​ for the largest string. Parameters (none). Return value Maximum number of characters. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example #include <iostream> #include <string> int main() { std::string s;

std::basic_string::push_back

void push_back( CharT ch ); Appends the given character ch to the end of the string. Parameters ch - the character to append Return value (none). Complexity Amortized constant. Exceptions If an exception is thrown for any reason, this function has no effect (strong exception guarantee). (since C++11). If the operation would result in size() > max_size(), throws std::length_error. See also pop_back (C++11) removes the last character (public member functio