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())
830 if constexpr (
requires {
831 requires is_same_v<ranges::iterator_t<_Rg>, _SbufIter>;
832 requires is_same_v<ranges::sentinel_t<_Rg>, _SbufIter> ||
835 _M_construct(ranges::begin(__rg), _SbufIter(),
836 input_iterator_tag{});
838 else if constexpr (ranges::forward_range<_Rg>
839 || ranges::sized_range<_Rg>)
841 const auto __n =
static_cast<size_type
>(ranges::distance(__rg));
848 auto __first = ranges::begin(__rg);
849 const auto __last = ranges::end(__rg);
850 for (; __first != __last; ++__first)
863 : _M_dataplus(_M_local_data(), __a)
868 : _M_dataplus(_M_local_data(), __a)
873 noexcept(_Alloc_traits::_S_always_equal())
874 : _M_dataplus(_M_local_data(), __a)
876 if (__str._M_is_local())
879 traits_type::copy(_M_local_buf, __str._M_local_buf,
881 _M_length(__str.length());
882 __str._M_set_length(0);
884 else if (_Alloc_traits::_S_always_equal()
887 _M_data(__str._M_data());
888 _M_length(__str.length());
889 _M_capacity(__str._M_allocated_capacity);
890 __str._M_data(__str._M_use_local_data());
891 __str._M_set_length(0);
898#if __cplusplus >= 202100L
909#if __cplusplus >= 201103L
910 template<
typename _InputIterator,
911 typename = std::_RequireInputIter<_InputIterator>>
913 template<
typename _InputIterator>
917 const _Alloc& __a = _Alloc())
918 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
920#if __cplusplus >= 201103L
921 _M_construct(__beg, __end, std::__iterator_category(__beg));
923 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
924 _M_construct_aux(__beg, __end, _Integral());
928#ifdef __glibcxx_string_view
936 template<
typename _Tp,
940 const _Alloc& __a = _Alloc())
948 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
951 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
952 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
970 return this->
assign(__str);
980 {
return this->
assign(__s); }
997#if __cplusplus >= 201103L
1007 _GLIBCXX20_CONSTEXPR
1010 noexcept(_Alloc_traits::_S_nothrow_move())
1012 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
1013 || _M_get_allocator() == __str._M_get_allocator();
1014 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
1018 _M_destroy(_M_allocated_capacity);
1019 _M_data(_M_local_data());
1023 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
1025 if (__str._M_is_local())
1033 this->_S_copy(_M_data(), __str._M_data(), __str.
size());
1034 _M_set_length(__str.
size());
1037 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
1040 pointer __data =
nullptr;
1041 size_type __capacity;
1048 __capacity = _M_allocated_capacity;
1051 _M_destroy(_M_allocated_capacity);
1054 _M_data(__str._M_data());
1055 _M_length(__str.
length());
1056 _M_capacity(__str._M_allocated_capacity);
1059 __str._M_data(__data);
1060 __str._M_capacity(__capacity);
1063 __str._M_data(__str._M_use_local_data());
1075 _GLIBCXX20_CONSTEXPR
1079 this->
assign(__l.begin(), __l.size());
1084#ifdef __glibcxx_string_view
1089 template<
typename _Tp>
1090 _GLIBCXX20_CONSTEXPR
1091 _If_sv<_Tp, basic_string&>
1092 operator=(
const _Tp& __svt)
1093 {
return this->
assign(__svt); }
1099 _GLIBCXX20_CONSTEXPR
1100 operator __sv_type() const noexcept
1101 {
return __sv_type(
data(),
size()); }
1109 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1112 {
return iterator(_M_data()); }
1118 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1121 {
return const_iterator(_M_data()); }
1127 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1130 {
return iterator(_M_data() + this->
size()); }
1136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1139 {
return const_iterator(_M_data() + this->
size()); }
1146 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1149 {
return reverse_iterator(this->
end()); }
1156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1157 const_reverse_iterator
1159 {
return const_reverse_iterator(this->
end()); }
1166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1169 {
return reverse_iterator(this->
begin()); }
1176 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1177 const_reverse_iterator
1179 {
return const_reverse_iterator(this->
begin()); }
1181#if __cplusplus >= 201103L
1186 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1189 {
return const_iterator(this->_M_data()); }
1195 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1198 {
return const_iterator(this->_M_data() + this->
size()); }
1205 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1206 const_reverse_iterator
1208 {
return const_reverse_iterator(this->
end()); }
1215 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1216 const_reverse_iterator
1218 {
return const_reverse_iterator(this->
begin()); }
1225 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1229 size_type __sz = _M_string_length;
1231 __builtin_unreachable();
1237 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1243 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1247 const size_t __diffmax
1248 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1250 return (
std::min)(__diffmax, __allocmax) - 1;
1263 _GLIBCXX20_CONSTEXPR
1277 _GLIBCXX20_CONSTEXPR
1280 { this->
resize(__n, _CharT()); }
1282#if __cplusplus >= 201103L
1283#pragma GCC diagnostic push
1284#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1286 _GLIBCXX20_CONSTEXPR
1290#pragma GCC diagnostic pop
1293#ifdef __glibcxx_string_resize_and_overwrite
1323 template<
typename _Operation>
1325 resize_and_overwrite(
size_type __n, _Operation __op);
1328#if __cplusplus >= 201103L
1330 template<
typename _Operation>
1331 _GLIBCXX20_CONSTEXPR
void
1339 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1343 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1344 : _M_allocated_capacity;
1345 if (__sz < _S_local_capacity || __sz >
max_size ())
1346 __builtin_unreachable();
1367 _GLIBCXX20_CONSTEXPR
1374#if __cplusplus >= 202002L
1375 [[deprecated(
"use shrink_to_fit() instead")]]
1377 _GLIBCXX20_CONSTEXPR
1384 _GLIBCXX20_CONSTEXPR
1387 { _M_set_length(0); }
1393 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1396 {
return _M_string_length == 0; }
1409 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1413 __glibcxx_assert(__pos <=
size());
1414 return _M_data()[__pos];
1427 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1433 __glibcxx_assert(__pos <=
size());
1435 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1436 return _M_data()[__pos];
1449 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1453 if (__n >= this->
size())
1454 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1455 "(which is %zu) >= this->size() "
1458 return _M_data()[__n];
1471 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1476 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1477 "(which is %zu) >= this->size() "
1480 return _M_data()[__n];
1483#if __cplusplus >= 201103L
1488 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1492 __glibcxx_assert(!
empty());
1500 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1504 __glibcxx_assert(!
empty());
1512 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1516 __glibcxx_assert(!
empty());
1524 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1528 __glibcxx_assert(!
empty());
1539 _GLIBCXX20_CONSTEXPR
1542 {
return this->
append(__str); }
1549 _GLIBCXX20_CONSTEXPR
1552 {
return this->
append(__s); }
1559 _GLIBCXX20_CONSTEXPR
1567#if __cplusplus >= 201103L
1573 _GLIBCXX20_CONSTEXPR
1576 {
return this->
append(__l.begin(), __l.size()); }
1579#ifdef __glibcxx_string_view
1585 template<
typename _Tp>
1586 _GLIBCXX20_CONSTEXPR
1587 _If_sv<_Tp, basic_string&>
1589 {
return this->
append(__svt); }
1597 _GLIBCXX20_CONSTEXPR
1600 {
return this->
append(__str._M_data(), __str.
size()); }
1615 _GLIBCXX20_CONSTEXPR
1618 {
return this->
append(__str._M_data()
1619 + __str._M_check(__pos,
"basic_string::append"),
1620 __str._M_limit(__pos, __n)); }
1628 _GLIBCXX20_CONSTEXPR
1632 __glibcxx_requires_string_len(__s, __n);
1633 _M_check_length(size_type(0), __n,
"basic_string::append");
1634 return _M_append(__s, __n);
1642 _GLIBCXX20_CONSTEXPR
1646 __glibcxx_requires_string(__s);
1647 const size_type __n = traits_type::length(__s);
1648 _M_check_length(size_type(0), __n,
"basic_string::append");
1649 return _M_append(__s, __n);
1660 _GLIBCXX20_CONSTEXPR
1663 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1665#if __glibcxx_containers_ranges
1673 template<__detail::__container_compatible_range<_CharT> _Rg>
1675 append_range(_Rg&& __rg)
1682 const auto __len =
size_type(ranges::distance(__rg));
1692 _M_check_length(0, __len,
"basic_string::append_range");
1694 __s.reserve(__newlen);
1697 _S_copy(__s._M_data(), _M_data(),
size());
1699 _M_destroy(_M_allocated_capacity);
1700 _M_data(__s._M_data());
1701 _M_capacity(__s._M_allocated_capacity);
1702 __s._M_data(__s._M_local_data());
1705 _M_set_length(__newlen);
1710 _M_get_allocator());
1717#if __cplusplus >= 201103L
1723 _GLIBCXX20_CONSTEXPR
1726 {
return this->
append(__l.begin(), __l.size()); }
1737#if __cplusplus >= 201103L
1738 template<
class _InputIterator,
1739 typename = std::_RequireInputIter<_InputIterator>>
1740 _GLIBCXX20_CONSTEXPR
1742 template<
class _InputIterator>
1745 append(_InputIterator __first, _InputIterator __last)
1748#ifdef __glibcxx_string_view
1754 template<
typename _Tp>
1755 _GLIBCXX20_CONSTEXPR
1756 _If_sv<_Tp, basic_string&>
1759 __sv_type __sv = __svt;
1760 return this->
append(__sv.data(), __sv.size());
1770 template<
typename _Tp>
1771 _GLIBCXX20_CONSTEXPR
1772 _If_sv<_Tp, basic_string&>
1773 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1775 __sv_type __sv = __svt;
1776 return _M_append(__sv.data()
1777 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1778 std::__sv_limit(__sv.size(), __pos, __n));
1790 _GLIBCXX20_CONSTEXPR
1792 append(
const _CharT* __s, size_type __pos, size_type __n)
1800 _GLIBCXX20_CONSTEXPR
1804 const size_type __size = this->
size();
1806 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1807 traits_type::assign(this->_M_data()[__size], __c);
1808 this->_M_set_length(__size + 1);
1816 _GLIBCXX20_CONSTEXPR
1820#if __cplusplus >= 201103L
1821 if (_Alloc_traits::_S_propagate_on_copy_assign())
1823 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1824 && _M_get_allocator() != __str._M_get_allocator())
1828 if (__str.
size() <= _S_local_capacity)
1830 _M_destroy(_M_allocated_capacity);
1831 _M_data(_M_use_local_data());
1836 const auto __len = __str.
size();
1837 auto __alloc = __str._M_get_allocator();
1839 auto __r = _S_allocate_at_least(__alloc, __len + 1);
1840 _M_destroy(_M_allocated_capacity);
1842 _M_capacity(__r.__count - 1);
1843 _M_set_length(__len);
1846 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1849 this->_M_assign(__str);
1853#if __cplusplus >= 201103L
1862 _GLIBCXX20_CONSTEXPR
1865 noexcept(_Alloc_traits::_S_nothrow_move())
1886 _GLIBCXX20_CONSTEXPR
1889 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1890 + __str._M_check(__pos,
"basic_string::assign"),
1891 __str._M_limit(__pos, __n)); }
1903 _GLIBCXX20_CONSTEXPR
1907 __glibcxx_requires_string_len(__s, __n);
1908 return _M_replace(size_type(0), this->
size(), __s, __n);
1920 _GLIBCXX20_CONSTEXPR
1924 __glibcxx_requires_string(__s);
1925 return _M_replace(size_type(0), this->
size(), __s,
1926 traits_type::length(__s));
1938 _GLIBCXX20_CONSTEXPR
1941 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1951#if __cplusplus >= 201103L
1952#pragma GCC diagnostic push
1953#pragma GCC diagnostic ignored "-Wc++17-extensions"
1954 template<
class _InputIterator,
1955 typename = std::_RequireInputIter<_InputIterator>>
1956 _GLIBCXX20_CONSTEXPR
1958 assign(_InputIterator __first, _InputIterator __last)
1961 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1962 &&
is_same<
typename _IterTraits::value_type,
1965 __glibcxx_requires_valid_range(__first, __last);
1966 return _M_replace(size_type(0),
size(),
1967 std::__niter_base(__first), __last - __first);
1969#if __cplusplus >= 202002L
1970 else if constexpr (contiguous_iterator<_InputIterator>
1971 && is_same_v<iter_value_t<_InputIterator>,
1974 __glibcxx_requires_valid_range(__first, __last);
1975 return _M_replace(size_type(0),
size(),
1982#pragma GCC diagnostic pop
1984 template<
class _InputIterator>
1986 assign(_InputIterator __first, _InputIterator __last)
1990#if __glibcxx_containers_ranges
1998 template<__detail::__container_compatible_range<_CharT> _Rg>
2000 assign_range(_Rg&& __rg)
2003 _M_get_allocator());
2009#if __cplusplus >= 201103L
2015 _GLIBCXX20_CONSTEXPR
2021 const size_type __n = __l.size();
2027 _S_copy(_M_data(), __l.begin(), __n);
2034#ifdef __glibcxx_string_view
2040 template<
typename _Tp>
2041 _GLIBCXX20_CONSTEXPR
2042 _If_sv<_Tp, basic_string&>
2045 __sv_type __sv = __svt;
2046 return this->
assign(__sv.data(), __sv.size());
2056 template<
typename _Tp>
2057 _GLIBCXX20_CONSTEXPR
2058 _If_sv<_Tp, basic_string&>
2059 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
2061 __sv_type __sv = __svt;
2062 return _M_replace(size_type(0), this->
size(),
2064 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
2065 std::__sv_limit(__sv.size(), __pos, __n));
2077 _GLIBCXX20_CONSTEXPR
2079 assign(
const _CharT* __s, size_type __pos, size_type __n)
2083#if __cplusplus >= 201103L
2099 _GLIBCXX20_CONSTEXPR
2101 insert(const_iterator __p, size_type __n, _CharT __c)
2103 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2104 const size_type __pos = __p -
begin();
2105 this->
replace(__p, __p, __n, __c);
2106 return iterator(this->_M_data() + __pos);
2124 { this->
replace(__p, __p, __n, __c); }
2127#if __cplusplus >= 201103L
2142 template<
class _InputIterator,
2143 typename = std::_RequireInputIter<_InputIterator>>
2144 _GLIBCXX20_CONSTEXPR
2146 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
2148 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2149 const size_type __pos = __p -
begin();
2150 this->
replace(__p, __p, __beg, __end);
2151 return iterator(this->_M_data() + __pos);
2166 template<
class _InputIterator>
2169 { this->
replace(__p, __p, __beg, __end); }
2172#if __glibcxx_containers_ranges
2180 template<__detail::__container_compatible_range<_CharT> _Rg>
2182 insert_range(const_iterator __p, _Rg&& __rg)
2184 auto __pos = __p -
cbegin();
2186 if constexpr (ranges::forward_range<_Rg>)
2187 if (ranges::empty(__rg))
2188 return begin() + __pos;
2196 _M_get_allocator());
2199 return begin() + __pos;
2203#if __cplusplus >= 201103L
2210 _GLIBCXX20_CONSTEXPR
2213 {
return this->
insert(__p, __l.begin(), __l.end()); }
2215#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
2220 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2221 this->
insert(__p -
begin(), __l.begin(), __l.size());
2238 _GLIBCXX20_CONSTEXPR
2241 {
return this->
replace(__pos1, size_type(0),
2242 __str._M_data(), __str.
size()); }
2262 _GLIBCXX20_CONSTEXPR
2265 size_type __pos2, size_type __n =
npos)
2266 {
return this->
replace(__pos1, size_type(0), __str._M_data()
2267 + __str._M_check(__pos2,
"basic_string::insert"),
2268 __str._M_limit(__pos2, __n)); }
2286 _GLIBCXX20_CONSTEXPR
2288 insert(size_type __pos,
const _CharT* __s, size_type __n)
2289 {
return this->
replace(__pos, size_type(0), __s, __n); }
2306 _GLIBCXX20_CONSTEXPR
2310 __glibcxx_requires_string(__s);
2311 return this->
replace(__pos, size_type(0), __s,
2312 traits_type::length(__s));
2331 _GLIBCXX20_CONSTEXPR
2333 insert(size_type __pos, size_type __n, _CharT __c)
2334 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2335 size_type(0), __n, __c); }
2350 _GLIBCXX20_CONSTEXPR
2354 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2355 const size_type __pos = __p -
begin();
2356 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2357 return iterator(_M_data() + __pos);
2360#ifdef __glibcxx_string_view
2367 template<
typename _Tp>
2368 _GLIBCXX20_CONSTEXPR
2369 _If_sv<_Tp, basic_string&>
2372 __sv_type __sv = __svt;
2373 return this->
insert(__pos, __sv.data(), __sv.size());
2384 template<
typename _Tp>
2385 _GLIBCXX20_CONSTEXPR
2386 _If_sv<_Tp, basic_string&>
2387 insert(size_type __pos1,
const _Tp& __svt,
2388 size_type __pos2, size_type __n =
npos)
2390 __sv_type __sv = __svt;
2391 return this->
replace(__pos1, size_type(0),
2393 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2394 std::__sv_limit(__sv.size(), __pos2, __n));
2413 _GLIBCXX20_CONSTEXPR
2417 _M_check(__pos,
"basic_string::erase");
2419 this->_M_set_length(__pos);
2421 this->_M_erase(__pos, _M_limit(__pos, __n));
2433 _GLIBCXX20_CONSTEXPR
2437 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2438 && __position <
end());
2439 const size_type __pos = __position -
begin();
2440 this->_M_erase(__pos, size_type(1));
2441 return iterator(_M_data() + __pos);
2453 _GLIBCXX20_CONSTEXPR
2455 erase(__const_iterator __first, __const_iterator __last)
2457 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2458 && __last <=
end());
2459 const size_type __pos = __first -
begin();
2460 if (__last ==
end())
2461 this->_M_set_length(__pos);
2463 this->_M_erase(__pos, __last - __first);
2464 return iterator(this->_M_data() + __pos);
2467#if __cplusplus >= 201103L
2473 _GLIBCXX20_CONSTEXPR
2477 __glibcxx_assert(!
empty());
2478 _M_erase(
size() - 1, 1);
2499 _GLIBCXX20_CONSTEXPR
2502 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
2522 _GLIBCXX20_CONSTEXPR
2525 size_type __pos2, size_type __n2 =
npos)
2526 {
return this->
replace(__pos1, __n1, __str._M_data()
2527 + __str._M_check(__pos2,
"basic_string::replace"),
2528 __str._M_limit(__pos2, __n2)); }
2548 _GLIBCXX20_CONSTEXPR
2550 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2553 __glibcxx_requires_string_len(__s, __n2);
2554 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2555 _M_limit(__pos, __n1), __s, __n2);
2574 _GLIBCXX20_CONSTEXPR
2576 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2578 __glibcxx_requires_string(__s);
2579 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2599 _GLIBCXX20_CONSTEXPR
2601 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2602 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2603 _M_limit(__pos, __n1), __n2, __c); }
2618 _GLIBCXX20_CONSTEXPR
2620 replace(__const_iterator __i1, __const_iterator __i2,
2622 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
2639 _GLIBCXX20_CONSTEXPR
2641 replace(__const_iterator __i1, __const_iterator __i2,
2642 const _CharT* __s, size_type __n)
2644 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2646 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2662 _GLIBCXX20_CONSTEXPR
2664 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2666 __glibcxx_requires_string(__s);
2667 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2684 _GLIBCXX20_CONSTEXPR
2686 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2689 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2691 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2709#if __cplusplus >= 201103L
2710 template<
class _InputIterator,
2711 typename = std::_RequireInputIter<_InputIterator>>
2712 _GLIBCXX20_CONSTEXPR
2715 _InputIterator __k1, _InputIterator __k2)
2717 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2719 __glibcxx_requires_valid_range(__k1, __k2);
2720 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2721 std::__false_type());
2724 template<
class _InputIterator>
2725#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2726 typename __enable_if_not_native_iterator<_InputIterator>::__type
2731 _InputIterator __k1, _InputIterator __k2)
2733 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2735 __glibcxx_requires_valid_range(__k1, __k2);
2736 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2737 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2743 _GLIBCXX20_CONSTEXPR
2745 replace(__const_iterator __i1, __const_iterator __i2,
2746 _CharT* __k1, _CharT* __k2)
2748 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2750 __glibcxx_requires_valid_range(__k1, __k2);
2755 _GLIBCXX20_CONSTEXPR
2757 replace(__const_iterator __i1, __const_iterator __i2,
2758 const _CharT* __k1,
const _CharT* __k2)
2760 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2762 __glibcxx_requires_valid_range(__k1, __k2);
2767 _GLIBCXX20_CONSTEXPR
2769 replace(__const_iterator __i1, __const_iterator __i2,
2770 iterator __k1, iterator __k2)
2772 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2774 __glibcxx_requires_valid_range(__k1, __k2);
2776 __k1.base(), __k2 - __k1);
2779 _GLIBCXX20_CONSTEXPR
2781 replace(__const_iterator __i1, __const_iterator __i2,
2782 const_iterator __k1, const_iterator __k2)
2784 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2786 __glibcxx_requires_valid_range(__k1, __k2);
2788 __k1.base(), __k2 - __k1);
2791#if __glibcxx_containers_ranges
2799 template<__detail::__container_compatible_range<_CharT> _Rg>
2801 replace_with_range(const_iterator __i1, const_iterator __i2, _Rg&& __rg)
2808 _M_get_allocator());
2815#if __cplusplus >= 201103L
2830 _GLIBCXX20_CONSTEXPR
2833 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2836#ifdef __glibcxx_string_view
2844 template<
typename _Tp>
2845 _GLIBCXX20_CONSTEXPR
2846 _If_sv<_Tp, basic_string&>
2849 __sv_type __sv = __svt;
2850 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2862 template<
typename _Tp>
2863 _GLIBCXX20_CONSTEXPR
2864 _If_sv<_Tp, basic_string&>
2865 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2866 size_type __pos2, size_type __n2 =
npos)
2868 __sv_type __sv = __svt;
2869 return this->
replace(__pos1, __n1,
2871 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2872 std::__sv_limit(__sv.size(), __pos2, __n2));
2884 template<
typename _Tp>
2885 _GLIBCXX20_CONSTEXPR
2886 _If_sv<_Tp, basic_string&>
2887 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2889 __sv_type __sv = __svt;
2890 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2895 template<
class _Integer>
2896 _GLIBCXX20_CONSTEXPR
2898 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2899 _Integer __n, _Integer __val, __true_type)
2900 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2902 template<
class _InputIterator>
2903 _GLIBCXX20_CONSTEXPR
2905 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2906 _InputIterator __k1, _InputIterator __k2,
2909 _GLIBCXX20_CONSTEXPR
2911 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2914 __attribute__((__noinline__, __noclone__, __cold__))
void
2915 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2916 const size_type __len2,
const size_type __how_much);
2918 _GLIBCXX20_CONSTEXPR
2920 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2921 const size_type __len2);
2923 _GLIBCXX20_CONSTEXPR
2925 _M_append(
const _CharT* __s, size_type __n);
2941 _GLIBCXX20_CONSTEXPR
2943 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2952 _GLIBCXX20_CONSTEXPR
2963 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2966 {
return _M_data(); }
2976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2979 {
return _M_data(); }
2981#if __cplusplus >= 201703L
2988 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2991 {
return _M_data(); }
2997 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3000 {
return _M_get_allocator(); }
3014 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3016 find(
const _CharT* __s, size_type __pos, size_type __n)
const
3029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3033 {
return this->
find(__str.
data(), __pos, __str.
size()); }
3035#ifdef __glibcxx_string_view
3042 template<
typename _Tp>
3043 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3044 _If_sv<_Tp, size_type>
3046 noexcept(
is_same<_Tp, __sv_type>::value)
3048 __sv_type __sv = __svt;
3049 return this->
find(__sv.data(), __pos, __sv.size());
3063 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3065 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
3067 __glibcxx_requires_string(__s);
3068 return this->
find(__s, __pos, traits_type::length(__s));
3081 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3083 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
3095 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3099 {
return this->
rfind(__str.data(), __pos, __str.size()); }
3101#ifdef __glibcxx_string_view
3108 template<
typename _Tp>
3109 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3110 _If_sv<_Tp, size_type>
3114 __sv_type __sv = __svt;
3115 return this->
rfind(__sv.data(), __pos, __sv.size());
3131 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3133 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
3146 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3150 __glibcxx_requires_string(__s);
3151 return this->
rfind(__s, __pos, traits_type::length(__s));
3164 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3166 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
3179 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3185#ifdef __glibcxx_string_view
3193 template<
typename _Tp>
3194 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3195 _If_sv<_Tp, size_type>
3197 noexcept(
is_same<_Tp, __sv_type>::value)
3199 __sv_type __sv = __svt;
3200 return this->
find_first_of(__sv.data(), __pos, __sv.size());
3216 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3231 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3236 __glibcxx_requires_string(__s);
3237 return this->
find_first_of(__s, __pos, traits_type::length(__s));
3252 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3255 {
return this->
find(__c, __pos); }
3268 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3274#ifdef __glibcxx_string_view
3282 template<
typename _Tp>
3283 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3284 _If_sv<_Tp, size_type>
3288 __sv_type __sv = __svt;
3289 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3305 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3320 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3325 __glibcxx_requires_string(__s);
3326 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3341 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3344 {
return this->
rfind(__c, __pos); }
3356 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3362#ifdef __glibcxx_string_view
3370 template<
typename _Tp>
3371 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3372 _If_sv<_Tp, size_type>
3374 noexcept(
is_same<_Tp, __sv_type>::value)
3376 __sv_type __sv = __svt;
3393 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3396 size_type __n)
const _GLIBCXX_NOEXCEPT;
3408 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3413 __glibcxx_requires_string(__s);
3427 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3443 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3449#ifdef __glibcxx_string_view
3457 template<
typename _Tp>
3458 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3459 _If_sv<_Tp, size_type>
3463 __sv_type __sv = __svt;
3480 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3483 size_type __n)
const _GLIBCXX_NOEXCEPT;
3495 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3500 __glibcxx_requires_string(__s);
3514 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3531 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3535 _M_check(__pos,
"basic_string::substr"), __n); }
3537#if __cplusplus >= 202302L
3545 substr(size_type __pos, size_type __n) &&
3549#ifdef __glibcxx_string_subview
3563 constexpr basic_string_view<_CharT, _Traits>
3565 {
return __sv_type(*this).subview(__pos, __n); }
3582 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3586 const size_type __size = this->
size();
3587 const size_type __osize = __str.
size();
3588 const size_type __len =
std::min(__size, __osize);
3590 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
3592 __r = _S_compare(__size, __osize);
3596#ifdef __glibcxx_string_view
3602 template<
typename _Tp>
3603 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3605 compare(
const _Tp& __svt)
const
3608 __sv_type __sv = __svt;
3610 const size_type __osize = __sv.size();
3613 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3615 __r = _S_compare(__size, __osize);
3627 template<
typename _Tp>
3628 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3630 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3632 __sv_type __sv = __svt;
3633 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3646 template<
typename _Tp>
3647 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3649 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3650 size_type __pos2, size_type __n2 =
npos)
const
3652 __sv_type __sv = __svt;
3653 return __sv_type(*
this)
3654 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3677 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3681 _M_check(__pos,
"basic_string::compare");
3682 __n = _M_limit(__pos, __n);
3683 const size_type __osize = __str.
size();
3684 const size_type __len =
std::min(__n, __osize);
3685 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
3687 __r = _S_compare(__n, __osize);
3714 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3717 size_type __pos2, size_type __n2 =
npos)
const
3719 _M_check(__pos1,
"basic_string::compare");
3720 __str._M_check(__pos2,
"basic_string::compare");
3721 __n1 = _M_limit(__pos1, __n1);
3722 __n2 = __str._M_limit(__pos2, __n2);
3723 const size_type __len =
std::min(__n1, __n2);
3724 int __r = traits_type::compare(_M_data() + __pos1,
3725 __str.
data() + __pos2, __len);
3727 __r = _S_compare(__n1, __n2);
3745 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3747 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3749 __glibcxx_requires_string(__s);
3750 const size_type __size = this->
size();
3751 const size_type __osize = traits_type::length(__s);
3752 const size_type __len =
std::min(__size, __osize);
3753 int __r = traits_type::compare(_M_data(), __s, __len);
3755 __r = _S_compare(__size, __osize);
3780 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3782 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3784 __glibcxx_requires_string(__s);
3785 _M_check(__pos,
"basic_string::compare");
3786 __n1 = _M_limit(__pos, __n1);
3787 const size_type __osize = traits_type::length(__s);
3788 const size_type __len =
std::min(__n1, __osize);
3789 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3791 __r = _S_compare(__n1, __osize);
3819 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3821 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3822 size_type __n2)
const
3824 __glibcxx_requires_string_len(__s, __n2);
3825 _M_check(__pos,
"basic_string::compare");
3826 __n1 = _M_limit(__pos, __n1);
3827 const size_type __len =
std::min(__n1, __n2);
3828 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3830 __r = _S_compare(__n1, __n2);
3834#if __cplusplus >= 202002L
3838 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3842 starts_with(_CharT __x)
const noexcept
3843 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3845 [[nodiscard, __gnu__::__nonnull__]]
3847 starts_with(
const _CharT* __x)
const noexcept
3848 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3852 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3853 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3857 ends_with(_CharT __x)
const noexcept
3858 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3860 [[nodiscard, __gnu__::__nonnull__]]
3862 ends_with(
const _CharT* __x)
const noexcept
3863 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3866#if __cplusplus > 202002L
3869 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3870 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3874 contains(_CharT __x)
const noexcept
3875 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3877 [[nodiscard, __gnu__::__nonnull__]]
3879 contains(
const _CharT* __x)
const noexcept
3880 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3884 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3886_GLIBCXX_END_NAMESPACE_CXX11
3887_GLIBCXX_END_NAMESPACE_VERSION
3891namespace std _GLIBCXX_VISIBILITY(default)
3893_GLIBCXX_BEGIN_NAMESPACE_VERSION
3895#if __cpp_deduction_guides >= 201606
3896_GLIBCXX_BEGIN_NAMESPACE_CXX11
3897 template<
typename _InputIterator,
typename _CharT
3900 typename = _RequireInputIter<_InputIterator>,
3901 typename = _RequireAllocator<_Allocator>>
3902 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3907 template<
typename _CharT,
typename _Traits,
3909 typename = _RequireAllocator<_Allocator>>
3913 template<
typename _CharT,
typename _Traits,
3915 typename = _RequireAllocator<_Allocator>>
3917 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3918 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3919 const _Allocator& = _Allocator())
3922#if __glibcxx_containers_ranges
3925 basic_string(from_range_t, _Rg&&, _Allocator = _Allocator())
3930_GLIBCXX_END_NAMESPACE_CXX11
3933 template<
typename _Str>
3934 _GLIBCXX20_CONSTEXPR
3936 __str_concat(
typename _Str::value_type
const* __lhs,
3937 typename _Str::size_type __lhs_len,
3938 typename _Str::value_type
const* __rhs,
3939 typename _Str::size_type __rhs_len,
3940 typename _Str::allocator_type
const& __a)
3942 typedef typename _Str::allocator_type allocator_type;
3943 typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
3944 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3945 __str.
reserve(__lhs_len + __rhs_len);
3946 __str.
append(__lhs, __lhs_len);
3947 __str.
append(__rhs, __rhs_len);
3958 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3959 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3965 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3976 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3977 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3978 inline basic_string<_CharT,_Traits,_Alloc>
3982 __glibcxx_requires_string(__lhs);
3984 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3995 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3996 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3997 inline basic_string<_CharT,_Traits,_Alloc>
4001 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
4012 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4013 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4014 inline basic_string<_CharT, _Traits, _Alloc>
4016 const _CharT* __rhs)
4018 __glibcxx_requires_string(__rhs);
4020 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
4021 __rhs, _Traits::length(__rhs),
4030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4031 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4032 inline basic_string<_CharT, _Traits, _Alloc>
4036 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
4037 __builtin_addressof(__rhs), 1,
4041#if __cplusplus >= 201103L
4042 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4043 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4044 inline basic_string<_CharT, _Traits, _Alloc>
4045 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4046 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4047 {
return std::move(__lhs.append(__rhs)); }
4049 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4050 _GLIBCXX20_CONSTEXPR
4054 {
return std::move(__rhs.insert(0, __lhs)); }
4056 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4057 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4062#pragma GCC diagnostic push
4063#pragma GCC diagnostic ignored "-Wc++17-extensions"
4066 bool __use_rhs =
false;
4069 else if (__lhs.get_allocator() == __rhs.get_allocator())
4073 const auto __size = __lhs.size() + __rhs.size();
4074 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
4075 return std::move(__rhs.insert(0, __lhs));
4078#pragma GCC diagnostic pop
4081 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4082 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4086 {
return std::move(__rhs.insert(0, __lhs)); }
4088 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4089 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4093 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4095 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4096 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4099 const _CharT* __rhs)
4100 {
return std::move(__lhs.append(__rhs)); }
4102 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4103 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4107 {
return std::move(__lhs.append(1, __rhs)); }
4110#if __glibcxx_string_view >= 202403L
4112 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4119 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4120 __rhs.data(), __rhs.size(),
4121 __lhs.get_allocator());
4125 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4142 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4143 __rhs.data(), __rhs.size(),
4144 __rhs.get_allocator());
4148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4154 return std::move(__rhs.insert(0, __lhs));
4165 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4172 return __lhs.size() == __rhs.size()
4173 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
4182 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4183 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4186 const _CharT* __rhs)
4188 return __lhs.
size() == _Traits::length(__rhs)
4189 && !_Traits::compare(__lhs.
data(), __rhs, __lhs.
size());
4192#if __cpp_lib_three_way_comparison
4200 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4205 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4206 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4215 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4219 const _CharT* __rhs)
noexcept
4220 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4221 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4229 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4232 operator==(
const _CharT* __lhs,
4233 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4234 {
return __rhs == __lhs; }
4243 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4249 {
return !(__lhs == __rhs); }
4257 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4260 operator!=(
const _CharT* __lhs,
4262 {
return !(__rhs == __lhs); }
4270 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4274 const _CharT* __rhs)
4275 {
return !(__lhs == __rhs); }
4284 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4290 {
return __lhs.compare(__rhs) < 0; }
4298 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4302 const _CharT* __rhs)
4303 {
return __lhs.compare(__rhs) < 0; }
4311 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4314 operator<(
const _CharT* __lhs,
4316 {
return __rhs.compare(__lhs) > 0; }
4325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4331 {
return __lhs.compare(__rhs) > 0; }
4339 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4343 const _CharT* __rhs)
4344 {
return __lhs.compare(__rhs) > 0; }
4352 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4355 operator>(
const _CharT* __lhs,
4357 {
return __rhs.compare(__lhs) < 0; }
4366 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4372 {
return __lhs.compare(__rhs) <= 0; }
4380 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4384 const _CharT* __rhs)
4385 {
return __lhs.compare(__rhs) <= 0; }
4393 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4396 operator<=(
const _CharT* __lhs,
4398 {
return __rhs.compare(__lhs) >= 0; }
4407 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4413 {
return __lhs.compare(__rhs) >= 0; }
4421 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4425 const _CharT* __rhs)
4426 {
return __lhs.compare(__rhs) >= 0; }
4434 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4437 operator>=(
const _CharT* __lhs,
4439 {
return __rhs.compare(__lhs) <= 0; }
4449 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4450 _GLIBCXX20_CONSTEXPR
4454 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4455 { __lhs.swap(__rhs); }
4470 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4471 basic_istream<_CharT, _Traits>&
4472 operator>>(basic_istream<_CharT, _Traits>& __is,
4473 basic_string<_CharT, _Traits, _Alloc>& __str);
4476 basic_istream<char>&
4488 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4495 return __ostream_insert(__os, __str.
data(), __str.
size());
4511 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4512 basic_istream<_CharT, _Traits>&
4513 getline(basic_istream<_CharT, _Traits>& __is,
4514 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4528 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4529 inline basic_istream<_CharT, _Traits>&
4534#if __cplusplus >= 201103L
4536 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4537 inline basic_istream<_CharT, _Traits>&
4543 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4544 inline basic_istream<_CharT, _Traits>&
4551 basic_istream<char>&
4552 getline(basic_istream<char>& __in, basic_string<char>& __str,
4555#ifdef _GLIBCXX_USE_WCHAR_T
4557 basic_istream<wchar_t>&
4558 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4562_GLIBCXX_END_NAMESPACE_VERSION
4565#if __cplusplus >= 201103L
4570namespace std _GLIBCXX_VISIBILITY(default)
4572_GLIBCXX_BEGIN_NAMESPACE_VERSION
4573_GLIBCXX_BEGIN_NAMESPACE_CXX11
4577 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4578 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4582 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4583 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4586 inline unsigned long
4587 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4588 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4591#if _GLIBCXX_USE_C99_STDLIB
4593 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4594 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4597 inline unsigned long long
4598 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4599 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4601#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4603 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4604 {
return std::stol(__str, __idx, __base); }
4606 inline unsigned long long
4607 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4608 {
return std::stoul(__str, __idx, __base); }
4612 stod(
const string& __str,
size_t* __idx = 0)
4613 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4615#if _GLIBCXX_HAVE_STRTOF
4618 stof(
const string& __str,
size_t* __idx = 0)
4619 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4622 stof(
const string& __str,
size_t* __idx = 0)
4624 double __d = std::stod(__str, __idx);
4625 if (__builtin_isfinite(__d) && __d != 0.0)
4627 double __abs_d = __builtin_fabs(__d);
4628 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4631 std::__throw_out_of_range(
"stof");
4638#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4640 stold(
const string& __str,
size_t* __idx = 0)
4641 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4642#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4644 stold(
const string& __str,
size_t* __idx = 0)
4645 {
return std::stod(__str, __idx); }
4648#if __glibcxx_constexpr_string >= 202511L
4649# define _GLIBCXX_TO_STRING_CONSTEXPR constexpr
4651# define _GLIBCXX_TO_STRING_CONSTEXPR inline
4658 _GLIBCXX_TO_STRING_CONSTEXPR
string
4659 to_string(
int __val)
4660#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4664 const bool __neg = __val < 0;
4665 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4666 const auto __len = __detail::__to_chars_len(__uval);
4668 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4670 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4677 _GLIBCXX_TO_STRING_CONSTEXPR
string
4678 to_string(
unsigned __val)
4679#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4683 const auto __len = __detail::__to_chars_len(__val);
4685 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4686 __detail::__to_chars_10_impl(__p, __n, __val);
4693 _GLIBCXX_TO_STRING_CONSTEXPR
string
4694 to_string(
long __val)
4695#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4699 const bool __neg = __val < 0;
4700 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4701 const auto __len = __detail::__to_chars_len(__uval);
4703 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4705 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4712 _GLIBCXX_TO_STRING_CONSTEXPR
string
4713 to_string(
unsigned long __val)
4714#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4718 const auto __len = __detail::__to_chars_len(__val);
4720 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4721 __detail::__to_chars_10_impl(__p, __n, __val);
4728 _GLIBCXX_TO_STRING_CONSTEXPR
string
4729 to_string(
long long __val)
4731 const bool __neg = __val < 0;
4732 const unsigned long long __uval
4733 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4734 const auto __len = __detail::__to_chars_len(__uval);
4736 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4738 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4745 _GLIBCXX_TO_STRING_CONSTEXPR
string
4746 to_string(
unsigned long long __val)
4748 const auto __len = __detail::__to_chars_len(__val);
4750 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4751 __detail::__to_chars_10_impl(__p, __n, __val);
4757#if __glibcxx_to_string >= 202306L
4761 to_string(
float __val)
4766 __str.resize_and_overwrite(__len,
4767 [__val, &__len] (
char* __p,
size_t __n) {
4768 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4769 if (__err == errc{}) [[likely]]
4774 }
while (__str.empty());
4780 to_string(
double __val)
4785 __str.resize_and_overwrite(__len,
4786 [__val, &__len] (
char* __p,
size_t __n) {
4787 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4788 if (__err == errc{}) [[likely]]
4793 }
while (__str.empty());
4799 to_string(
long double __val)
4804 __str.resize_and_overwrite(__len,
4805 [__val, &__len] (
char* __p,
size_t __n) {
4806 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4807 if (__err == errc{}) [[likely]]
4812 }
while (__str.empty());
4815#elif _GLIBCXX_USE_C99_STDIO
4816#pragma GCC diagnostic push
4817#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4822 to_string(
float __val)
4825 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4826 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4832 to_string(
double __val)
4835 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4836 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4842 to_string(
long double __val)
4845 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4846 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4849#pragma GCC diagnostic pop
4852#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4854 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4855 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4859 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4860 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4863 inline unsigned long
4864 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4865 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4869 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4870 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4873 inline unsigned long long
4874 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4875 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4880 stof(
const wstring& __str,
size_t* __idx = 0)
4881 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4884 stod(
const wstring& __str,
size_t* __idx = 0)
4885 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4888 stold(
const wstring& __str,
size_t* __idx = 0)
4889 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4892#ifdef _GLIBCXX_USE_WCHAR_T
4893#pragma GCC diagnostic push
4894#pragma GCC diagnostic ignored "-Wc++17-extensions"
4895 _GLIBCXX20_CONSTEXPR
4897 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4901 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4902 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4904 for (
int __i = 0; __i < __len; ++__i)
4905 __wout[__i] = (
wchar_t) __s[__i];
4910 for (
int __i =
'0'; __i <=
'9'; ++__i)
4911 __wc[__i] = L
'0' + __i;
4936 for (
int __i = 0; __i < __len; ++__i)
4937 __wout[__i] = __wc[(
int)__s[__i]];
4941#if __glibcxx_constexpr_string >= 201907L
4945#ifdef __glibcxx_string_view
4946 __to_wstring_numeric(string_view __s)
4948 __to_wstring_numeric(
const string& __s)
4951 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4952 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4953 return wstring(__s.data(), __s.data() + __s.size());
4957 auto __f = __s.data();
4958 __ws.__resize_and_overwrite(__s.size(),
4959 [__f] (
wchar_t* __to,
int __n) {
4960 std::__to_wstring_numeric(__f, __n, __to);
4966#pragma GCC diagnostic pop
4969 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4970 to_wstring(
int __val)
4971 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4974 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4975 to_wstring(
unsigned __val)
4976 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4979 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4980 to_wstring(
long __val)
4981 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4984 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4985 to_wstring(
unsigned long __val)
4986 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4989 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4990 to_wstring(
long long __val)
4991 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4994 _GLIBCXX_TO_STRING_CONSTEXPR
wstring
4995 to_wstring(
unsigned long long __val)
4996 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4998#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
5001 to_wstring(
float __val)
5002 {
return std::__to_wstring_numeric(std::to_string(__val)); }
5006 to_wstring(
double __val)
5007 {
return std::__to_wstring_numeric(std::to_string(__val)); }
5011 to_wstring(
long double __val)
5012 {
return std::__to_wstring_numeric(std::to_string(__val)); }
5015#undef _GLIBCXX_TO_STRING_CONSTEXPR
5017_GLIBCXX_END_NAMESPACE_CXX11
5018_GLIBCXX_END_NAMESPACE_VERSION
5023#if __cplusplus >= 201103L
5027namespace std _GLIBCXX_VISIBILITY(default)
5029_GLIBCXX_BEGIN_NAMESPACE_VERSION
5034 template<
typename _CharT,
typename _Alloc,
5036 struct __str_hash_base
5037 :
public __hash_base<size_t, _StrT>
5041 operator()(
const _StrT& __s)
const noexcept
5042 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
5045#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5047 template<
typename _Alloc>
5049 :
public __str_hash_base<char, _Alloc>
5053 template<
typename _Alloc>
5055 :
public __str_hash_base<wchar_t, _Alloc>
5058 template<
typename _Alloc>
5065#ifdef _GLIBCXX_USE_CHAR8_T
5067 template<
typename _Alloc>
5068 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
5069 :
public __str_hash_base<char8_t, _Alloc>
5074 template<
typename _Alloc>
5076 :
public __str_hash_base<char16_t, _Alloc>
5080 template<
typename _Alloc>
5082 :
public __str_hash_base<char32_t, _Alloc>
5085#if ! _GLIBCXX_INLINE_VERSION
5091#ifdef _GLIBCXX_USE_CHAR8_T
5096 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5102#ifdef __glibcxx_string_udls
5105 inline namespace string_literals
5107#pragma GCC diagnostic push
5108#pragma GCC diagnostic ignored "-Wliteral-suffix"
5110#if __glibcxx_constexpr_string >= 201907L
5111# define _GLIBCXX_STRING_CONSTEXPR constexpr
5113# define _GLIBCXX_STRING_CONSTEXPR
5116 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5117 inline basic_string<char>
5118 operator""s(
const char* __str,
size_t __len)
5119 {
return basic_string<char>{__str, __len}; }
5121 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5122 inline basic_string<wchar_t>
5123 operator""s(
const wchar_t* __str,
size_t __len)
5124 {
return basic_string<wchar_t>{__str, __len}; }
5126#ifdef _GLIBCXX_USE_CHAR8_T
5127 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5128 inline basic_string<char8_t>
5129 operator""s(
const char8_t* __str,
size_t __len)
5130 {
return basic_string<char8_t>{__str, __len}; }
5133 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5134 inline basic_string<char16_t>
5135 operator""s(
const char16_t* __str,
size_t __len)
5136 {
return basic_string<char16_t>{__str, __len}; }
5138 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5139 inline basic_string<char32_t>
5140 operator""s(
const char32_t* __str,
size_t __len)
5141 {
return basic_string<char32_t>{__str, __len}; }
5143#undef _GLIBCXX_STRING_CONSTEXPR
5144#pragma GCC diagnostic pop
5149#ifdef __glibcxx_variant
5150 namespace __detail::__variant
5152 template<
typename>
struct _Never_valueless_alt;
5156 template<
typename _Tp,
typename _Traits,
typename _Alloc>
5157 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
5159 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
5160 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
5166_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.
Provides input iterator semantics for streambufs.
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.