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::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::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::c_str

const CharT* c_str() const; Returns a pointer to a null-terminated character array with data equivalent to those stored in the string. The pointer is such that the range [c_str(); c_str() + size()] is valid and the values in it correspond to the values stored in the string with an additional null character after the last position. The pointer obtained from c_str() may be invalidated by: Passing a non-const reference to the string to any standard library function, or Calling non-const

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::clear

void clear(); Removes all characters from the string as if by executing erase(begin(), end()). The allocated memory will not be released, effectively leaving the capacity of the string unchanged. All pointers, references, and iterators are invalidated. Parameters (none). Return value (none). Notes Unlike for std::vector::clear, the C++ standard does not explicitly require that capacity is unchanged by this function, but existing implementations do not change capacity. Excepti

std::basic_string::capacity

size_type capacity() const; Returns the number of characters that the string has currently allocated space for. Parameters (none). Return value capacity of the currently allocated storage. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. Example #include <iostream> #include <string> void show_capacity(std::string const& s) { std::cout << "'" << s << "' has capacity " <&

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

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