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

◆ insert() [18/18]

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

Insert a substring.

Parameters
__pos1Position in string to insert at.
__strThe string to insert.
__pos2Start of characters in str to insert.
__nNumber of characters to insert.
Returns
Reference to this string.
Exceptions
std::length_errorIf new length exceeds max_size().
std::out_of_rangeIf pos1 > size() or __pos2 > str.size().

Starting at pos1, insert __n character of __str beginning with __pos2. If adding characters causes the length to exceed max_size(), length_error is thrown. If __pos1 is beyond the end of this string or __pos2 is beyond the end of __str, out_of_range is thrown. The value of the string doesn't change if an error is thrown.

Definition at line 1716 of file cow_string.h.

1718 { return this->insert(__pos1, __str._M_data()
1719 + __str._M_check(__pos2, "basic_string::insert"),
1720 __str._M_limit(__pos2, __n)); }
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 iterator insert(const_iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
Managing sequences of characters and character-like objects.