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

◆ insert() [4/18]

template<typename _CharT, typename _Traits, typename _Alloc>
iterator std::basic_string< _CharT, _Traits, _Alloc >::insert ( const_iterator __p,
size_type __n,
_CharT __c )
inlineconstexpr

Insert multiple characters.

Parameters
__pConst_iterator referencing location in string to insert at.
__nNumber of characters to insert
__cThe character to insert.
Returns
Iterator referencing the first inserted char.
Exceptions
std::length_errorIf new length exceeds max_size().

Inserts __n copies of character __c starting at the position referenced by iterator __p. If adding characters causes the length to exceed max_size(), length_error is thrown. The value of the string doesn't change if an error is thrown.

Definition at line 2033 of file basic_string.h.

2034 {
2036 const size_type __pos = __p - begin();
2037 this->replace(__p, __p, __n, __c);
2038 return iterator(this->_M_data() + __pos);
2039 }
#define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
Definition assertions.h:66
_Alloc_traits::size_type size_type
constexpr pointer _M_data() const
constexpr iterator end() noexcept
constexpr iterator begin() noexcept
constexpr basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
__gnu_cxx::__normal_iterator< pointer, basic_string > iterator
Managing sequences of characters and character-like objects.

Referenced by std::money_get< _CharT, _InIter >::_M_extract(), std::money_put< _CharT, _OutIter >::_M_insert(), std::basic_string< _CharT >::insert(), std::basic_string< _CharT >::insert(), std::basic_string< _CharT >::insert(), std::basic_string< _CharT >::insert(), and std::basic_string< _CharT >::insert().

Here is the caller graph for this function: