Standard C++ Library Class Reference
rfind(basic_string(1, c), pos)
basic_string&
replace (size_type pos, size_type n1, const basic_string& s);
basic_string&
replace (size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2);
basic_string&
replace (size_type pos, size_type n1, const charT* s,
size_type n2);
basic_string&
replace (size_type pos, size_type n1, const charT* s);
basic_string&
replace (size_type pos, size_type n1, size_type n2, charT c);
The replace function replaces selected elements of this string with an alternate set of elements. All of these versions
insert the new elements in place of n1 elements in this string, starting at position pos. They each throw an out_of_range
exception if pos1 > size()and a length_error exception if the resulting string size exceeds max_size().
The second version replaces elements of the original string with n2 characters from string s starting at position pos2. It
will throw the out_of_range exception if pos2 > s.size(). The third variation of the function replaces elements in the
original string with n2 elements from the array pointed to by s. The fourth version replaces elements in the string with
elements from the array pointed to by s, up to, but not including, a traits::eos() character. The fifth replaces n elements
with n2 repetitions of character c.
basic_string&
replace (iterator i1, iterator i2,
const basic_string& str);
basic_string&
replace (iterator i1, iterator i2, const charT* s,
size_type n);
basic_string&
replace (iterator i1, iterator i2, const charT* s);
basic_string&
replace (iterator i1, iterator i2, size_type n,
charT c);
template<class InputIterator>
basic_string&
replace (iterator i1, iterator i2,
InputIterator j1, InputIterator j2);
Replace selected elements of this string with an alternative set of elements. All of these versions of replace require
iterators i1 and i2 to be valid iterators on this string. The elements specified by the range [i1, i2) are replaced by the new
elements.
The first version shown here replaces with all members in str. The second version starts at position i1, and replaces the
next n characters with n characters of the array pointed to by s. The third variation replaces string elements with
elements from the array pointed to by s up to, but not including, a traits::eos() character. The fourth version replaces
string elements with n repetitions of c. The last variation shown here replaces string elements with the members
specified in the range [j1, j2).
void reserve (size_type res_arg);
Assures that the storage capacity is at least res_arg.
void
resize (size_type n, charT c);
void
resize (size_type n);
Changes the capacity of this string to n. If the new capacity is smaller than the current size of the string, then it is
truncated. If the capacity is larger, then the string is padded with c characters. The latter resize member pads the string
with default characters specified by traits::eos().
size type