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

◆ insert() [5/18]

template<typename _CharT, typename _Traits, typename _Alloc>
iterator std::basic_string< _CharT, _Traits, _Alloc >::insert ( iterator __p,
_CharT __c )
inline

Insert one character.

Parameters
__pIterator referencing position in string to insert at.
__cThe character to insert.
Returns
Iterator referencing newly inserted char.
Exceptions
std::length_errorIf new length exceeds max_size().

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

Definition at line 1798 of file cow_string.h.

1799 {
1801 const size_type __pos = __p - _M_ibegin();
1803 _M_rep()->_M_set_leaked();
1804 return iterator(_M_data() + __pos);
1805 }
#define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
Definition assertions.h:66
_Alloc_traits::size_type size_type
constexpr pointer _M_data() const
iterator _M_ibegin() const noexcept
Definition cow_string.h:343
iterator _M_iend() const noexcept
Definition cow_string.h:347
_Rep * _M_rep() const noexcept
Definition cow_string.h:337
constexpr basic_string & _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, _CharT __c)
__gnu_cxx::__normal_iterator< pointer, basic_string > iterator
Managing sequences of characters and character-like objects.
void _M_set_leaked() noexcept
Definition cow_string.h:228