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

◆ insert() [14/18]

template<typename _CharT, typename _Traits, typename _Alloc>
basic_string & std::basic_string< _CharT, _Traits, _Alloc >::insert ( size_type __pos,
size_type __n,
_CharT __c )
inline

Insert multiple characters.

Parameters
__posIndex in string to insert at.
__nNumber of characters to insert
__cThe character to insert.
Returns
Reference to this string.
Exceptions
std::length_errorIf new length exceeds max_size().
std::out_of_rangeIf __pos is beyond the end of this string.

Inserts __n copies of character __c starting at index __pos. If adding characters causes the length to exceed max_size(), length_error is thrown. If __pos > length(), out_of_range is thrown. The value of the string doesn't change if an error is thrown.

Definition at line 1780 of file cow_string.h.

1781 { return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
1782 size_type(0), __n, __c); }
_Alloc_traits::size_type size_type
constexpr size_type _M_check(size_type __pos, const char *__s) const
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.