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

◆ replace() [20/30]

template<typename _CharT, typename _Traits, typename _Alloc>
basic_string & std::basic_string< _CharT, _Traits, _Alloc >::replace ( iterator __i1,
iterator __i2,
size_type __n,
_CharT __c )
inline

Replace range of characters with multiple characters.

Parameters
__i1Iterator referencing start of range to replace.
__i2Iterator referencing end of range to replace.
__nNumber of characters to insert.
__cCharacter to insert.
Returns
Reference to this string.
Exceptions
std::length_errorIf new length exceeds max_size().

Removes the characters in the range [__i1,__i2). In place, __n copies of __c are inserted. 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.

Definition at line 2098 of file cow_string.h.

2099 {
2101 && __i2 <= _M_iend());
2102 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
2103 }
#define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
Definition assertions.h:66
iterator _M_ibegin() const noexcept
Definition cow_string.h:343
iterator _M_iend() const noexcept
Definition cow_string.h:347
constexpr basic_string & _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c)
Managing sequences of characters and character-like objects.