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

◆ _S_construct() [3/5]

template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InIterator>
_CharT * std::basic_string< _CharT, _Traits, _Alloc >::_S_construct ( _InIterator __beg,
_InIterator __end,
const _Alloc & __a,
forward_iterator_tag  )

Definition at line 3329 of file cow_string.h.

3332 {
3333#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3334 if (__beg == __end && __a == _Alloc())
3335 return _S_empty_rep()._M_refdata();
3336#endif
3337 // NB: Not required, but considered best practice.
3339 __throw_logic_error(__N("basic_string::_S_construct null not valid"));
3340
3341 const size_type __dnew = static_cast<size_type>(std::distance(__beg,
3342 __end));
3343 // Check for out_of_range and length_error exceptions.
3345 __try
3346 { _S_copy_chars(__r->_M_refdata(), __beg, __end); }
3347 __catch(...)
3348 {
3349 __r->_M_destroy(__a);
3351 }
3352 __r->_M_set_length_and_sharable(__dnew);
3353 return __r->_M_refdata();
3354 }
#define __catch(X)
#define __N(msgid)
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void __throw_logic_error(const char *)
_Alloc_traits::size_type size_type
static constexpr void _S_copy_chars(_CharT *__p, _Iterator __k1, _Iterator __k2)
constexpr void _M_destroy(size_type __size)
static _Rep & _S_empty_rep() noexcept
Definition cow_string.h:467
Managing sequences of characters and character-like objects.
static _Rep * _S_create(size_type, size_type, const _Alloc &)