Standard C++ Library Class Reference
capacity() a value at least as large as size()
template <class InputIterator>
basic_string (InputIterator first, InputIterator last,
const Allocator& a = Allocator());
Creates a basic_string of length last - first, filled with all values obtained by dereferencing the InputIterators on the
range [first, last). The effects of this constructor are:
data() points at the first element of an allocated copy of the elements in the range [first,last)
size() distance between first and last
capacity() a value at least as large as size()
~basic_string ();
Releases any allocated memory for this basic_string.
Operators
basic_string&
operator= (const basic_string& str);
Assignment operator. Sets the contents of this string to be the same as str. The effects of operator= are:
data() points at the first element of an allocated copy of the array whose first element is pointed at by str.size()
size() str.size()
capacity() a value at least as large as size()
basic_string&
operator= (const charT * s);
Assignment operator. Sets the contents of this string to be the same as s up to, but not including, the traits::eos()
character.
basic_string&
operator= (charT c);
Assignment operator. Sets the contents of this string to be equal to the single charT c.
charT
operator[] (size_type pos) const;
reference
operator[] (size_type pos);
If pos < size(), returns the element at position pos in this string. If pos == size(), the const version returns traits::eos(),
the behavior of the non-const version is undefined. The reference returned by the non-const version is invalidated by any
call to c_str(), data(), or any non-const member function for the object.
basic_string&
operator+= (const basic_string& s);
basic_string&
operator+= (const charT* s);
basic_string&
operator+= (charT c);
Concatenates a string onto the current contents of this string. The second member operator uses traits::length() to
determine the number of elements from s to add. The third member operator adds the single character c. All return a
reference to this string after completion.