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

◆ replace() [30/30]

template<typename _CharT, typename _Traits, typename _Alloc>
basic_string & std::basic_string< _CharT, _Traits, _Alloc >::replace ( size_type __pos1,
size_type __n1,
const basic_string< _CharT, _Traits, _Alloc > & __str,
size_type __pos2,
size_type __n2 = npos )
inline

Replace characters with value from another string.

Parameters
__pos1Index of first character to replace.
__n1Number of characters to be replaced.
__strString to insert.
__pos2Index of first character of str to use.
__n2Number of characters from str to use.
Returns
Reference to this string.
Exceptions
std::out_of_rangeIf __pos1 > size() or __pos2 > __str.size().
std::length_errorIf new length exceeds max_size().

Removes the characters in the range [__pos1,__pos1 + n) from this string. In place, the value of __str is inserted. If __pos is beyond end of string, out_of_range is thrown. If the length of the result exceeds max_size(), length_error is thrown. The value of the string doesn't change if an error is thrown.

Definition at line 1950 of file cow_string.h.

1952 { return this->replace(__pos1, __n1, __str._M_data()
1953 + __str._M_check(__pos2, "basic_string::replace"),
constexpr size_type _M_limit(size_type __pos, size_type __off) const noexcept
constexpr void _M_data(pointer __p)
constexpr size_type _M_check(size_type __pos, const char *__s) const
constexpr basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
Managing sequences of characters and character-like objects.