Standard C++ Library Class Reference
template<class InputIterator>
basic_string&
assign (InputIterator first, InputIterator last);
Replace the value of this string with the value of another.
All versions of the function assign values to this string. The first two variations assign the lesser of n and s.size() - pos
characters of s, beginning at position pos. The second variation throws an out_of_range exception if pos > str.size(). The
third version of the function assigns n characters of the array pointed to by s. The fourth version assigns elements from
the array pointed to by s up to, but not including, a traits::eos() character. The fifth assigns one or n repetitions of c. The
last variation assigns the members specified by the range [first, last).
All functions will throw a length_error exception if the resulting length will exceed max_size(). All return a reference to
this string after completion.
const_reference
at (size_type pos) const;
reference
at (size_type pos);
If pos < size(), returns the element at position pos in this string. Otherwise, an out_of_range exception is thrown.
size_type
capacity () const;
Returns the current storage capacity of the string. This is guaranteed to be at least as large as size().
int
compare (const basic_string& str);
Returns the result of a lexographical comparison between elements of this string and elements of str. The return value is:
<0 if size() < str.size()
0 if size() == str.size()
>0 if size() > str.size()
int
compare (size_type pos1, size_type n1,
const basic_string& str) const;
int
compare (size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2) const;
int
compare (charT* s) const;
int
compare (size_type pos, size_type n1, charT* s) const;
int
compare (size_type pos, size_type n1, charT* s,
size_type n2) const;
Return the result of a lexographical comparison between elements of this string and a given comparison string. The
members return, respectively:
compare (str)
compare (basic_string (str, pos2, n2))
compare (basic_string(s))
compare (basic_string(s, npos))
compare (basic_string (s,n2))
size_type
copy (charT* s, size_type n, size_type pos = 0) const;
Replaces elements in memory with copies of elements from this string. An out_of_range exception will be thrown if pos
> size(). The lesser of n and size() - pos elements of this string, starting at position pos are copied into the array pointed
to by s. No terminating null is appended to s.
const charT*