34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
38#pragma GCC system_header
44#if __cplusplus >= 201103L
50#ifdef __glibcxx_string_view
54#if __glibcxx_containers_ranges
59#if __glibcxx_to_string >= 202306L
63#if ! _GLIBCXX_USE_CXX11_ABI
67namespace std _GLIBCXX_VISIBILITY(default)
69_GLIBCXX_BEGIN_NAMESPACE_VERSION
70_GLIBCXX_BEGIN_NAMESPACE_CXX11
92 template<
typename _CharT,
typename _Traits,
typename _Alloc>
95#if __cplusplus >= 202002L
96 static_assert(is_trivially_copyable_v<_CharT>
97 && is_trivially_default_constructible_v<_CharT>
98 && is_standard_layout_v<_CharT>);
99 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
100 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
101 using _Char_alloc_type = _Alloc;
104 rebind<_CharT>::other _Char_alloc_type;
111 typedef _Traits traits_type;
112 typedef typename _Traits::char_type value_type;
113 typedef _Char_alloc_type allocator_type;
114 typedef typename _Alloc_traits::size_type size_type;
115 typedef typename _Alloc_traits::difference_type difference_type;
116 typedef typename _Alloc_traits::reference reference;
117 typedef typename _Alloc_traits::const_reference const_reference;
118 typedef typename _Alloc_traits::pointer pointer;
119 typedef typename _Alloc_traits::const_pointer const_pointer;
120 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
121 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
127 static const size_type
npos =
static_cast<size_type
>(-1);
131#if __cplusplus < 201103L
132 typedef iterator __const_iterator;
134 typedef const_iterator __const_iterator;
139 static _GLIBCXX20_CONSTEXPR pointer
140 _S_allocate(_Char_alloc_type& __a, size_type __n)
143 struct _Alloc_result { pointer __ptr;
size_type __count; };
145 static _GLIBCXX20_CONSTEXPR _Alloc_result
146 _S_allocate_at_least(_Char_alloc_type& __a, size_type __n)
149#ifdef __glibcxx_allocate_at_least
152 __r.__count = __count;
157#if __glibcxx_constexpr_string >= 201907L
160 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
161 if (std::__is_constant_evaluated())
163 for (size_type __i = 0; __i < __r.__count; ++__i)
164 std::construct_at(__builtin_addressof(__r.__ptr[__i]));
169#ifdef __glibcxx_string_view
171 typedef basic_string_view<_CharT, _Traits> __sv_type;
173 template<
typename _Tp,
typename _Res>
175 __and_<is_convertible<const _Tp&, __sv_type>,
176 __not_<is_convertible<const _Tp*, const basic_string*>>,
177 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
183 _S_to_string_view(__sv_type __svt)
noexcept
192 _GLIBCXX20_CONSTEXPR
explicit
193 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
211 struct _Alloc_hider : allocator_type
213#if __cplusplus < 201103L
214 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
215 : allocator_type(__a), _M_p(__dat) { }
218 _Alloc_hider(pointer __dat,
const _Alloc& __a)
219 : allocator_type(__a), _M_p(__dat) { }
222 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
223 : allocator_type(std::
move(__a)), _M_p(__dat) { }
229 _Alloc_hider _M_dataplus;
230 size_type _M_string_length;
232 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
236 _CharT _M_local_buf[_S_local_capacity + 1];
237 size_type _M_allocated_capacity;
243 { _M_dataplus._M_p = __p; }
247 _M_length(size_type __length)
248 { _M_string_length = __length; }
253 {
return _M_dataplus._M_p; }
259#if __cplusplus >= 201103L
260 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
262 return pointer(_M_local_buf);
268 _M_local_data()
const
270#if __cplusplus >= 201103L
271 return std::pointer_traits<const_pointer>::pointer_to(*_M_local_buf);
273 return const_pointer(_M_local_buf);
279 _M_capacity(size_type __capacity)
280 { _M_allocated_capacity = __capacity; }
284 _M_set_length(size_type __n)
286 traits_type::assign(_M_data()[__n], _CharT());
294 if (_M_data() == _M_local_data())
296 if (_M_string_length > _S_local_capacity)
297 __builtin_unreachable();
306 _M_create_plus(size_type __new_capacity, size_type __old_capacity);
308 __attribute__((__always_inline__))
311 _M_create_and_place(size_type __new_capacity, size_type __old_capacity)
313 _Alloc_result __r = _M_create_plus(__new_capacity, __old_capacity);
315 _M_capacity(__r.__count - 1);
321 _M_create(size_type&, size_type);
328 _M_destroy(_M_allocated_capacity);
333 _M_destroy(size_type __size)
throw()
336#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
339 template<
typename _InIterator>
341 _M_construct_aux(_InIterator __beg, _InIterator __end,
344 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
345 _M_construct(__beg, __end, _Tag());
350 template<
typename _Integer>
352 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
353 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
356 _M_construct_aux_2(size_type __req, _CharT __c)
357 { _M_construct(__req, __c); }
361 template<
typename _InIterator>
364 _M_construct(_InIterator __beg, _InIterator __end,
365 std::input_iterator_tag);
369 template<
typename _FwdIterator>
372 _M_construct(_FwdIterator __beg, _FwdIterator __end,
373 std::forward_iterator_tag);
377 _M_construct(size_type __req, _CharT __c);
381 template<
bool _Terminated>
384 _M_construct(
const _CharT *__c, size_type __n);
386#if __cplusplus >= 202302L
388 _M_construct(
basic_string&& __str, size_type __pos, size_type __n);
394 {
return _M_dataplus; }
397 const allocator_type&
398 _M_get_allocator()
const
399 {
return _M_dataplus; }
402 __attribute__((__always_inline__))
405 _M_init_local_buf() _GLIBCXX_NOEXCEPT
407#if __glibcxx_is_constant_evaluated
408 if (std::is_constant_evaluated())
409 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
410 _M_local_buf[__i] = _CharT();
414 __attribute__((__always_inline__))
417 _M_use_local_data() _GLIBCXX_NOEXCEPT
419#if __cpp_lib_is_constant_evaluated
422 return _M_local_data();
427#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
430 template<
typename _Tp,
bool _Requires =
431 !__are_same<_Tp, _CharT*>::__value
432 && !__are_same<_Tp, const _CharT*>::__value
433 && !__are_same<_Tp, iterator>::__value
434 && !__are_same<_Tp, const_iterator>::__value>
435 struct __enable_if_not_native_iterator
436 {
typedef basic_string& __type; };
437 template<
typename _Tp>
438 struct __enable_if_not_native_iterator<_Tp, false> { };
443 _M_check(size_type __pos,
const char* __s)
const
445 if (__pos > this->
size())
446 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
447 "this->size() (which is %zu)"),
448 __s, (
size_t)__pos, (
size_t)this->
size());
454 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
457 __throw_length_error(__N(__s));
464 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
466 const bool __testoff = __off < this->
size() - __pos;
467 return __testoff ? __off : this->
size() - __pos;
472 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
474 return (less<const _CharT*>()(__s, _M_data())
475 || less<const _CharT*>()(_M_data() + this->
size(), __s));
482 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
485 traits_type::assign(*__d, *__s);
487 traits_type::copy(__d, __s, __n);
492 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
495 traits_type::assign(*__d, *__s);
497 traits_type::move(__d, __s, __n);
502 _S_assign(_CharT* __d, size_type __n, _CharT __c)
505 traits_type::assign(*__d, __c);
507 traits_type::assign(__d, __n, __c);
510#pragma GCC diagnostic push
511#pragma GCC diagnostic ignored "-Wc++17-extensions"
514 template<
class _Iterator>
517 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
519#if __cplusplus >= 201103L
520 using _IterBase =
decltype(std::__niter_base(__k1));
521 if constexpr (__or_<is_same<_IterBase, _CharT*>,
522 is_same<_IterBase, const _CharT*>>::value)
523 _S_copy(__p, std::__niter_base(__k1), __k2 - __k1);
524#if __cpp_lib_concepts
525 else if constexpr (
requires {
526 requires contiguous_iterator<_Iterator>;
528 -> convertible_to<const _CharT*>;
531 const auto __d = __k2 - __k1;
538 for (; __k1 != __k2; ++__k1, (void)++__p)
539 traits_type::assign(*__p,
static_cast<_CharT
>(*__k1));
541#pragma GCC diagnostic pop
543#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
545 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
546 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
549 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
550 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
553 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
554 { _S_copy(__p, __k1, __k2 - __k1); }
557 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
558 { _S_copy(__p, __k1, __k2 - __k1); }
561#if __glibcxx_containers_ranges
563 template<
typename _Rg>
564 static constexpr void
565 _S_copy_range(pointer __p, _Rg&& __rg, size_type __n)
567 if constexpr (
requires {
568 requires ranges::contiguous_range<_Rg>;
570 -> convertible_to<const _CharT*>;
575 auto __first = ranges::begin(__rg);
576 const auto __last = ranges::end(__rg);
577 for (; __first != __last; ++__first)
578 traits_type::assign(*__p++,
static_cast<_CharT
>(*__first));
585 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
587 const difference_type __d = difference_type(__n1 - __n2);
589 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
590 return __gnu_cxx::__numeric_traits<int>::__max;
591 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
592 return __gnu_cxx::__numeric_traits<int>::__min;
603 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
608 _M_erase(size_type __pos, size_type __n);
621#if __cpp_concepts && __glibcxx_type_trait_variable_templates
622 requires is_default_constructible_v<_Alloc>
624 : _M_dataplus(_M_local_data())
636 : _M_dataplus(_M_local_data(), __a)
648 : _M_dataplus(_M_local_data(),
649 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
651 _M_construct<true>(__str._M_data(), __str.
length());
664 const _Alloc& __a = _Alloc())
665 : _M_dataplus(_M_local_data(), __a)
667 const _CharT* __start = __str._M_data()
668 + __str._M_check(__pos,
"basic_string::basic_string");
669 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
682 : _M_dataplus(_M_local_data())
684 const _CharT* __start = __str._M_data()
685 + __str._M_check(__pos,
"basic_string::basic_string");
686 _M_construct(__start, __start + __str._M_limit(__pos, __n),
699 size_type __n,
const _Alloc& __a)
700 : _M_dataplus(_M_local_data(), __a)
702 const _CharT* __start
703 = __str._M_data() + __str._M_check(__pos,
"string::string");
704 _M_construct(__start, __start + __str._M_limit(__pos, __n),
708#if __cplusplus >= 202302L
711 const _Alloc& __a = _Alloc())
712 : _M_dataplus(_M_local_data(), __a)
714 __pos = __str._M_check(__pos,
"string::string");
720 const _Alloc& __a = _Alloc())
721 : _M_dataplus(_M_local_data(), __a)
723 __pos = __str._M_check(__pos,
"string::string");
724 _M_construct(
std::move(__str), __pos, __str._M_limit(__pos, __n));
739 const _Alloc& __a = _Alloc())
740 : _M_dataplus(_M_local_data(), __a)
743 if (__s == 0 && __n > 0)
744 std::__throw_logic_error(__N(
"basic_string: "
745 "construction from null is not valid"));
754#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
757 template<
typename = _RequireAllocator<_Alloc>>
761 : _M_dataplus(_M_local_data(), __a)
765 std::__throw_logic_error(__N(
"basic_string: "
766 "construction from null is not valid"));
767 const _CharT* __end = __s + traits_type::length(__s);
777#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
780 template<
typename = _RequireAllocator<_Alloc>>
784 : _M_dataplus(_M_local_data(), __a)
785 { _M_construct(__n, __c); }
787#if __cplusplus >= 201103L
797 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
799 if (__str._M_is_local())
802 traits_type::copy(_M_local_buf, __str._M_local_buf,
807 _M_data(__str._M_data());
808 _M_capacity(__str._M_allocated_capacity);
814 _M_length(__str.
length());
815 __str._M_data(__str._M_use_local_data());
816 __str._M_set_length(0);
819#if __glibcxx_containers_ranges
824 template<__detail::__container_compatible_range<_CharT> _Rg>
826 basic_string(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
831 const auto __n =
static_cast<size_type>(ranges::distance(__rg));
838 auto __first = ranges::begin(__rg);
839 const auto __last = ranges::end(__rg);
840 for (; __first != __last; ++__first)
853 : _M_dataplus(_M_local_data(), __a)
858 : _M_dataplus(_M_local_data(), __a)
863 noexcept(_Alloc_traits::_S_always_equal())
864 : _M_dataplus(_M_local_data(), __a)
866 if (__str._M_is_local())
869 traits_type::copy(_M_local_buf, __str._M_local_buf,
871 _M_length(__str.length());
872 __str._M_set_length(0);
874 else if (_Alloc_traits::_S_always_equal()
877 _M_data(__str._M_data());
878 _M_length(__str.length());
879 _M_capacity(__str._M_allocated_capacity);
880 __str._M_data(__str._M_use_local_data());
881 __str._M_set_length(0);
888#if __cplusplus >= 202100L
899#if __cplusplus >= 201103L
900 template<
typename _InputIterator,
901 typename = std::_RequireInputIter<_InputIterator>>
903 template<
typename _InputIterator>
907 const _Alloc& __a = _Alloc())
908 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
910#if __cplusplus >= 201103L
911 _M_construct(__beg, __end, std::__iterator_category(__beg));
913 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
914 _M_construct_aux(__beg, __end, _Integral());
918#ifdef __glibcxx_string_view
926 template<
typename _Tp,
930 const _Alloc& __a = _Alloc())
938 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
941 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
942 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
960 return this->
assign(__str);
970 {
return this->
assign(__s); }
987#if __cplusplus >= 201103L
1000 noexcept(_Alloc_traits::_S_nothrow_move())
1002 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
1003 || _M_get_allocator() == __str._M_get_allocator();
1004 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
1008 _M_destroy(_M_allocated_capacity);
1009 _M_data(_M_local_data());
1013 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
1015 if (__str._M_is_local())
1023 this->_S_copy(_M_data(), __str._M_data(), __str.
size());
1024 _M_set_length(__str.
size());
1027 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
1030 pointer __data =
nullptr;
1031 size_type __capacity;
1038 __capacity = _M_allocated_capacity;
1041 _M_destroy(_M_allocated_capacity);
1044 _M_data(__str._M_data());
1045 _M_length(__str.
length());
1046 _M_capacity(__str._M_allocated_capacity);
1049 __str._M_data(__data);
1050 __str._M_capacity(__capacity);
1053 __str._M_data(__str._M_use_local_data());
1065 _GLIBCXX20_CONSTEXPR
1069 this->
assign(__l.begin(), __l.size());
1074#ifdef __glibcxx_string_view
1079 template<
typename _Tp>
1080 _GLIBCXX20_CONSTEXPR
1081 _If_sv<_Tp, basic_string&>
1082 operator=(
const _Tp& __svt)
1083 {
return this->
assign(__svt); }
1089 _GLIBCXX20_CONSTEXPR
1090 operator __sv_type() const noexcept
1091 {
return __sv_type(
data(),
size()); }
1099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1102 {
return iterator(_M_data()); }
1108 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1111 {
return const_iterator(_M_data()); }
1117 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1120 {
return iterator(_M_data() + this->
size()); }
1126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1129 {
return const_iterator(_M_data() + this->
size()); }
1136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1139 {
return reverse_iterator(this->
end()); }
1146 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1147 const_reverse_iterator
1149 {
return const_reverse_iterator(this->
end()); }
1156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1159 {
return reverse_iterator(this->
begin()); }
1166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1167 const_reverse_iterator
1169 {
return const_reverse_iterator(this->
begin()); }
1171#if __cplusplus >= 201103L
1176 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1179 {
return const_iterator(this->_M_data()); }
1185 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1188 {
return const_iterator(this->_M_data() + this->
size()); }
1195 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1196 const_reverse_iterator
1198 {
return const_reverse_iterator(this->
end()); }
1205 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1206 const_reverse_iterator
1208 {
return const_reverse_iterator(this->
begin()); }
1215 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1219 size_type __sz = _M_string_length;
1221 __builtin_unreachable();
1227 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1233 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1237 const size_t __diffmax
1238 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1240 return (
std::min)(__diffmax, __allocmax) - 1;
1253 _GLIBCXX20_CONSTEXPR
1267 _GLIBCXX20_CONSTEXPR
1270 { this->
resize(__n, _CharT()); }
1272#if __cplusplus >= 201103L
1273#pragma GCC diagnostic push
1274#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1276 _GLIBCXX20_CONSTEXPR
1280#pragma GCC diagnostic pop
1283#ifdef __glibcxx_string_resize_and_overwrite
1313 template<
typename _Operation>
1315 resize_and_overwrite(
size_type __n, _Operation __op);
1318#if __cplusplus >= 201103L
1320 template<
typename _Operation>
1321 _GLIBCXX20_CONSTEXPR
void
1329 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1333 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1334 : _M_allocated_capacity;
1335 if (__sz < _S_local_capacity || __sz >
max_size ())
1336 __builtin_unreachable();
1357 _GLIBCXX20_CONSTEXPR
1364#if __cplusplus >= 202002L
1365 [[deprecated(
"use shrink_to_fit() instead")]]
1367 _GLIBCXX20_CONSTEXPR
1374 _GLIBCXX20_CONSTEXPR
1377 { _M_set_length(0); }
1383 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1386 {
return _M_string_length == 0; }
1399 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1403 __glibcxx_assert(__pos <=
size());
1404 return _M_data()[__pos];
1417 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1423 __glibcxx_assert(__pos <=
size());
1425 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1426 return _M_data()[__pos];
1439 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1443 if (__n >= this->
size())
1444 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1445 "(which is %zu) >= this->size() "
1448 return _M_data()[__n];
1461 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1466 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1467 "(which is %zu) >= this->size() "
1470 return _M_data()[__n];
1473#if __cplusplus >= 201103L
1478 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1482 __glibcxx_assert(!
empty());
1490 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1494 __glibcxx_assert(!
empty());
1502 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1506 __glibcxx_assert(!
empty());
1514 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1518 __glibcxx_assert(!
empty());
1529 _GLIBCXX20_CONSTEXPR
1532 {
return this->
append(__str); }
1539 _GLIBCXX20_CONSTEXPR
1542 {
return this->
append(__s); }
1549 _GLIBCXX20_CONSTEXPR
1557#if __cplusplus >= 201103L
1563 _GLIBCXX20_CONSTEXPR
1566 {
return this->
append(__l.begin(), __l.size()); }
1569#ifdef __glibcxx_string_view
1575 template<
typename _Tp>
1576 _GLIBCXX20_CONSTEXPR
1577 _If_sv<_Tp, basic_string&>
1579 {
return this->
append(__svt); }
1587 _GLIBCXX20_CONSTEXPR
1590 {
return this->
append(__str._M_data(), __str.
size()); }
1605 _GLIBCXX20_CONSTEXPR
1608 {
return this->
append(__str._M_data()
1609 + __str._M_check(__pos,
"basic_string::append"),
1610 __str._M_limit(__pos, __n)); }
1618 _GLIBCXX20_CONSTEXPR
1622 __glibcxx_requires_string_len(__s, __n);
1623 _M_check_length(size_type(0), __n,
"basic_string::append");
1624 return _M_append(__s, __n);
1632 _GLIBCXX20_CONSTEXPR
1636 __glibcxx_requires_string(__s);
1637 const size_type __n = traits_type::length(__s);
1638 _M_check_length(size_type(0), __n,
"basic_string::append");
1639 return _M_append(__s, __n);
1650 _GLIBCXX20_CONSTEXPR
1653 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1655#if __glibcxx_containers_ranges
1663 template<__detail::__container_compatible_range<_CharT> _Rg>
1665 append_range(_Rg&& __rg)
1672 const auto __len =
size_type(ranges::distance(__rg));
1682 _M_check_length(0, __len,
"basic_string::append_range");
1684 __s.reserve(__newlen);
1687 _S_copy(__s._M_data(), _M_data(),
size());
1689 _M_destroy(_M_allocated_capacity);
1690 _M_data(__s._M_data());
1691 _M_capacity(__s._M_allocated_capacity);
1692 __s._M_data(__s._M_local_data());
1695 _M_set_length(__newlen);
1700 _M_get_allocator());
1707#if __cplusplus >= 201103L
1713 _GLIBCXX20_CONSTEXPR
1716 {
return this->
append(__l.begin(), __l.size()); }
1727#if __cplusplus >= 201103L
1728 template<
class _InputIterator,
1729 typename = std::_RequireInputIter<_InputIterator>>
1730 _GLIBCXX20_CONSTEXPR
1732 template<
class _InputIterator>
1735 append(_InputIterator __first, _InputIterator __last)
1738#ifdef __glibcxx_string_view
1744 template<
typename _Tp>
1745 _GLIBCXX20_CONSTEXPR
1746 _If_sv<_Tp, basic_string&>
1749 __sv_type __sv = __svt;
1750 return this->
append(__sv.data(), __sv.size());
1760 template<
typename _Tp>
1761 _GLIBCXX20_CONSTEXPR
1762 _If_sv<_Tp, basic_string&>
1763 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1765 __sv_type __sv = __svt;
1766 return _M_append(__sv.data()
1767 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1768 std::__sv_limit(__sv.size(), __pos, __n));
1780 _GLIBCXX20_CONSTEXPR
1782 append(
const _CharT* __s, size_type __pos, size_type __n)
1790 _GLIBCXX20_CONSTEXPR
1794 const size_type __size = this->
size();
1796 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1797 traits_type::assign(this->_M_data()[__size], __c);
1798 this->_M_set_length(__size + 1);
1806 _GLIBCXX20_CONSTEXPR
1810#if __cplusplus >= 201103L
1811 if (_Alloc_traits::_S_propagate_on_copy_assign())
1813 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1814 && _M_get_allocator() != __str._M_get_allocator())
1818 if (__str.
size() <= _S_local_capacity)
1820 _M_destroy(_M_allocated_capacity);
1821 _M_data(_M_use_local_data());
1826 const auto __len = __str.
size();
1827 auto __alloc = __str._M_get_allocator();
1829 auto __r = _S_allocate_at_least(__alloc, __len + 1);
1830 _M_destroy(_M_allocated_capacity);
1832 _M_capacity(__r.__count - 1);
1833 _M_set_length(__len);
1836 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1839 this->_M_assign(__str);
1843#if __cplusplus >= 201103L
1852 _GLIBCXX20_CONSTEXPR
1855 noexcept(_Alloc_traits::_S_nothrow_move())
1876 _GLIBCXX20_CONSTEXPR
1879 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1880 + __str._M_check(__pos,
"basic_string::assign"),
1881 __str._M_limit(__pos, __n)); }
1893 _GLIBCXX20_CONSTEXPR
1897 __glibcxx_requires_string_len(__s, __n);
1898 return _M_replace(size_type(0), this->
size(), __s, __n);
1910 _GLIBCXX20_CONSTEXPR
1914 __glibcxx_requires_string(__s);
1915 return _M_replace(size_type(0), this->
size(), __s,
1916 traits_type::length(__s));
1928 _GLIBCXX20_CONSTEXPR
1931 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1941#if __cplusplus >= 201103L
1942#pragma GCC diagnostic push
1943#pragma GCC diagnostic ignored "-Wc++17-extensions"
1944 template<
class _InputIterator,
1945 typename = std::_RequireInputIter<_InputIterator>>
1946 _GLIBCXX20_CONSTEXPR
1948 assign(_InputIterator __first, _InputIterator __last)
1951 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1952 &&
is_same<
typename _IterTraits::value_type,
1955 __glibcxx_requires_valid_range(__first, __last);
1956 return _M_replace(size_type(0),
size(),
1957 std::__niter_base(__first), __last - __first);
1959#if __cplusplus >= 202002L
1960 else if constexpr (contiguous_iterator<_InputIterator>
1961 && is_same_v<iter_value_t<_InputIterator>,
1964 __glibcxx_requires_valid_range(__first, __last);
1965 return _M_replace(size_type(0),
size(),
1972#pragma GCC diagnostic pop
1974 template<
class _InputIterator>
1976 assign(_InputIterator __first, _InputIterator __last)
1980#if __glibcxx_containers_ranges
1988 template<__detail::__container_compatible_range<_CharT> _Rg>
1990 assign_range(_Rg&& __rg)
1993 _M_get_allocator());
1999#if __cplusplus >= 201103L
2005 _GLIBCXX20_CONSTEXPR
2011 const size_type __n = __l.size();
2017 _S_copy(_M_data(), __l.begin(), __n);
2024#ifdef __glibcxx_string_view
2030 template<
typename _Tp>
2031 _GLIBCXX20_CONSTEXPR
2032 _If_sv<_Tp, basic_string&>
2035 __sv_type __sv = __svt;
2036 return this->
assign(__sv.data(), __sv.size());
2046 template<
typename _Tp>
2047 _GLIBCXX20_CONSTEXPR
2048 _If_sv<_Tp, basic_string&>
2049 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
2051 __sv_type __sv = __svt;
2052 return _M_replace(size_type(0), this->
size(),
2054 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
2055 std::__sv_limit(__sv.size(), __pos, __n));
2067 _GLIBCXX20_CONSTEXPR
2069 assign(
const _CharT* __s, size_type __pos, size_type __n)
2073#if __cplusplus >= 201103L
2089 _GLIBCXX20_CONSTEXPR
2091 insert(const_iterator __p, size_type __n, _CharT __c)
2093 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2094 const size_type __pos = __p -
begin();
2095 this->
replace(__p, __p, __n, __c);
2096 return iterator(this->_M_data() + __pos);
2114 { this->
replace(__p, __p, __n, __c); }
2117#if __cplusplus >= 201103L
2132 template<
class _InputIterator,
2133 typename = std::_RequireInputIter<_InputIterator>>
2134 _GLIBCXX20_CONSTEXPR
2136 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
2138 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2139 const size_type __pos = __p -
begin();
2140 this->
replace(__p, __p, __beg, __end);
2141 return iterator(this->_M_data() + __pos);
2156 template<
class _InputIterator>
2159 { this->
replace(__p, __p, __beg, __end); }
2162#if __glibcxx_containers_ranges
2170 template<__detail::__container_compatible_range<_CharT> _Rg>
2172 insert_range(const_iterator __p, _Rg&& __rg)
2174 auto __pos = __p -
cbegin();
2176 if constexpr (ranges::forward_range<_Rg>)
2177 if (ranges::empty(__rg))
2178 return begin() + __pos;
2186 _M_get_allocator());
2189 return begin() + __pos;
2193#if __cplusplus >= 201103L
2200 _GLIBCXX20_CONSTEXPR
2203 {
return this->
insert(__p, __l.begin(), __l.end()); }
2205#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
2210 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2211 this->
insert(__p -
begin(), __l.begin(), __l.size());
2228 _GLIBCXX20_CONSTEXPR
2231 {
return this->
replace(__pos1, size_type(0),
2232 __str._M_data(), __str.
size()); }
2252 _GLIBCXX20_CONSTEXPR
2255 size_type __pos2, size_type __n =
npos)
2256 {
return this->
replace(__pos1, size_type(0), __str._M_data()
2257 + __str._M_check(__pos2,
"basic_string::insert"),
2258 __str._M_limit(__pos2, __n)); }
2276 _GLIBCXX20_CONSTEXPR
2278 insert(size_type __pos,
const _CharT* __s, size_type __n)
2279 {
return this->
replace(__pos, size_type(0), __s, __n); }
2296 _GLIBCXX20_CONSTEXPR
2300 __glibcxx_requires_string(__s);
2301 return this->
replace(__pos, size_type(0), __s,
2302 traits_type::length(__s));
2321 _GLIBCXX20_CONSTEXPR
2323 insert(size_type __pos, size_type __n, _CharT __c)
2324 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2325 size_type(0), __n, __c); }
2340 _GLIBCXX20_CONSTEXPR
2344 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2345 const size_type __pos = __p -
begin();
2346 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2347 return iterator(_M_data() + __pos);
2350#ifdef __glibcxx_string_view
2357 template<
typename _Tp>
2358 _GLIBCXX20_CONSTEXPR
2359 _If_sv<_Tp, basic_string&>
2362 __sv_type __sv = __svt;
2363 return this->
insert(__pos, __sv.data(), __sv.size());
2374 template<
typename _Tp>
2375 _GLIBCXX20_CONSTEXPR
2376 _If_sv<_Tp, basic_string&>
2377 insert(size_type __pos1,
const _Tp& __svt,
2378 size_type __pos2, size_type __n =
npos)
2380 __sv_type __sv = __svt;
2381 return this->
replace(__pos1, size_type(0),
2383 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2384 std::__sv_limit(__sv.size(), __pos2, __n));
2403 _GLIBCXX20_CONSTEXPR
2407 _M_check(__pos,
"basic_string::erase");
2409 this->_M_set_length(__pos);
2411 this->_M_erase(__pos, _M_limit(__pos, __n));
2423 _GLIBCXX20_CONSTEXPR
2427 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2428 && __position <
end());
2429 const size_type __pos = __position -
begin();
2430 this->_M_erase(__pos, size_type(1));
2431 return iterator(_M_data() + __pos);
2443 _GLIBCXX20_CONSTEXPR
2445 erase(__const_iterator __first, __const_iterator __last)
2447 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2448 && __last <=
end());
2449 const size_type __pos = __first -
begin();
2450 if (__last ==
end())
2451 this->_M_set_length(__pos);
2453 this->_M_erase(__pos, __last - __first);
2454 return iterator(this->_M_data() + __pos);
2457#if __cplusplus >= 201103L
2463 _GLIBCXX20_CONSTEXPR
2467 __glibcxx_assert(!
empty());
2468 _M_erase(
size() - 1, 1);
2489 _GLIBCXX20_CONSTEXPR
2492 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
2512 _GLIBCXX20_CONSTEXPR
2515 size_type __pos2, size_type __n2 =
npos)
2516 {
return this->
replace(__pos1, __n1, __str._M_data()
2517 + __str._M_check(__pos2,
"basic_string::replace"),
2518 __str._M_limit(__pos2, __n2)); }
2538 _GLIBCXX20_CONSTEXPR
2540 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2543 __glibcxx_requires_string_len(__s, __n2);
2544 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2545 _M_limit(__pos, __n1), __s, __n2);
2564 _GLIBCXX20_CONSTEXPR
2566 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2568 __glibcxx_requires_string(__s);
2569 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2589 _GLIBCXX20_CONSTEXPR
2591 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2592 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2593 _M_limit(__pos, __n1), __n2, __c); }
2608 _GLIBCXX20_CONSTEXPR
2610 replace(__const_iterator __i1, __const_iterator __i2,
2612 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
2629 _GLIBCXX20_CONSTEXPR
2631 replace(__const_iterator __i1, __const_iterator __i2,
2632 const _CharT* __s, size_type __n)
2634 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2636 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2652 _GLIBCXX20_CONSTEXPR
2654 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2656 __glibcxx_requires_string(__s);
2657 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2674 _GLIBCXX20_CONSTEXPR
2676 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2679 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2681 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2699#if __cplusplus >= 201103L
2700 template<
class _InputIterator,
2701 typename = std::_RequireInputIter<_InputIterator>>
2702 _GLIBCXX20_CONSTEXPR
2705 _InputIterator __k1, _InputIterator __k2)
2707 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2709 __glibcxx_requires_valid_range(__k1, __k2);
2710 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2711 std::__false_type());
2714 template<
class _InputIterator>
2715#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2716 typename __enable_if_not_native_iterator<_InputIterator>::__type
2721 _InputIterator __k1, _InputIterator __k2)
2723 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2725 __glibcxx_requires_valid_range(__k1, __k2);
2726 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2727 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2733 _GLIBCXX20_CONSTEXPR
2735 replace(__const_iterator __i1, __const_iterator __i2,
2736 _CharT* __k1, _CharT* __k2)
2738 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2740 __glibcxx_requires_valid_range(__k1, __k2);
2745 _GLIBCXX20_CONSTEXPR
2747 replace(__const_iterator __i1, __const_iterator __i2,
2748 const _CharT* __k1,
const _CharT* __k2)
2750 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2752 __glibcxx_requires_valid_range(__k1, __k2);
2757 _GLIBCXX20_CONSTEXPR
2759 replace(__const_iterator __i1, __const_iterator __i2,
2760 iterator __k1, iterator __k2)
2762 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2764 __glibcxx_requires_valid_range(__k1, __k2);
2766 __k1.base(), __k2 - __k1);
2769 _GLIBCXX20_CONSTEXPR
2771 replace(__const_iterator __i1, __const_iterator __i2,
2772 const_iterator __k1, const_iterator __k2)
2774 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2776 __glibcxx_requires_valid_range(__k1, __k2);
2778 __k1.base(), __k2 - __k1);
2781#if __glibcxx_containers_ranges
2789 template<__detail::__container_compatible_range<_CharT> _Rg>
2791 replace_with_range(const_iterator __i1, const_iterator __i2, _Rg&& __rg)
2798 _M_get_allocator());
2805#if __cplusplus >= 201103L
2820 _GLIBCXX20_CONSTEXPR
2823 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2826#ifdef __glibcxx_string_view
2834 template<
typename _Tp>
2835 _GLIBCXX20_CONSTEXPR
2836 _If_sv<_Tp, basic_string&>
2839 __sv_type __sv = __svt;
2840 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2852 template<
typename _Tp>
2853 _GLIBCXX20_CONSTEXPR
2854 _If_sv<_Tp, basic_string&>
2855 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2856 size_type __pos2, size_type __n2 =
npos)
2858 __sv_type __sv = __svt;
2859 return this->
replace(__pos1, __n1,
2861 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2862 std::__sv_limit(__sv.size(), __pos2, __n2));
2874 template<
typename _Tp>
2875 _GLIBCXX20_CONSTEXPR
2876 _If_sv<_Tp, basic_string&>
2877 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2879 __sv_type __sv = __svt;
2880 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2885 template<
class _Integer>
2886 _GLIBCXX20_CONSTEXPR
2888 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2889 _Integer __n, _Integer __val, __true_type)
2890 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2892 template<
class _InputIterator>
2893 _GLIBCXX20_CONSTEXPR
2895 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2896 _InputIterator __k1, _InputIterator __k2,
2899 _GLIBCXX20_CONSTEXPR
2901 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2904 __attribute__((__noinline__, __noclone__, __cold__))
void
2905 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2906 const size_type __len2,
const size_type __how_much);
2908 _GLIBCXX20_CONSTEXPR
2910 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2911 const size_type __len2);
2913 _GLIBCXX20_CONSTEXPR
2915 _M_append(
const _CharT* __s, size_type __n);
2931 _GLIBCXX20_CONSTEXPR
2933 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2942 _GLIBCXX20_CONSTEXPR
2953 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2956 {
return _M_data(); }
2966 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2969 {
return _M_data(); }
2971#if __cplusplus >= 201703L
2978 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2981 {
return _M_data(); }
2987 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2990 {
return _M_get_allocator(); }
3004 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3006 find(
const _CharT* __s, size_type __pos, size_type __n)
const
3019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3023 {
return this->
find(__str.
data(), __pos, __str.
size()); }
3025#ifdef __glibcxx_string_view
3032 template<
typename _Tp>
3033 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3034 _If_sv<_Tp, size_type>
3036 noexcept(
is_same<_Tp, __sv_type>::value)
3038 __sv_type __sv = __svt;
3039 return this->
find(__sv.data(), __pos, __sv.size());
3053 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3055 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
3057 __glibcxx_requires_string(__s);
3058 return this->
find(__s, __pos, traits_type::length(__s));
3071 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3073 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
3085 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3089 {
return this->
rfind(__str.data(), __pos, __str.size()); }
3091#ifdef __glibcxx_string_view
3098 template<
typename _Tp>
3099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3100 _If_sv<_Tp, size_type>
3104 __sv_type __sv = __svt;
3105 return this->
rfind(__sv.data(), __pos, __sv.size());
3121 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3123 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
3136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3140 __glibcxx_requires_string(__s);
3141 return this->
rfind(__s, __pos, traits_type::length(__s));
3154 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3156 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
3169 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3175#ifdef __glibcxx_string_view
3183 template<
typename _Tp>
3184 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3185 _If_sv<_Tp, size_type>
3187 noexcept(
is_same<_Tp, __sv_type>::value)
3189 __sv_type __sv = __svt;
3190 return this->
find_first_of(__sv.data(), __pos, __sv.size());
3206 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3221 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3226 __glibcxx_requires_string(__s);
3227 return this->
find_first_of(__s, __pos, traits_type::length(__s));
3242 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3245 {
return this->
find(__c, __pos); }
3258 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3264#ifdef __glibcxx_string_view
3272 template<
typename _Tp>
3273 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3274 _If_sv<_Tp, size_type>
3278 __sv_type __sv = __svt;
3279 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3295 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3310 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3315 __glibcxx_requires_string(__s);
3316 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3331 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3334 {
return this->
rfind(__c, __pos); }
3346 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3352#ifdef __glibcxx_string_view
3360 template<
typename _Tp>
3361 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3362 _If_sv<_Tp, size_type>
3364 noexcept(
is_same<_Tp, __sv_type>::value)
3366 __sv_type __sv = __svt;
3383 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3386 size_type __n)
const _GLIBCXX_NOEXCEPT;
3398 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3403 __glibcxx_requires_string(__s);
3417 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3433 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3439#ifdef __glibcxx_string_view
3447 template<
typename _Tp>
3448 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3449 _If_sv<_Tp, size_type>
3453 __sv_type __sv = __svt;
3470 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3473 size_type __n)
const _GLIBCXX_NOEXCEPT;
3485 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3490 __glibcxx_requires_string(__s);
3504 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3521 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3525 _M_check(__pos,
"basic_string::substr"), __n); }
3527#if __cplusplus >= 202302L
3535 substr(size_type __pos, size_type __n) &&
3539#ifdef __glibcxx_string_subview
3553 constexpr basic_string_view<_CharT, _Traits>
3555 {
return __sv_type(*this).subview(__pos, __n); }
3572 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3576 const size_type __size = this->
size();
3577 const size_type __osize = __str.
size();
3578 const size_type __len =
std::min(__size, __osize);
3580 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
3582 __r = _S_compare(__size, __osize);
3586#ifdef __glibcxx_string_view
3592 template<
typename _Tp>
3593 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3595 compare(
const _Tp& __svt)
const
3598 __sv_type __sv = __svt;
3600 const size_type __osize = __sv.size();
3603 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3605 __r = _S_compare(__size, __osize);
3617 template<
typename _Tp>
3618 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3620 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3622 __sv_type __sv = __svt;
3623 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3636 template<
typename _Tp>
3637 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3639 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3640 size_type __pos2, size_type __n2 =
npos)
const
3642 __sv_type __sv = __svt;
3643 return __sv_type(*
this)
3644 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3667 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3671 _M_check(__pos,
"basic_string::compare");
3672 __n = _M_limit(__pos, __n);
3673 const size_type __osize = __str.
size();
3674 const size_type __len =
std::min(__n, __osize);
3675 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
3677 __r = _S_compare(__n, __osize);
3704 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3707 size_type __pos2, size_type __n2 =
npos)
const
3709 _M_check(__pos1,
"basic_string::compare");
3710 __str._M_check(__pos2,
"basic_string::compare");
3711 __n1 = _M_limit(__pos1, __n1);
3712 __n2 = __str._M_limit(__pos2, __n2);
3713 const size_type __len =
std::min(__n1, __n2);
3714 int __r = traits_type::compare(_M_data() + __pos1,
3715 __str.
data() + __pos2, __len);
3717 __r = _S_compare(__n1, __n2);
3735 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3737 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3739 __glibcxx_requires_string(__s);
3740 const size_type __size = this->
size();
3741 const size_type __osize = traits_type::length(__s);
3742 const size_type __len =
std::min(__size, __osize);
3743 int __r = traits_type::compare(_M_data(), __s, __len);
3745 __r = _S_compare(__size, __osize);
3770 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3772 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3774 __glibcxx_requires_string(__s);
3775 _M_check(__pos,
"basic_string::compare");
3776 __n1 = _M_limit(__pos, __n1);
3777 const size_type __osize = traits_type::length(__s);
3778 const size_type __len =
std::min(__n1, __osize);
3779 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3781 __r = _S_compare(__n1, __osize);
3809 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3811 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3812 size_type __n2)
const
3814 __glibcxx_requires_string_len(__s, __n2);
3815 _M_check(__pos,
"basic_string::compare");
3816 __n1 = _M_limit(__pos, __n1);
3817 const size_type __len =
std::min(__n1, __n2);
3818 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3820 __r = _S_compare(__n1, __n2);
3824#if __cplusplus >= 202002L
3828 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3832 starts_with(_CharT __x)
const noexcept
3833 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3835 [[nodiscard, __gnu__::__nonnull__]]
3837 starts_with(
const _CharT* __x)
const noexcept
3838 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3842 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3843 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3847 ends_with(_CharT __x)
const noexcept
3848 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3850 [[nodiscard, __gnu__::__nonnull__]]
3852 ends_with(
const _CharT* __x)
const noexcept
3853 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3856#if __cplusplus > 202002L
3859 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3860 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3864 contains(_CharT __x)
const noexcept
3865 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3867 [[nodiscard, __gnu__::__nonnull__]]
3869 contains(
const _CharT* __x)
const noexcept
3870 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3874 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3876_GLIBCXX_END_NAMESPACE_CXX11
3877_GLIBCXX_END_NAMESPACE_VERSION
3881namespace std _GLIBCXX_VISIBILITY(default)
3883_GLIBCXX_BEGIN_NAMESPACE_VERSION
3885#if __cpp_deduction_guides >= 201606
3886_GLIBCXX_BEGIN_NAMESPACE_CXX11
3887 template<
typename _InputIterator,
typename _CharT
3890 typename = _RequireInputIter<_InputIterator>,
3891 typename = _RequireAllocator<_Allocator>>
3892 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3897 template<
typename _CharT,
typename _Traits,
3899 typename = _RequireAllocator<_Allocator>>
3903 template<
typename _CharT,
typename _Traits,
3905 typename = _RequireAllocator<_Allocator>>
3907 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3908 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3909 const _Allocator& = _Allocator())
3912#if __glibcxx_containers_ranges
3915 basic_string(from_range_t, _Rg&&, _Allocator = _Allocator())
3920_GLIBCXX_END_NAMESPACE_CXX11
3923 template<
typename _Str>
3924 _GLIBCXX20_CONSTEXPR
3926 __str_concat(
typename _Str::value_type
const* __lhs,
3927 typename _Str::size_type __lhs_len,
3928 typename _Str::value_type
const* __rhs,
3929 typename _Str::size_type __rhs_len,
3930 typename _Str::allocator_type
const& __a)
3932 typedef typename _Str::allocator_type allocator_type;
3933 typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
3934 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3935 __str.
reserve(__lhs_len + __rhs_len);
3936 __str.
append(__lhs, __lhs_len);
3937 __str.
append(__rhs, __rhs_len);
3948 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3949 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3955 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3966 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3967 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3968 inline basic_string<_CharT,_Traits,_Alloc>
3972 __glibcxx_requires_string(__lhs);
3974 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3985 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3986 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3987 inline basic_string<_CharT,_Traits,_Alloc>
3991 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
4002 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4003 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4004 inline basic_string<_CharT, _Traits, _Alloc>
4006 const _CharT* __rhs)
4008 __glibcxx_requires_string(__rhs);
4010 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
4011 __rhs, _Traits::length(__rhs),
4020 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4021 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4022 inline basic_string<_CharT, _Traits, _Alloc>
4026 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
4027 __builtin_addressof(__rhs), 1,
4031#if __cplusplus >= 201103L
4032 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4033 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4034 inline basic_string<_CharT, _Traits, _Alloc>
4035 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4036 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4037 {
return std::move(__lhs.append(__rhs)); }
4039 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4040 _GLIBCXX20_CONSTEXPR
4044 {
return std::move(__rhs.insert(0, __lhs)); }
4046 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4047 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4052#pragma GCC diagnostic push
4053#pragma GCC diagnostic ignored "-Wc++17-extensions"
4056 bool __use_rhs =
false;
4059 else if (__lhs.get_allocator() == __rhs.get_allocator())
4063 const auto __size = __lhs.size() + __rhs.size();
4064 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
4065 return std::move(__rhs.insert(0, __lhs));
4068#pragma GCC diagnostic pop
4071 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4072 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4076 {
return std::move(__rhs.insert(0, __lhs)); }
4078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4079 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4083 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4085 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4086 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4089 const _CharT* __rhs)
4090 {
return std::move(__lhs.append(__rhs)); }
4092 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4093 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4097 {
return std::move(__lhs.append(1, __rhs)); }
4100#if __glibcxx_string_view >= 202403L
4102 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4109 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4110 __rhs.data(), __rhs.size(),
4111 __lhs.get_allocator());
4115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4125 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4132 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4133 __rhs.data(), __rhs.size(),
4134 __rhs.get_allocator());
4138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4144 return std::move(__rhs.insert(0, __lhs));
4155 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4162 return __lhs.size() == __rhs.size()
4163 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
4172 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4173 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4176 const _CharT* __rhs)
4178 return __lhs.
size() == _Traits::length(__rhs)
4179 && !_Traits::compare(__lhs.
data(), __rhs, __lhs.
size());
4182#if __cpp_lib_three_way_comparison
4190 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4195 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4196 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4205 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4209 const _CharT* __rhs)
noexcept
4210 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4211 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4219 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4222 operator==(
const _CharT* __lhs,
4223 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4224 {
return __rhs == __lhs; }
4233 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4239 {
return !(__lhs == __rhs); }
4247 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4250 operator!=(
const _CharT* __lhs,
4252 {
return !(__rhs == __lhs); }
4260 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4264 const _CharT* __rhs)
4265 {
return !(__lhs == __rhs); }
4274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4280 {
return __lhs.compare(__rhs) < 0; }
4288 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4292 const _CharT* __rhs)
4293 {
return __lhs.compare(__rhs) < 0; }
4301 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4304 operator<(
const _CharT* __lhs,
4306 {
return __rhs.compare(__lhs) > 0; }
4315 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4321 {
return __lhs.compare(__rhs) > 0; }
4329 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4333 const _CharT* __rhs)
4334 {
return __lhs.compare(__rhs) > 0; }
4342 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4345 operator>(
const _CharT* __lhs,
4347 {
return __rhs.compare(__lhs) < 0; }
4356 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4362 {
return __lhs.compare(__rhs) <= 0; }
4370 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4374 const _CharT* __rhs)
4375 {
return __lhs.compare(__rhs) <= 0; }
4383 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4386 operator<=(
const _CharT* __lhs,
4388 {
return __rhs.compare(__lhs) >= 0; }
4397 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4403 {
return __lhs.compare(__rhs) >= 0; }
4411 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4415 const _CharT* __rhs)
4416 {
return __lhs.compare(__rhs) >= 0; }
4424 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4427 operator>=(
const _CharT* __lhs,
4429 {
return __rhs.compare(__lhs) <= 0; }
4439 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4440 _GLIBCXX20_CONSTEXPR
4444 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4445 { __lhs.swap(__rhs); }
4460 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4461 basic_istream<_CharT, _Traits>&
4462 operator>>(basic_istream<_CharT, _Traits>& __is,
4463 basic_string<_CharT, _Traits, _Alloc>& __str);
4466 basic_istream<char>&
4478 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4485 return __ostream_insert(__os, __str.
data(), __str.
size());
4501 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4502 basic_istream<_CharT, _Traits>&
4503 getline(basic_istream<_CharT, _Traits>& __is,
4504 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4518 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4519 inline basic_istream<_CharT, _Traits>&
4524#if __cplusplus >= 201103L
4526 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4527 inline basic_istream<_CharT, _Traits>&
4533 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4534 inline basic_istream<_CharT, _Traits>&
4541 basic_istream<char>&
4542 getline(basic_istream<char>& __in, basic_string<char>& __str,
4545#ifdef _GLIBCXX_USE_WCHAR_T
4547 basic_istream<wchar_t>&
4548 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4552_GLIBCXX_END_NAMESPACE_VERSION
4555#if __cplusplus >= 201103L
4560namespace std _GLIBCXX_VISIBILITY(default)
4562_GLIBCXX_BEGIN_NAMESPACE_VERSION
4563_GLIBCXX_BEGIN_NAMESPACE_CXX11
4567 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4568 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4572 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4573 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4576 inline unsigned long
4577 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4578 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4581#if _GLIBCXX_USE_C99_STDLIB
4583 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4584 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4587 inline unsigned long long
4588 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4589 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4591#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4593 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4594 {
return std::stol(__str, __idx, __base); }
4596 inline unsigned long long
4597 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4598 {
return std::stoul(__str, __idx, __base); }
4602 stod(
const string& __str,
size_t* __idx = 0)
4603 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4605#if _GLIBCXX_HAVE_STRTOF
4608 stof(
const string& __str,
size_t* __idx = 0)
4609 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4612 stof(
const string& __str,
size_t* __idx = 0)
4614 double __d = std::stod(__str, __idx);
4615 if (__builtin_isfinite(__d) && __d != 0.0)
4617 double __abs_d = __builtin_fabs(__d);
4618 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4621 std::__throw_out_of_range(
"stof");
4628#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4630 stold(
const string& __str,
size_t* __idx = 0)
4631 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4632#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4634 stold(
const string& __str,
size_t* __idx = 0)
4635 {
return std::stod(__str, __idx); }
4638#if __glibcxx_constexpr_string >= 202511L
4639# define _GLIBCXX_TO_STRING_CONSTEXPR constexpr
4641# define _GLIBCXX_TO_STRING_CONSTEXPR inline
4648 _GLIBCXX_TO_STRING_CONSTEXPR
string
4649 to_string(
int __val)
4650#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4654 const bool __neg = __val < 0;
4655 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4656 const auto __len = __detail::__to_chars_len(__uval);
4658 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4660 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4667 _GLIBCXX_TO_STRING_CONSTEXPR
string
4668 to_string(
unsigned __val)
4669#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4673 const auto __len = __detail::__to_chars_len(__val);
4675 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4676 __detail::__to_chars_10_impl(__p, __n, __val);
4683 _GLIBCXX_TO_STRING_CONSTEXPR
string
4684 to_string(
long __val)
4685#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4689 const bool __neg = __val < 0;
4690 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4691 const auto __len = __detail::__to_chars_len(__uval);
4693 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4695 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4702 _GLIBCXX_TO_STRING_CONSTEXPR
string
4703 to_string(
unsigned long __val)
4704#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4708 const auto __len = __detail::__to_chars_len(__val);
4710 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4711 __detail::__to_chars_10_impl(__p, __n, __val);
4718 _GLIBCXX_TO_STRING_CONSTEXPR
string
4719 to_string(
long long __val)
4721 const bool __neg = __val < 0;
4722 const unsigned long long __uval
4723 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4724 const auto __len = __detail::__to_chars_len(__uval);
4726 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4728 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4735 _GLIBCXX_TO_STRING_CONSTEXPR
string
4736 to_string(
unsigned long long __val)
4738 const auto __len = __detail::__to_chars_len(__val);
4740 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4741 __detail::__to_chars_10_impl(__p, __n, __val);
4747#if __glibcxx_to_string >= 202306L
4751 to_string(
float __val)
4756 __str.resize_and_overwrite(__len,
4757 [__val, &__len] (
char* __p,
size_t __n) {
4758 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4759 if (__err == errc{}) [[likely]]
4764 }
while (__str.empty());
4770 to_string(
double __val)
4775 __str.resize_and_overwrite(__len,
4776 [__val, &__len] (
char* __p,
size_t __n) {
4777 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4778 if (__err == errc{}) [[likely]]
4783 }
while (__str.empty());
4789 to_string(
long double __val)
4794 __str.resize_and_overwrite(__len,
4795 [__val, &__len] (
char* __p,
size_t __n) {
4796 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4797 if (__err == errc{}) [[likely]]
4802 }
while (__str.empty());
4805#elif _GLIBCXX_USE_C99_STDIO
4806#pragma GCC diagnostic push
4807#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4812 to_string(
float __val)
4815 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4816 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4822 to_string(
double __val)
4825 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4826 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4832 to_string(
long double __val)
4835 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4836 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4839#pragma GCC diagnostic pop
4842#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4844 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4845 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4849 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4850 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4853 inline unsigned long
4854 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4855 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4859 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4860 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4863 inline unsigned long long
4864 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4865 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4870 stof(
const wstring& __str,
size_t* __idx = 0)
4871 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4874 stod(
const wstring& __str,
size_t* __idx = 0)
4875 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4878 stold(
const wstring& __str,
size_t* __idx = 0)
4879 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4882#ifdef _GLIBCXX_USE_WCHAR_T
4883#pragma GCC diagnostic push
4884#pragma GCC diagnostic ignored "-Wc++17-extensions"
4885 _GLIBCXX20_CONSTEXPR
4887 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4891 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4892 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4894 for (
int __i = 0; __i < __len; ++__i)
4895 __wout[__i] = (
wchar_t) __s[__i];
4900 for (
int __i =
'0'; __i <=
'9'; ++__i)
4901 __wc[__i] = L
'0' + __i;
4926 for (
int __i = 0; __i < __len; ++__i)
4927 __wout[__i] = __wc[(
int)__s[__i]];
4931#if __glibcxx_constexpr_string >= 201907L
4935#ifdef __glibcxx_string_view
4936 __to_wstring_numeric(string_view __s)
4938 __to_wstring_numeric(
const string& __s)
4941 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4942 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4943 return wstring(__s.data(), __s.data() + __s.size());
4947 auto __f = __s.data();
4948 __ws.__resize_and_overwrite(__s.size(),
4949 [__f] (
wchar_t* __to,
int __n) {
4950 std::__to_wstring_numeric(__f, __n, __to);
4956#pragma GCC diagnostic pop
4959 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4960 to_wstring(
int __val)
4961 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4964 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4965 to_wstring(
unsigned __val)
4966 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4969 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4970 to_wstring(
long __val)
4971 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4974 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4975 to_wstring(
unsigned long __val)
4976 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4979 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4980 to_wstring(
long long __val)
4981 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4984 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4985 to_wstring(
unsigned long long __val)
4986 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4988#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4991 to_wstring(
float __val)
4992 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4996 to_wstring(
double __val)
4997 {
return std::__to_wstring_numeric(std::to_string(__val)); }
5001 to_wstring(
long double __val)
5002 {
return std::__to_wstring_numeric(std::to_string(__val)); }
5005#undef _GLIBCXX_TO_STRING_CONSTEXPR
5007_GLIBCXX_END_NAMESPACE_CXX11
5008_GLIBCXX_END_NAMESPACE_VERSION
5013#if __cplusplus >= 201103L
5017namespace std _GLIBCXX_VISIBILITY(default)
5019_GLIBCXX_BEGIN_NAMESPACE_VERSION
5024 template<
typename _CharT,
typename _Alloc,
5026 struct __str_hash_base
5027 :
public __hash_base<size_t, _StrT>
5031 operator()(
const _StrT& __s)
const noexcept
5032 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
5035#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5037 template<
typename _Alloc>
5039 :
public __str_hash_base<char, _Alloc>
5043 template<
typename _Alloc>
5045 :
public __str_hash_base<wchar_t, _Alloc>
5048 template<
typename _Alloc>
5055#ifdef _GLIBCXX_USE_CHAR8_T
5057 template<
typename _Alloc>
5058 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
5059 :
public __str_hash_base<char8_t, _Alloc>
5064 template<
typename _Alloc>
5066 :
public __str_hash_base<char16_t, _Alloc>
5070 template<
typename _Alloc>
5072 :
public __str_hash_base<char32_t, _Alloc>
5075#if ! _GLIBCXX_INLINE_VERSION
5081#ifdef _GLIBCXX_USE_CHAR8_T
5086 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5092#ifdef __glibcxx_string_udls
5095 inline namespace string_literals
5097#pragma GCC diagnostic push
5098#pragma GCC diagnostic ignored "-Wliteral-suffix"
5100#if __glibcxx_constexpr_string >= 201907L
5101# define _GLIBCXX_STRING_CONSTEXPR constexpr
5103# define _GLIBCXX_STRING_CONSTEXPR
5106 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5107 inline basic_string<char>
5108 operator""s(
const char* __str,
size_t __len)
5109 {
return basic_string<char>{__str, __len}; }
5111 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5112 inline basic_string<wchar_t>
5113 operator""s(
const wchar_t* __str,
size_t __len)
5114 {
return basic_string<wchar_t>{__str, __len}; }
5116#ifdef _GLIBCXX_USE_CHAR8_T
5117 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5118 inline basic_string<char8_t>
5119 operator""s(
const char8_t* __str,
size_t __len)
5120 {
return basic_string<char8_t>{__str, __len}; }
5123 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5124 inline basic_string<char16_t>
5125 operator""s(
const char16_t* __str,
size_t __len)
5126 {
return basic_string<char16_t>{__str, __len}; }
5128 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5129 inline basic_string<char32_t>
5130 operator""s(
const char32_t* __str,
size_t __len)
5131 {
return basic_string<char32_t>{__str, __len}; }
5133#undef _GLIBCXX_STRING_CONSTEXPR
5134#pragma GCC diagnostic pop
5139#ifdef __glibcxx_variant
5140 namespace __detail::__variant
5142 template<
typename>
struct _Never_valueless_alt;
5146 template<
typename _Tp,
typename _Traits,
typename _Alloc>
5147 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
5149 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
5150 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
5156_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string< char > string
A string of char.
basic_string< char32_t > u32string
A string of char32_t.
basic_string< char16_t > u16string
A string of char16_t.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
ISO C++ inline namespace for literal suffixes.
Template class basic_istream.
A non-owning reference to a string.
Primary class template hash.
is_nothrow_default_constructible
static constexpr allocation_result< pointer, size_type > allocate_at_least(_Char_alloc_type &__a, size_type __n)
The standard allocator, as per C++03 [20.4.1].
char_type widen(char __c) const
Widens characters.
Managing sequences of characters and character-like objects.
constexpr const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
constexpr basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
constexpr basic_string(const _Alloc &__a) noexcept
Construct an empty string using allocator a.
constexpr size_type find_first_not_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a different character.
constexpr basic_string & append(const basic_string &__str, size_type __pos, size_type __n=npos)
Append a substring.
constexpr basic_string() noexcept(/*conditional */)
Default constructor creates an empty string.
constexpr reference at(size_type __n)
Provides access to the data contained in the string.
constexpr basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
constexpr size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const basic_string &__str)
Replace range of characters with string.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
constexpr const_iterator begin() const noexcept
constexpr void clear() noexcept
constexpr size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
constexpr basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
constexpr const_reverse_iterator rend() const noexcept
constexpr void reserve(size_type __res_arg)
Attempt to preallocate enough memory for specified number of characters.
constexpr size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
constexpr basic_string & assign(const _CharT *__s, size_type __n)
Set value to a C substring.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
constexpr const _CharT * data() const noexcept
Return const pointer to contents.
constexpr void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
constexpr size_type find_first_not_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a character not in C substring.
constexpr basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
constexpr size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
constexpr int compare(size_type __pos, size_type __n, const basic_string &__str) const
Compare substring to a string.
constexpr int compare(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos) const
Compare substring to a substring.
constexpr size_type rfind(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
constexpr reference back() noexcept
constexpr size_type find_first_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a character of C substring.
constexpr basic_string(const basic_string &__str, size_type __pos, const _Alloc &__a=_Alloc())
Construct string as copy of a substring.
constexpr basic_string(const basic_string &__str, size_type __pos, size_type __n)
Construct string as copy of a substring.
constexpr basic_string & replace(const_iterator __i1, const_iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
constexpr basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
constexpr size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
constexpr size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
constexpr basic_string & operator+=(const _CharT *__s)
Append a C string.
constexpr basic_string & assign(const basic_string &__str)
Set value to contents of another string.
constexpr basic_string(const basic_string &__str)
Construct string with copy of value of __str.
constexpr basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
constexpr basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
constexpr basic_string & append(size_type __n, _CharT __c)
Append multiple characters.
constexpr size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr const_reverse_iterator crbegin() const noexcept
constexpr basic_string(const basic_string &__str, size_type __pos, size_type __n, const _Alloc &__a)
Construct string as copy of a substring.
constexpr size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
constexpr basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2)
Replace characters with value of a C substring.
constexpr basic_string & assign(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Set value to contents of another string.
constexpr basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
constexpr basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
constexpr const_reverse_iterator rbegin() const noexcept
constexpr size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
constexpr const_iterator end() const noexcept
constexpr basic_string & insert(size_type __pos, const _CharT *__s, size_type __n)
Insert a C substring.
constexpr 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.
constexpr const_iterator cbegin() const noexcept
constexpr size_type rfind(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a C substring.
constexpr iterator erase(__const_iterator __first, __const_iterator __last)
Remove a range of characters.
constexpr size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
constexpr const_reference at(size_type __n) const
Provides access to the data contained in the string.
constexpr reference operator[](size_type __pos)
Subscript access to the data contained in the string.
constexpr basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
constexpr reverse_iterator rend() noexcept
constexpr void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
constexpr iterator insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
constexpr size_type find_last_not_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a different character.
constexpr basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
constexpr iterator insert(__const_iterator __p, _CharT __c)
Insert one character.
constexpr ~basic_string()
Destroy the string instance.
constexpr basic_string & operator=(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Move assign the value of str to this string.
constexpr void __resize_and_overwrite(size_type __n, _Operation __op)
Non-standard version of resize_and_overwrite for C++11 and above.
constexpr size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
constexpr basic_string & append(const basic_string &__str)
Append a string to this string.
constexpr basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
constexpr const_reference back() const noexcept
constexpr basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
constexpr size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
constexpr reference front() noexcept
constexpr iterator end() noexcept
constexpr basic_string & append(const _CharT *__s)
Append a C string.
constexpr iterator begin() noexcept
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
constexpr size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const _CharT *__s)
Replace range of characters with C string.
constexpr basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
constexpr void push_back(_CharT __c)
Append a single character.
constexpr reverse_iterator rbegin() noexcept
constexpr basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
constexpr void resize(size_type __n)
Resizes the string to the specified number of characters.
constexpr size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
constexpr basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
constexpr basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
constexpr basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
constexpr iterator insert(const_iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
constexpr size_type find_last_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a character of C substring.
constexpr size_type capacity() const noexcept
constexpr basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
constexpr bool empty() const noexcept
constexpr 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.
constexpr int compare(const _CharT *__s) const noexcept
Compare to a C string.
static const size_type npos
constexpr basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
constexpr size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr basic_string & replace(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
constexpr iterator erase(__const_iterator __position)
Remove one character.
constexpr allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
constexpr size_type find(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
constexpr basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
constexpr const_reverse_iterator crend() const noexcept
constexpr basic_string & operator+=(_CharT __c)
Append a character.
constexpr basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
constexpr const_reference front() const noexcept
constexpr basic_string_view< _CharT, _Traits > subview(size_type __pos=0, size_type __n=npos) const
Get a subview.
constexpr int compare(const basic_string &__str) const
Compare to a string.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2) const
Compare substring against a character array.
constexpr size_type find_last_not_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a character not in C substring.
constexpr basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
constexpr _CharT * data() noexcept
Return non-const pointer to contents.
constexpr basic_string & append(const _CharT *__s, size_type __n)
Append a C substring.
constexpr size_type max_size() const noexcept
Returns the size() of the largest possible string.
constexpr void swap(basic_string &__s) noexcept
Swap contents with another string.
constexpr basic_string(basic_string &&__str) noexcept
Move construct string.
constexpr const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
constexpr void pop_back() noexcept
Remove the last character.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s) const
Compare substring to a C string.
constexpr basic_string & operator+=(const basic_string &__str)
Append a string to this string.
constexpr iterator insert(const_iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
constexpr const_iterator cend() const noexcept
constexpr basic_string & operator=(_CharT __c)
Set value to string of length 1.
constexpr size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
Basis for explicit traits specializations.
Template class basic_ostream.
Traits class for iterators.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Char_alloc_type &__a, size_type __n)
static constexpr void deallocate(_Char_alloc_type &__a, pointer __p, size_type __n)
static constexpr size_type max_size(const _Char_alloc_type &__a) noexcept
[range.sized] The sized_range concept.
A range for which ranges::begin returns an input iterator.
A range for which ranges::begin returns a forward iterator.