libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ replace() [26/30]

template<typename _CharT, typename _Traits, typename _Alloc>
basic_string & std::basic_string< _CharT, _Traits, _Alloc >::replace ( size_type __pos,
size_type __n1,
const _CharT * __s,
size_type __n2 )

Replace characters with value of a C substring.

Parameters
__posIndex of first character to replace.
__n1Number of characters to be replaced.
__sC string to insert.
__n2Number of characters from s to use.
Returns
Reference to this string.
Exceptions
std::out_of_rangeIf pos1 > size().
std::length_errorIf new length exceeds max_size().

Removes the characters in the range [__pos,__pos + __n1) from this string. In place, the first __n2 characters of __s are inserted, or all of __s if __n2 is too large. If __pos is beyond end of string, out_of_range is thrown. If the length of result exceeds max_size(), length_error is thrown. The value of the string doesn't change if an error is thrown.