33#define _COW_STRING_H 1
35#if ! _GLIBCXX_USE_CXX11_ABI
39#ifdef __cpp_lib_is_constant_evaluated
41# define __cpp_lib_constexpr_string 201811L
42#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
44# define __cpp_lib_constexpr_string 201611L
47namespace std _GLIBCXX_VISIBILITY(default)
49_GLIBCXX_BEGIN_NAMESPACE_VERSION
115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
119 rebind<_CharT>::other _CharT_alloc_type;
124 typedef _Traits traits_type;
125 typedef typename _Traits::char_type value_type;
126 typedef _Alloc allocator_type;
127 typedef typename _CharT_alloc_traits::size_type size_type;
128 typedef typename _CharT_alloc_traits::difference_type difference_type;
129#if __cplusplus < 201103L
130 typedef typename _CharT_alloc_type::reference reference;
131 typedef typename _CharT_alloc_type::const_reference const_reference;
133 typedef value_type& reference;
134 typedef const value_type& const_reference;
137 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
138 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
139 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
146 typedef iterator __const_iterator;
166 size_type _M_capacity;
167 _Atomic_word _M_refcount;
170 struct _Rep : _Rep_base
174 rebind<char>::other _Raw_bytes_alloc;
189 static const size_type _S_max_size;
190 static const _CharT _S_terminal;
194 static size_type _S_empty_rep_storage[];
202 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
203 return *
reinterpret_cast<_Rep*
>(__p);
209#if defined(__GTHREADS)
216 return this->_M_refcount < 0;
223#if defined(__GTHREADS)
229 if (!__gnu_cxx::__is_single_threaded())
232 return this->_M_refcount > 0;
237 { this->_M_refcount = -1; }
241 { this->_M_refcount = 0; }
246#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
250 this->_M_set_sharable();
251 this->_M_length = __n;
252 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
260 {
return reinterpret_cast<_CharT*
>(
this + 1); }
266 ? _M_refcopy() : _M_clone(
__alloc1);
271 _S_create(size_type, size_type,
const _Alloc&);
276#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
281 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
290 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
293 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
300 _M_destroy(
const _Alloc&)
throw();
305#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
308 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
313 _M_clone(
const _Alloc&, size_type
__res = 0);
317 struct _Alloc_hider : _Alloc
320 : _Alloc(__a), _M_p(
__dat) { }
330 static const size_type
npos =
static_cast<size_type
>(-1);
334 mutable _Alloc_hider _M_dataplus;
338 {
return _M_dataplus._M_p; }
342 {
return (_M_dataplus._M_p = __p); }
345 _M_rep() const _GLIBCXX_NOEXCEPT
346 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
351 _M_ibegin() const _GLIBCXX_NOEXCEPT
352 {
return iterator(_M_data()); }
355 _M_iend() const _GLIBCXX_NOEXCEPT
356 {
return iterator(_M_data() + this->
size()); }
361 if (!_M_rep()->_M_is_leaked())
366 _M_check(size_type __pos,
const char* __s)
const
368 if (__pos > this->
size())
369 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
370 "this->size() (which is %zu)"),
371 __s, __pos, this->
size());
376 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
379 __throw_length_error(__N(__s));
384 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
386 const bool __testoff = __off < this->
size() - __pos;
387 return __testoff ? __off : this->
size() - __pos;
392 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
394 return (less<const _CharT*>()(__s, _M_data())
395 || less<const _CharT*>()(_M_data() + this->
size(), __s));
401 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
404 traits_type::assign(*__d, *__s);
406 traits_type::copy(__d, __s, __n);
410 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
413 traits_type::assign(*__d, *__s);
415 traits_type::move(__d, __s, __n);
419 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
422 traits_type::assign(*__d, __c);
424 traits_type::assign(__d, __n, __c);
429 template<
class _Iterator>
431 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
433 for (; __k1 != __k2; ++__k1, (void)++__p)
434 traits_type::assign(*__p, *__k1);
438 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
439 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
442 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
444 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
447 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
448 { _M_copy(__p, __k1, __k2 - __k1); }
451 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
453 { _M_copy(__p, __k1, __k2 - __k1); }
456 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
458 const difference_type __d = difference_type(__n1 - __n2);
460 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
461 return __gnu_cxx::__numeric_traits<int>::__max;
462 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
463 return __gnu_cxx::__numeric_traits<int>::__min;
469 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
475 _S_empty_rep() _GLIBCXX_NOEXCEPT
476 {
return _Rep::_S_empty_rep(); }
478#if __cplusplus >= 201703L
480 typedef basic_string_view<_CharT, _Traits> __sv_type;
482 template<
typename _Tp,
typename _Res>
484 __and_<is_convertible<const _Tp&, __sv_type>,
485 __not_<is_convertible<const _Tp*, const basic_string*>>,
486 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
491 _S_to_string_view(__sv_type __svt)
noexcept
500 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
524#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
526 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
528 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
537 : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
560 const _Alloc& __a = _Alloc());
578 size_type __n,
const _Alloc& __a);
590 const _Alloc& __a = _Alloc())
591 : _M_dataplus(_S_construct(
__s,
__s + __n, __a), __a)
599#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
602 template<
typename = _RequireAllocator<_Alloc>>
616 : _M_dataplus(_S_construct(__n, __c, __a), __a)
619#if __cplusplus >= 201103L
630#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
632 __str._M_data(_S_empty_rep()._M_refdata());
638 if (_M_rep()->_M_is_shared())
639 __gnu_cxx::__atomic_add_dispatch(&_M_rep()->_M_refcount, 1);
641 _M_rep()->_M_refcount = 1;
659 : _M_dataplus(__str._M_data(), __a)
663#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
664 __str._M_data(_S_empty_rep()._M_refdata());
666 __str._M_data(_S_construct(size_type(), _CharT(), __a));
670 _M_dataplus._M_p = _S_construct(__str.
begin(), __str.
end(), __a);
674#if __cplusplus >= 202100L
685 template<
class _InputIterator>
687 const _Alloc& __a = _Alloc())
688 : _M_dataplus(_S_construct(
__beg, __end, __a), __a)
691#if __cplusplus >= 201703L
699 template<
typename _Tp,
702 const _Alloc& __a = _Alloc())
710 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
713 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
728 {
return this->
assign(__str); }
736 {
return this->
assign(__s); }
752#if __cplusplus >= 201103L
781#if __cplusplus >= 201703L
786 template<
typename _Tp>
789 {
return this->
assign(__svt); }
808 return iterator(_M_data());
817 {
return const_iterator(_M_data()); }
827 return iterator(_M_data() + this->
size());
836 {
return const_iterator(_M_data() + this->
size()); }
852 const_reverse_iterator
870 const_reverse_iterator
874#if __cplusplus >= 201103L
881 {
return const_iterator(this->_M_data()); }
889 {
return const_iterator(this->_M_data() + this->
size()); }
896 const_reverse_iterator
905 const_reverse_iterator
916 {
return _M_rep()->_M_length; }
922 {
return _M_rep()->_M_length; }
927 {
return _Rep::_S_max_size; }
954 { this->
resize(__n, _CharT()); }
956#if __cplusplus >= 201103L
957#pragma GCC diagnostic push
958#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
963#pragma GCC diagnostic pop
972 {
return _M_rep()->_M_capacity; }
995#if __cplusplus > 201703L
996 [[deprecated(
"use shrink_to_fit() instead")]]
1004#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
1008 if (_M_rep()->_M_is_shared())
1011 _M_data(_S_empty_rep()._M_refdata());
1014 _M_rep()->_M_set_length_and_sharable(0);
1020 { _M_mutate(0, this->
size(), 0); }
1027 _GLIBCXX_NODISCARD
bool
1029 {
return this->
size() == 0; }
1046 return _M_data()[
__pos];
1068 return _M_data()[
__pos];
1084 if (__n >= this->
size())
1085 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1086 "(which is %zu) >= this->size() "
1089 return _M_data()[__n];
1107 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1108 "(which is %zu) >= this->size() "
1112 return _M_data()[__n];
1115#if __cplusplus >= 201103L
1123 __glibcxx_assert(!
empty());
1134 __glibcxx_assert(!
empty());
1145 __glibcxx_assert(!
empty());
1156 __glibcxx_assert(!
empty());
1169 {
return this->
append(__str); }
1178 {
return this->
append(__s); }
1192#if __cplusplus >= 201103L
1200 {
return this->
append(__l.begin(),
__l.size()); }
1203#if __cplusplus >= 201703L
1209 template<
typename _Tp>
1212 {
return this->
append(__svt); }
1256 __glibcxx_requires_string(
__s);
1257 return this->
append(__s, traits_type::length(
__s));
1271#if __cplusplus >= 201103L
1279 {
return this->
append(__l.begin(),
__l.size()); }
1290 template<
class _InputIterator>
1293 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
1295#if __cplusplus >= 201703L
1301 template<
typename _Tp>
1306 return this->
append(__sv.data(),
__sv.size());
1317 template<
typename _Tp>
1323 + std::__sv_check(
__sv.size(),
__pos,
"basic_string::append"),
1324 std::__sv_limit(
__sv.size(),
__pos, __n));
1335 const size_type
__len = 1 + this->
size();
1336 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
1338 traits_type::assign(_M_data()[this->
size()], __c);
1339 _M_rep()->_M_set_length_and_sharable(
__len);
1350#if __cplusplus >= 201103L
1383 {
return this->
assign(__str._M_data()
1384 +
__str._M_check(
__pos,
"basic_string::assign"),
1412 __glibcxx_requires_string(
__s);
1413 return this->
assign(__s, traits_type::length(
__s));
1427 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1437 template<
class _InputIterator>
1440 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
1442#if __cplusplus >= 201103L
1450 {
return this->
assign(__l.begin(),
__l.size()); }
1453#if __cplusplus >= 201703L
1459 template<
typename _Tp>
1464 return this->
assign(__sv.data(),
__sv.size());
1474 template<
typename _Tp>
1480 + std::__sv_check(
__sv.size(),
__pos,
"basic_string::assign"),
1481 std::__sv_limit(
__sv.size(),
__pos, __n));
1499 insert(iterator __p, size_type __n, _CharT __c)
1500 { this->
replace(__p, __p, __n, __c); }
1514 template<
class _InputIterator>
1519#if __cplusplus >= 201103L
1529 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1530 this->
insert(__p - _M_ibegin(),
__l.begin(),
__l.size());
1612 __glibcxx_requires_string(
__s);
1613 return this->
insert(__pos,
__s, traits_type::length(
__s));
1634 {
return _M_replace_aux(_M_check(
__pos,
"basic_string::insert"),
1635 size_type(0), __n, __c); }
1653 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
1654 const size_type
__pos = __p - _M_ibegin();
1655 _M_replace_aux(
__pos, size_type(0), size_type(1), __c);
1656 _M_rep()->_M_set_leaked();
1657 return iterator(_M_data() +
__pos);
1660#if __cplusplus >= 201703L
1667 template<
typename _Tp>
1683 template<
typename _Tp>
1689 return this->
replace(__pos1, size_type(0),
__sv.data()
1690 + std::__sv_check(
__sv.size(),
__pos2,
"basic_string::insert"),
1713 _M_mutate(_M_check(
__pos,
"basic_string::erase"),
1714 _M_limit(
__pos, __n), size_type(0));
1729 _GLIBCXX_DEBUG_PEDASSERT(
__position >= _M_ibegin()
1732 _M_mutate(
__pos, size_type(1), size_type(0));
1733 _M_rep()->_M_set_leaked();
1734 return iterator(_M_data() +
__pos);
1747 erase(iterator __first, iterator __last);
1749#if __cplusplus >= 201103L
1758 __glibcxx_assert(!
empty());
1806 +
__str._M_check(
__pos2,
"basic_string::replace"),
1850 __glibcxx_requires_string(
__s);
1873 {
return _M_replace_aux(_M_check(
__pos,
"basic_string::replace"),
1911 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <=
__i1 &&
__i1 <=
__i2
1912 &&
__i2 <= _M_iend());
1932 __glibcxx_requires_string(
__s);
1953 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <=
__i1 &&
__i1 <=
__i2
1954 &&
__i2 <= _M_iend());
1955 return _M_replace_aux(
__i1 - _M_ibegin(),
__i2 -
__i1, __n, __c);
1973 template<
class _InputIterator>
1978 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <=
__i1 &&
__i1 <=
__i2
1979 &&
__i2 <= _M_iend());
1980 __glibcxx_requires_valid_range(
__k1,
__k2);
1981 typedef typename std::__is_integer<_InputIterator>::__type
_Integral;
1990 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <=
__i1 &&
__i1 <=
__i2
1991 &&
__i2 <= _M_iend());
1992 __glibcxx_requires_valid_range(
__k1,
__k2);
1998 replace(iterator __i1, iterator __i2,
1999 const _CharT* __k1,
const _CharT* __k2)
2001 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
2002 && __i2 <= _M_iend());
2003 __glibcxx_requires_valid_range(__k1, __k2);
2004 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
2009 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
2011 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
2012 && __i2 <= _M_iend());
2013 __glibcxx_requires_valid_range(__k1, __k2);
2014 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
2015 __k1.base(), __k2 - __k1);
2019 replace(iterator __i1, iterator __i2,
2020 const_iterator __k1, const_iterator __k2)
2022 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
2023 && __i2 <= _M_iend());
2024 __glibcxx_requires_valid_range(__k1, __k2);
2025 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
2026 __k1.base(), __k2 - __k1);
2029#if __cplusplus >= 201103L
2049#if __cplusplus >= 201703L
2057 template<
typename _Tp>
2074 template<
typename _Tp>
2082 + std::__sv_check(
__sv.size(),
__pos2,
"basic_string::replace"),
2095 template<
typename _Tp>
2105 template<
class _Integer>
2109 {
return _M_replace_aux(
__i1 - _M_ibegin(),
__i2 -
__i1, __n, __val); }
2111 template<
class _InputIterator>
2113 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
2114 _InputIterator __k2, __false_type);
2117 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2121 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
2126 template<
class _InIterator>
2128 _S_construct_aux(_InIterator __beg, _InIterator __end,
2129 const _Alloc& __a, __false_type)
2131 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
2132 return _S_construct(__beg, __end, __a, _Tag());
2137 template<
class _Integer>
2139 _S_construct_aux(_Integer __beg, _Integer __end,
2140 const _Alloc& __a, __true_type)
2141 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
2145 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
2146 {
return _S_construct(__req, __c, __a); }
2148 template<
class _InIterator>
2150 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
2152 typedef typename std::__is_integer<_InIterator>::__type _Integral;
2153 return _S_construct_aux(__beg, __end, __a, _Integral());
2157 template<
class _InIterator>
2159 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
2160 input_iterator_tag);
2164 template<
class _FwdIterator>
2166 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
2167 forward_iterator_tag);
2170 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
2209 {
return _M_data(); }
2221 {
return _M_data(); }
2223#if __cplusplus >= 201703L
2243 {
return _M_dataplus; }
2258 find(
const _CharT*
__s, size_type
__pos, size_type __n)
const
2289 __glibcxx_requires_string(
__s);
2290 return this->
find(__s,
__pos, traits_type::length(
__s));
2306#if __cplusplus >= 201703L
2313 template<
typename _Tp>
2351 rfind(
const _CharT*
__s, size_type
__pos, size_type __n)
const
2367 __glibcxx_requires_string(
__s);
2384#if __cplusplus >= 201703L
2391 template<
typename _Tp>
2447 __glibcxx_requires_string(
__s);
2467#if __cplusplus >= 201703L
2475 template<
typename _Tp>
2531 __glibcxx_requires_string(
__s);
2551#if __cplusplus >= 201703L
2559 template<
typename _Tp>
2614 __glibcxx_requires_string(
__s);
2632#if __cplusplus >= 201703L
2640 template<
typename _Tp>
2696 __glibcxx_requires_string(
__s);
2714#if __cplusplus >= 201703L
2722 template<
typename _Tp>
2747 _M_check(
__pos,
"basic_string::substr"), __n); }
2770 int __r = traits_type::compare(_M_data(),
__str.data(),
__len);
2776#if __cplusplus >= 201703L
2782 template<
typename _Tp>
2792 int __r = traits_type::compare(_M_data(),
__sv.data(),
__len);
2806 template<
typename _Tp>
2825 template<
typename _Tp>
2925 compare(size_type
__pos, size_type
__n1,
const _CharT*
__s)
const;
2952 compare(size_type
__pos, size_type
__n1,
const _CharT*
__s,
2953 size_type
__n2)
const;
2955#if __cplusplus > 201703L
2958 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
2961 starts_with(_CharT __x)
const noexcept
2962 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
2965 starts_with(
const _CharT* __x)
const noexcept
2966 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
2969 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
2970 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
2973 ends_with(_CharT __x)
const noexcept
2974 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
2977 ends_with(
const _CharT* __x)
const noexcept
2978 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
2981#if __cplusplus > 202011L
2983 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
2984 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
2987 contains(_CharT __x)
const noexcept
2988 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
2991 contains(
const _CharT* __x)
const noexcept
2992 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
2995# ifdef _GLIBCXX_TM_TS_INTERNAL
2997 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
3000 ::_txnal_cow_string_c_str(
const void *that);
3002 ::_txnal_cow_string_D1(
void *that);
3004 ::_txnal_cow_string_D1_commit(
void *that);
3008 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3009 const typename basic_string<_CharT, _Traits, _Alloc>::size_type
3010 basic_string<_CharT, _Traits, _Alloc>::
3011 _Rep::_S_max_size = (((npos -
sizeof(_Rep_base))/
sizeof(_CharT)) - 1) / 4;
3013 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3015 basic_string<_CharT, _Traits, _Alloc>::
3016 _Rep::_S_terminal = _CharT();
3018 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3019 const typename basic_string<_CharT, _Traits, _Alloc>::size_type
3024 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3025 typename basic_string<_CharT, _Traits, _Alloc>::size_type
3026 basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[
3027 (
sizeof(_Rep_base) +
sizeof(_CharT) +
sizeof(size_type) - 1) /
3034 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3035 template<
typename _InIterator>
3037 basic_string<_CharT, _Traits, _Alloc>::
3038 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
3041#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3042 if (__beg == __end && __a == _Alloc())
3043 return _S_empty_rep()._M_refdata();
3047 size_type __len = 0;
3048 while (__beg != __end && __len <
sizeof(__buf) /
sizeof(_CharT))
3050 __buf[__len++] = *__beg;
3053 _Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
3054 _M_copy(__r->_M_refdata(), __buf, __len);
3057 while (__beg != __end)
3059 if (__len == __r->_M_capacity)
3062 _Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
3063 _M_copy(__another->_M_refdata(), __r->_M_refdata(), __len);
3064 __r->_M_destroy(__a);
3067 __r->_M_refdata()[__len++] = *__beg;
3073 __r->_M_destroy(__a);
3074 __throw_exception_again;
3076 __r->_M_set_length_and_sharable(__len);
3077 return __r->_M_refdata();
3080 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3081 template <
typename _InIterator>
3083 basic_string<_CharT, _Traits, _Alloc>::
3084 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
3085 forward_iterator_tag)
3087#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3088 if (__beg == __end && __a == _Alloc())
3089 return _S_empty_rep()._M_refdata();
3092 if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
3093 __throw_logic_error(__N(
"basic_string::_S_construct null not valid"));
3095 const size_type __dnew =
static_cast<size_type
>(
std::distance(__beg,
3098 _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);
3100 { _S_copy_chars(__r->_M_refdata(), __beg, __end); }
3103 __r->_M_destroy(__a);
3104 __throw_exception_again;
3106 __r->_M_set_length_and_sharable(__dnew);
3107 return __r->_M_refdata();
3110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3112 basic_string<_CharT, _Traits, _Alloc>::
3113 _S_construct(size_type __n, _CharT __c,
const _Alloc& __a)
3115#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3116 if (__n == 0 && __a == _Alloc())
3117 return _S_empty_rep()._M_refdata();
3120 _Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
3122 _M_assign(__r->_M_refdata(), __n, __c);
3124 __r->_M_set_length_and_sharable(__n);
3125 return __r->_M_refdata();
3128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3131 : _M_dataplus(_S_construct(
__str._M_data()
3133 "basic_string::basic_string"),
3138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3141 : _M_dataplus(_S_construct(
__str._M_data()
3143 "basic_string::basic_string"),
3145 +
__pos, _Alloc()), _Alloc())
3148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3151 size_type __n,
const _Alloc& __a)
3152 : _M_dataplus(_S_construct(
__str._M_data()
3154 "basic_string::basic_string"),
3159 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3164 if (_M_rep() !=
__str._M_rep())
3167 const allocator_type __a = this->get_allocator();
3169 _M_rep()->_M_dispose(__a);
3175 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3178 assign(
const _CharT*
__s, size_type __n)
3180 __glibcxx_requires_string_len(
__s, __n);
3181 _M_check_length(this->
size(), __n,
"basic_string::assign");
3182 if (_M_disjunct(
__s) || _M_rep()->_M_is_shared())
3183 return _M_replace_safe(size_type(0), this->
size(), __s, __n);
3187 const size_type
__pos =
__s - _M_data();
3189 _M_copy(_M_data(),
__s, __n);
3191 _M_move(_M_data(),
__s, __n);
3192 _M_rep()->_M_set_length_and_sharable(__n);
3197 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3200 append(size_type __n, _CharT __c)
3204 _M_check_length(size_type(0), __n,
"basic_string::append");
3205 const size_type
__len = __n + this->
size();
3206 if (__len > this->capacity() || _M_rep()->_M_is_shared())
3207 this->reserve(
__len);
3208 _M_assign(_M_data() + this->
size(), __n, __c);
3209 _M_rep()->_M_set_length_and_sharable(
__len);
3214 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3217 append(
const _CharT*
__s, size_type __n)
3219 __glibcxx_requires_string_len(
__s, __n);
3222 _M_check_length(size_type(0), __n,
"basic_string::append");
3223 const size_type
__len = __n + this->
size();
3224 if (__len > this->capacity() || _M_rep()->_M_is_shared())
3226 if (_M_disjunct(
__s))
3227 this->reserve(
__len);
3230 const size_type
__off =
__s - _M_data();
3231 this->reserve(
__len);
3235 _M_copy(_M_data() + this->
size(), __s, __n);
3236 _M_rep()->_M_set_length_and_sharable(
__len);
3241 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3250 if (__len > this->capacity() || _M_rep()->_M_is_shared())
3251 this->reserve(
__len);
3252 _M_copy(_M_data() + this->
size(), __str._M_data(),
__size);
3253 _M_rep()->_M_set_length_and_sharable(
__len);
3258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3263 __str._M_check(
__pos,
"basic_string::append");
3267 const size_type
__len = __n + this->
size();
3268 if (__len > this->capacity() || _M_rep()->_M_is_shared())
3269 this->reserve(
__len);
3270 _M_copy(_M_data() + this->
size(), __str._M_data() +
__pos, __n);
3271 _M_rep()->_M_set_length_and_sharable(
__len);
3276 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3281 __glibcxx_requires_string_len(
__s, __n);
3282 _M_check(
__pos,
"basic_string::insert");
3283 _M_check_length(size_type(0), __n,
"basic_string::insert");
3284 if (_M_disjunct(
__s) || _M_rep()->_M_is_shared())
3285 return _M_replace_safe(
__pos, size_type(0),
__s, __n);
3289 const size_type
__off =
__s - _M_data();
3290 _M_mutate(
__pos, 0, __n);
3292 _CharT* __p = _M_data() +
__pos;
3293 if (
__s + __n <= __p)
3294 _M_copy(__p,
__s, __n);
3295 else if (
__s >= __p)
3296 _M_copy(__p,
__s + __n, __n);
3307 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3308 typename basic_string<_CharT, _Traits, _Alloc>::iterator
3310 erase(iterator __first, iterator __last)
3312 _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
3313 && __last <= _M_iend());
3318 const size_type
__size = __last - __first;
3321 const size_type
__pos = __first - _M_ibegin();
3323 _M_rep()->_M_set_leaked();
3324 return iterator(_M_data() +
__pos);
3330 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3336 __glibcxx_requires_string_len(
__s,
__n2);
3337 _M_check(
__pos,
"basic_string::replace");
3339 _M_check_length(
__n1,
__n2,
"basic_string::replace");
3341 if (_M_disjunct(
__s) || _M_rep()->_M_is_shared())
3361 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3366 const size_type
__size =
sizeof(_Rep_base)
3367 + (this->_M_capacity + 1) *
sizeof(_CharT);
3368 _Raw_bytes_alloc(__a).deallocate(
reinterpret_cast<char*
>(
this),
__size);
3371 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3373 basic_string<_CharT, _Traits, _Alloc>::
3383 if (_M_rep()->_M_is_shared())
3385 _M_rep()->_M_set_leaked();
3388 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3390 basic_string<_CharT, _Traits, _Alloc>::
3391 _M_mutate(size_type __pos, size_type __len1, size_type __len2)
3393 const size_type __old_size = this->
size();
3394 const size_type __new_size = __old_size + __len2 - __len1;
3395 const size_type __how_much = __old_size - __pos - __len1;
3397 if (__new_size > this->capacity() || _M_rep()->_M_is_shared())
3400 const allocator_type __a = get_allocator();
3401 _Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a);
3404 _M_copy(__r->_M_refdata(), _M_data(), __pos);
3406 _M_copy(__r->_M_refdata() + __pos + __len2,
3407 _M_data() + __pos + __len1, __how_much);
3409 _M_rep()->_M_dispose(__a);
3410 _M_data(__r->_M_refdata());
3412 else if (__how_much && __len1 != __len2)
3415 _M_move(_M_data() + __pos + __len2,
3416 _M_data() + __pos + __len1, __how_much);
3418 _M_rep()->_M_set_length_and_sharable(__new_size);
3421 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3434 if (!_M_rep()->_M_is_shared())
3441 const allocator_type __a = get_allocator();
3443 _M_rep()->_M_dispose(__a);
3447 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3453 if (_M_rep()->_M_is_leaked())
3454 _M_rep()->_M_set_sharable();
3455 if (
__s._M_rep()->_M_is_leaked())
3456 __s._M_rep()->_M_set_sharable();
3457 if (this->get_allocator() ==
__s.get_allocator())
3459 _CharT*
__tmp = _M_data();
3460 _M_data(
__s._M_data());
3467 __s.get_allocator());
3469 this->get_allocator());
3475 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3484 __throw_length_error(__N(
"basic_string::_S_create"));
3539 void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
3540 _Rep *__p =
new (__place) _Rep;
3541 __p->_M_capacity = __capacity;
3549 __p->_M_set_sharable();
3553 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3555 basic_string<_CharT, _Traits, _Alloc>::_Rep::
3556 _M_clone(
const _Alloc& __alloc, size_type __res)
3559 const size_type __requested_cap = this->_M_length + __res;
3560 _Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity,
3562 if (this->_M_length)
3563 _M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length);
3565 __r->_M_set_length_and_sharable(this->_M_length);
3566 return __r->_M_refdata();
3569 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3572 resize(size_type __n, _CharT __c)
3575 _M_check_length(
__size, __n,
"basic_string::resize");
3577 this->append(__n -
__size, __c);
3583 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3584 template<
typename _InputIterator>
3592 _M_check_length(
__n1,
__s.size(),
"basic_string::_M_replace_dispatch");
3593 return _M_replace_safe(
__i1 - _M_ibegin(),
__n1,
__s._M_data(),
3597 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3598 basic_string<_CharT, _Traits, _Alloc>&
3599 basic_string<_CharT, _Traits, _Alloc>::
3600 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
3603 _M_check_length(__n1, __n2,
"basic_string::_M_replace_aux");
3604 _M_mutate(__pos1, __n1, __n2);
3606 _M_assign(_M_data() + __pos1, __n2, __c);
3610 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3611 basic_string<_CharT, _Traits, _Alloc>&
3612 basic_string<_CharT, _Traits, _Alloc>::
3613 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
3616 _M_mutate(__pos1, __n1, __n2);
3618 _M_copy(_M_data() + __pos1, __s, __n2);
3622 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3628 if (length() < capacity() || _M_rep()->_M_is_shared())
3631 const allocator_type __a = get_allocator();
3632 _CharT*
__tmp = _M_rep()->_M_clone(__a);
3633 _M_rep()->_M_dispose(__a);
3643 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3644 typename basic_string<_CharT, _Traits, _Alloc>::size_type
3646 copy(_CharT*
__s, size_type __n, size_type
__pos)
const
3648 _M_check(
__pos,
"basic_string::copy");
3649 __n = _M_limit(
__pos, __n);
3650 __glibcxx_requires_string_len(
__s, __n);
3652 _M_copy(
__s, _M_data() +
__pos, __n);
3656_GLIBCXX_END_NAMESPACE_VERSION
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
Uniform interface to all allocator types.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
_If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & append(const basic_string &__str, size_type __pos, size_type __n=npos)
Append a substring.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
iterator erase(iterator __first, iterator __last)
Remove a range of characters.
_If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
_If_sv< _Tp, int > compare(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
_If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
iterator erase(iterator __position)
Remove one character.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & assign(const _CharT *__s, size_type __n)
Set value to a C substring.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string(const basic_string &__str)
Construct string with copy of value of str.
int compare(const basic_string &__str) const
Compare to a string.
_If_sv< _Tp, size_type > find_last_not_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character not in a string_view.
_If_sv< _Tp, basic_string & > replace(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos)
Replace range of characters with string_view.
_If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string(const basic_string &__str, size_type __pos, const _Alloc &__a=_Alloc())
Construct string as copy of a substring.
basic_string(const basic_string &__str, size_type __pos, size_type __n)
Construct string as copy of a substring.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
const_reference front() const noexcept
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string & append(size_type __n, _CharT __c)
Append multiple characters.
basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
reverse_iterator rbegin()
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
basic_string(const basic_string &__str, size_type __pos, size_type __n, const _Alloc &__a)
Construct string as copy of a substring.
basic_string(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2)
Replace characters with value of a C substring.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
_If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
void pop_back()
Remove the last character.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & insert(size_type __pos, const _CharT *__s, size_type __n)
Insert a C substring.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void reserve()
Equivalent to shrink_to_fit().
_If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
_If_sv< _Tp, size_type > find_first_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character of a string_view.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
_If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator+=(_CharT __c)
Append a character.
const_reverse_iterator crend() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt, size_type __pos, size_type __n=npos)
Set value from a range of characters in a string_view.
basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
_If_sv< _Tp, basic_string & > append(const _Tp &__svt, size_type __pos, size_type __n=npos)
Append a range of characters from a string_view.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
bool empty() const noexcept
_If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
_If_sv< _Tp, size_type > find(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a string_view.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
_If_sv< _Tp, int > compare(size_type __pos, size_type __n, const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_iterator cbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string() noexcept
Default constructor creates an empty string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
_If_sv< _Tp, size_type > find_first_not_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character not in a string_view.
_If_sv< _Tp, size_type > rfind(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a string_view.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
basic_string & append(const _CharT *__s, size_type __n)
Append a C substring.
_CharT * data() noexcept
Return non-const pointer to contents.
basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
basic_string & append(const _CharT *__s)
Append a C string.
_If_sv< _Tp, size_type > find_last_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character of string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Thrown as part of forced unwinding.
Uniform interface to C++98 and C++11 allocators.