std::basic_string::empty

bool empty() const; Checks if the string has no characters, i.e. whether begin() == end(). Parameters (none). Return value true if the string is empty, false otherwise. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example #include <iostream> #include <string> int main() { std::string s; std::boolalpha(std::cout); std::cout << "s.empty():" << s.empty() << "\t s:'" &

std::basic_string::erase

basic_string& erase( size_type index = 0, size_type count = npos ); (1) (2) iterator erase( iterator position ); (until C++11) iterator erase( const_iterator position ); (since C++11) (3) iterator erase( iterator first, iterator last ); (until C++11) iterator erase( const_iterator first, const_iterator last ); (since C++11) Removes specified characters from the string. 1) Removes min(count, size() - index) characters starting at index. 2) Removes the charac

std::basic_string::end

iterator end(); const_iterator end() const; const_iterator cend() const; (since C++11) Returns an iterator to the character following the last character of the string. This character acts as a placeholder, attempting to access it results in undefined behavior. Parameters (none). Return value iterator to the character following the last character. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example #

std::basic_string::data

const CharT* data() const; Returns pointer to the underlying array serving as character storage. The pointer is such that the range [data(); data() + size()) is valid and the values in it correspond to the values stored in the string. The returned array is not required to be null-terminated. If empty() returns true, the pointer is a non-null pointer that should not be dereferenced. (until C++11) The returned array is null-terminated, that is, data() and c_str() perform the same func

std::basic_string::copy

size_type copy( CharT* dest, size_type count, size_type pos = 0) const; Copies a substring [pos, pos+count) to character string pointed to by dest. If the requested substring lasts past the end of the string, or if count == npos, the copied substring is [pos, size()). The resulting character string is not null-terminated. If pos >= size(), std::out_of_range is thrown. Parameters dest - pointer to the destination character string pos - pos

std::basic_string::compare

int compare( const basic_string& str ) const; (1) int compare( size_type pos1, size_type count1, const basic_string& str ) const; (2) (3) int compare( size_type pos1, size_type count1, const basic_string& str, size_type pos2, size_type count2 ) const; (until C++14) int compare( size_type pos1, size_type count1, const basic_string& str, size_type pos2, size_type count2 = npos ) const; (since C

std::basic_string::basic_string

(1) explicit basic_string( const Allocator& alloc = Allocator() ); (until C++14) basic_string() : basic_string( Allocator() ) {} explicit basic_string( const Allocator& alloc ); (since C++14) basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() ); (2) basic_string( const basic_string& other, size_type pos, size_type count = std::basic_string::npos, const Allocato

std::basic_string::at

reference at( size_type pos ); const_reference at( size_type pos ) const; Returns a reference to the character at specified location pos. Bounds checking is performed, exception of type std::out_of_range will be thrown on invalid access. Parameters pos - position of the character to return Return value Reference to the requested character. Exceptions Throws std::out_of_range if pos >= size(). Complexity Constant. Example #include <stdexcept>

std::basic_string::back

CharT& back(); (since C++11) const CharT& back() const; (since C++11) Returns reference to the last character in the string. The behavior is undefined if empty() == true. Parameters (none). Return value reference to the last character, equivalent to operator[](size() - 1). Complexity Constant. Example #include <iostream> #include <string> int main() { { std::string s("Exemplary"); char& back = s.back(); back = 's'; std::cou

std::basic_string::begin

iterator begin(); const_iterator begin() const; const_iterator cbegin() const; (since C++11) Returns an iterator to the first character of the string. begin() returns a mutable or constant iterator, depending on the constness of *this. cbegin() always returns a constant iterator. It is equivalent to const_cast<const basic_string&>(*this).begin(). Parameters (none). Return value iterator to the first character. Exceptions (none) (until C++11) noexcept spec