34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
37#pragma GCC system_header
42#if __cplusplus >= 201103L
46#if __cplusplus >= 201703L
50#if ! _GLIBCXX_USE_CXX11_ABI
53namespace std _GLIBCXX_VISIBILITY(default)
55_GLIBCXX_BEGIN_NAMESPACE_VERSION
56_GLIBCXX_BEGIN_NAMESPACE_CXX11
58#ifdef __cpp_lib_is_constant_evaluated
60# define __cpp_lib_constexpr_string 201907L
61#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
63# define __cpp_lib_constexpr_string 201611L
84 template<
typename _CharT,
typename _Traits,
typename _Alloc>
88 rebind<_CharT>::other _Char_alloc_type;
90#if __cpp_lib_constexpr_string < 201907L
93 template<
typename _Traits2,
typename _Dummy_for_PR85282>
98 [[__gnu__::__always_inline__]]
99 static constexpr typename _Base::pointer
100 allocate(_Char_alloc_type& __a,
typename _Base::size_type __n)
102 pointer __p = _Base::allocate(__a, __n);
105 for (size_type __i = 0; __i < __n; ++__i)
106 std::construct_at(__builtin_addressof(__p[__i]));
111 template<
typename _Dummy_for_PR85282>
112 struct _Alloc_traits_impl<char_traits<_CharT>, _Dummy_for_PR85282>
118 using _Alloc_traits = _Alloc_traits_impl<_Traits, void>;
123 typedef _Traits traits_type;
124 typedef typename _Traits::char_type value_type;
125 typedef _Char_alloc_type allocator_type;
126 typedef typename _Alloc_traits::size_type size_type;
127 typedef typename _Alloc_traits::difference_type difference_type;
128 typedef typename _Alloc_traits::reference reference;
129 typedef typename _Alloc_traits::const_reference const_reference;
130 typedef typename _Alloc_traits::pointer pointer;
131 typedef typename _Alloc_traits::const_pointer const_pointer;
132 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
133 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
139 static const size_type
npos =
static_cast<size_type
>(-1);
143#if __cplusplus < 201103L
144 typedef iterator __const_iterator;
146 typedef const_iterator __const_iterator;
150#if __cplusplus >= 201703L
152 typedef basic_string_view<_CharT, _Traits> __sv_type;
154 template<
typename _Tp,
typename _Res>
156 __and_<is_convertible<const _Tp&, __sv_type>,
157 __not_<is_convertible<const _Tp*, const basic_string*>>,
158 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
164 _S_to_string_view(__sv_type __svt)
noexcept
173 _GLIBCXX20_CONSTEXPR
explicit
174 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
192 struct _Alloc_hider : allocator_type
194#if __cplusplus < 201103L
195 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
196 : allocator_type(__a), _M_p(__dat) { }
199 _Alloc_hider(pointer __dat,
const _Alloc& __a)
200 : allocator_type(__a), _M_p(__dat) { }
203 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
204 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
210 _Alloc_hider _M_dataplus;
211 size_type _M_string_length;
213 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
217 _CharT _M_local_buf[_S_local_capacity + 1];
218 size_type _M_allocated_capacity;
224 { _M_dataplus._M_p = __p; }
228 _M_length(size_type __length)
229 { _M_string_length = __length; }
234 {
return _M_dataplus._M_p; }
240#if __cplusplus >= 201103L
243 return pointer(_M_local_buf);
249 _M_local_data()
const
251#if __cplusplus >= 201103L
254 return const_pointer(_M_local_buf);
260 _M_capacity(size_type __capacity)
261 { _M_allocated_capacity = __capacity; }
265 _M_set_length(size_type __n)
268 traits_type::assign(_M_data()[__n], _CharT());
275 if (_M_data() == _M_local_data())
277 if (_M_string_length > _S_local_capacity)
278 __builtin_unreachable();
287 _M_create(size_type&, size_type);
294 _M_destroy(_M_allocated_capacity);
299 _M_destroy(size_type __size)
throw()
300 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
302#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
305 template<
typename _InIterator>
307 _M_construct_aux(_InIterator __beg, _InIterator __end,
310 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
311 _M_construct(__beg, __end, _Tag());
316 template<
typename _Integer>
318 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
319 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
322 _M_construct_aux_2(size_type __req, _CharT __c)
323 { _M_construct(__req, __c); }
327 template<
typename _InIterator>
330 _M_construct(_InIterator __beg, _InIterator __end,
335 template<
typename _FwdIterator>
338 _M_construct(_FwdIterator __beg, _FwdIterator __end,
343 _M_construct(size_type __req, _CharT __c);
348 {
return _M_dataplus; }
351 const allocator_type&
352 _M_get_allocator()
const
353 {
return _M_dataplus; }
356 __attribute__((__always_inline__))
359 _M_use_local_data() _GLIBCXX_NOEXCEPT
361#if __cpp_lib_is_constant_evaluated
363 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
364 _M_local_buf[__i] = _CharT();
366 return _M_local_data();
371#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
374 template<
typename _Tp,
bool _Requires =
375 !__are_same<_Tp, _CharT*>::__value
376 && !__are_same<_Tp, const _CharT*>::__value
377 && !__are_same<_Tp, iterator>::__value
378 && !__are_same<_Tp, const_iterator>::__value>
379 struct __enable_if_not_native_iterator
380 {
typedef basic_string& __type; };
381 template<
typename _Tp>
382 struct __enable_if_not_native_iterator<_Tp, false> { };
387 _M_check(size_type __pos,
const char* __s)
const
389 if (__pos > this->
size())
390 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
391 "this->size() (which is %zu)"),
392 __s, __pos, this->
size());
398 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
401 __throw_length_error(__N(__s));
408 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
410 const bool __testoff = __off < this->
size() - __pos;
411 return __testoff ? __off : this->
size() - __pos;
416 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
418 return (less<const _CharT*>()(__s, _M_data())
419 || less<const _CharT*>()(_M_data() + this->
size(), __s));
426 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
429 traits_type::assign(*__d, *__s);
431 traits_type::copy(__d, __s, __n);
436 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
439 traits_type::assign(*__d, *__s);
441 traits_type::move(__d, __s, __n);
446 _S_assign(_CharT* __d, size_type __n, _CharT __c)
449 traits_type::assign(*__d, __c);
451 traits_type::assign(__d, __n, __c);
456 template<
class _Iterator>
459 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
461 for (; __k1 != __k2; ++__k1, (void)++__p)
462 traits_type::assign(*__p, *__k1);
467 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
468 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
472 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
474 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
478 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
479 { _S_copy(__p, __k1, __k2 - __k1); }
483 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
485 { _S_copy(__p, __k1, __k2 - __k1); }
489 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
491 const difference_type __d = difference_type(__n1 - __n2);
493 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
494 return __gnu_cxx::__numeric_traits<int>::__max;
495 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
496 return __gnu_cxx::__numeric_traits<int>::__min;
507 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
512 _M_erase(size_type __pos, size_type __n);
524 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
525 : _M_dataplus(_M_local_data())
537 : _M_dataplus(_M_local_data(), __a)
549 : _M_dataplus(_M_local_data(),
550 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
552 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
566 const _Alloc& __a = _Alloc())
567 : _M_dataplus(_M_local_data(), __a)
569 const _CharT* __start = __str._M_data()
570 + __str._M_check(__pos,
"basic_string::basic_string");
571 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
584 : _M_dataplus(_M_local_data())
586 const _CharT* __start = __str._M_data()
587 + __str._M_check(__pos,
"basic_string::basic_string");
588 _M_construct(__start, __start + __str._M_limit(__pos, __n),
601 size_type __n,
const _Alloc& __a)
602 : _M_dataplus(_M_local_data(), __a)
604 const _CharT* __start
605 = __str._M_data() + __str._M_check(__pos,
"string::string");
606 _M_construct(__start, __start + __str._M_limit(__pos, __n),
621 const _Alloc& __a = _Alloc())
622 : _M_dataplus(_M_local_data(), __a)
625 if (__s == 0 && __n > 0)
626 std::__throw_logic_error(__N(
"basic_string: "
627 "construction from null is not valid"));
636#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
639 template<
typename = _RequireAllocator<_Alloc>>
642 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
643 : _M_dataplus(_M_local_data(), __a)
647 std::__throw_logic_error(__N(
"basic_string: "
648 "construction from null is not valid"));
649 const _CharT* __end = __s + traits_type::length(__s);
650 _M_construct(__s, __end, forward_iterator_tag());
659#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
662 template<
typename = _RequireAllocator<_Alloc>>
665 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
666 : _M_dataplus(_M_local_data(), __a)
667 { _M_construct(__n, __c); }
669#if __cplusplus >= 201103L
679 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
681 if (__str._M_is_local())
683 traits_type::copy(_M_local_buf, __str._M_local_buf,
688 _M_data(__str._M_data());
689 _M_capacity(__str._M_allocated_capacity);
695 _M_length(__str.length());
696 __str._M_data(__str._M_local_data());
697 __str._M_set_length(0);
706 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
707 : _M_dataplus(_M_local_data(), __a)
712 : _M_dataplus(_M_local_data(), __a)
717 noexcept(_Alloc_traits::_S_always_equal())
718 : _M_dataplus(_M_local_data(), __a)
720 if (__str._M_is_local())
722 traits_type::copy(_M_local_buf, __str._M_local_buf,
724 _M_length(__str.length());
725 __str._M_set_length(0);
727 else if (_Alloc_traits::_S_always_equal()
728 || __str.get_allocator() == __a)
730 _M_data(__str._M_data());
731 _M_length(__str.length());
732 _M_capacity(__str._M_allocated_capacity);
733 __str._M_data(__str._M_local_buf);
734 __str._M_set_length(0);
741#if __cplusplus >= 202100L
752#if __cplusplus >= 201103L
753 template<
typename _InputIterator,
754 typename = std::_RequireInputIter<_InputIterator>>
756 template<
typename _InputIterator>
759 basic_string(_InputIterator __beg, _InputIterator __end,
760 const _Alloc& __a = _Alloc())
761 : _M_dataplus(_M_local_data(), __a)
763#if __cplusplus >= 201103L
766 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
767 _M_construct_aux(__beg, __end, _Integral());
771#if __cplusplus >= 201703L
779 template<
typename _Tp,
780 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
782 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
783 const _Alloc& __a = _Alloc())
791 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
794 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
795 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
813 return this->
assign(__str);
823 {
return this->
assign(__s); }
840#if __cplusplus >= 201103L
853 noexcept(_Alloc_traits::_S_nothrow_move())
855 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
856 || _M_get_allocator() == __str._M_get_allocator();
857 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
861 _M_destroy(_M_allocated_capacity);
862 _M_data(_M_local_data());
866 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
868 if (__str._M_is_local())
876 this->_S_copy(_M_data(), __str._M_data(), __str.size());
877 _M_set_length(__str.size());
880 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
883 pointer __data =
nullptr;
884 size_type __capacity;
891 __capacity = _M_allocated_capacity;
894 _M_destroy(_M_allocated_capacity);
897 _M_data(__str._M_data());
898 _M_length(__str.length());
899 _M_capacity(__str._M_allocated_capacity);
902 __str._M_data(__data);
903 __str._M_capacity(__capacity);
906 __str._M_data(__str._M_local_buf);
922 this->
assign(__l.begin(), __l.size());
927#if __cplusplus >= 201703L
932 template<
typename _Tp>
934 _If_sv<_Tp, basic_string&>
936 {
return this->
assign(__svt); }
943 operator __sv_type() const noexcept
944 {
return __sv_type(
data(),
size()); }
952 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
954 begin() _GLIBCXX_NOEXCEPT
955 {
return iterator(_M_data()); }
961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
963 begin() const _GLIBCXX_NOEXCEPT
964 {
return const_iterator(_M_data()); }
970 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
972 end() _GLIBCXX_NOEXCEPT
973 {
return iterator(_M_data() + this->
size()); }
979 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
981 end() const _GLIBCXX_NOEXCEPT
982 {
return const_iterator(_M_data() + this->
size()); }
989 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
991 rbegin() _GLIBCXX_NOEXCEPT
992 {
return reverse_iterator(this->
end()); }
999 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1000 const_reverse_iterator
1001 rbegin() const _GLIBCXX_NOEXCEPT
1002 {
return const_reverse_iterator(this->
end()); }
1009 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1011 rend() _GLIBCXX_NOEXCEPT
1012 {
return reverse_iterator(this->
begin()); }
1019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1020 const_reverse_iterator
1021 rend() const _GLIBCXX_NOEXCEPT
1022 {
return const_reverse_iterator(this->
begin()); }
1024#if __cplusplus >= 201103L
1029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1032 {
return const_iterator(this->_M_data()); }
1038 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1040 cend() const noexcept
1041 {
return const_iterator(this->_M_data() + this->
size()); }
1048 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1049 const_reverse_iterator
1051 {
return const_reverse_iterator(this->
end()); }
1058 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1059 const_reverse_iterator
1060 crend() const noexcept
1061 {
return const_reverse_iterator(this->
begin()); }
1068 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1070 size() const _GLIBCXX_NOEXCEPT
1071 {
return _M_string_length; }
1075 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1077 length() const _GLIBCXX_NOEXCEPT
1078 {
return _M_string_length; }
1081 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1084 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1096 _GLIBCXX20_CONSTEXPR
1098 resize(size_type __n, _CharT __c);
1110 _GLIBCXX20_CONSTEXPR
1113 { this->
resize(__n, _CharT()); }
1115#if __cplusplus >= 201103L
1116#pragma GCC diagnostic push
1117#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1119 _GLIBCXX20_CONSTEXPR
1123#pragma GCC diagnostic pop
1126#if __cplusplus > 202002L
1127#define __cpp_lib_string_resize_and_overwrite 202110L
1157 template<
typename _Operation>
1159 resize_and_overwrite(size_type __n, _Operation __op);
1166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1170 return _M_is_local() ? size_type(_S_local_capacity)
1171 : _M_allocated_capacity;
1191 _GLIBCXX20_CONSTEXPR
1198#if __cplusplus > 201703L
1199 [[deprecated(
"use shrink_to_fit() instead")]]
1201 _GLIBCXX20_CONSTEXPR
1208 _GLIBCXX20_CONSTEXPR
1210 clear() _GLIBCXX_NOEXCEPT
1211 { _M_set_length(0); }
1217 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1219 empty() const _GLIBCXX_NOEXCEPT
1220 {
return this->
size() == 0; }
1233 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1235 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1237 __glibcxx_assert(__pos <=
size());
1238 return _M_data()[__pos];
1251 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1257 __glibcxx_assert(__pos <=
size());
1259 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1260 return _M_data()[__pos];
1273 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1275 at(size_type __n)
const
1277 if (__n >= this->
size())
1278 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1279 "(which is %zu) >= this->size() "
1282 return _M_data()[__n];
1295 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1300 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1301 "(which is %zu) >= this->size() "
1304 return _M_data()[__n];
1307#if __cplusplus >= 201103L
1312 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1316 __glibcxx_assert(!
empty());
1324 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1326 front() const noexcept
1328 __glibcxx_assert(!
empty());
1336 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1340 __glibcxx_assert(!
empty());
1348 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1350 back() const noexcept
1352 __glibcxx_assert(!
empty());
1363 _GLIBCXX20_CONSTEXPR
1366 {
return this->
append(__str); }
1373 _GLIBCXX20_CONSTEXPR
1376 {
return this->
append(__s); }
1383 _GLIBCXX20_CONSTEXPR
1391#if __cplusplus >= 201103L
1397 _GLIBCXX20_CONSTEXPR
1400 {
return this->
append(__l.begin(), __l.size()); }
1403#if __cplusplus >= 201703L
1409 template<
typename _Tp>
1410 _GLIBCXX20_CONSTEXPR
1411 _If_sv<_Tp, basic_string&>
1413 {
return this->
append(__svt); }
1421 _GLIBCXX20_CONSTEXPR
1424 {
return this->
append(__str._M_data(), __str.size()); }
1439 _GLIBCXX20_CONSTEXPR
1442 {
return this->
append(__str._M_data()
1443 + __str._M_check(__pos,
"basic_string::append"),
1444 __str._M_limit(__pos, __n)); }
1452 _GLIBCXX20_CONSTEXPR
1454 append(
const _CharT* __s, size_type __n)
1456 __glibcxx_requires_string_len(__s, __n);
1457 _M_check_length(size_type(0), __n,
"basic_string::append");
1458 return _M_append(__s, __n);
1466 _GLIBCXX20_CONSTEXPR
1468 append(
const _CharT* __s)
1470 __glibcxx_requires_string(__s);
1471 const size_type __n = traits_type::length(__s);
1472 _M_check_length(size_type(0), __n,
"basic_string::append");
1473 return _M_append(__s, __n);
1484 _GLIBCXX20_CONSTEXPR
1486 append(size_type __n, _CharT __c)
1487 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1489#if __cplusplus >= 201103L
1495 _GLIBCXX20_CONSTEXPR
1497 append(initializer_list<_CharT> __l)
1498 {
return this->
append(__l.begin(), __l.size()); }
1509#if __cplusplus >= 201103L
1510 template<
class _InputIterator,
1511 typename = std::_RequireInputIter<_InputIterator>>
1512 _GLIBCXX20_CONSTEXPR
1514 template<
class _InputIterator>
1517 append(_InputIterator __first, _InputIterator __last)
1520#if __cplusplus >= 201703L
1526 template<
typename _Tp>
1527 _GLIBCXX20_CONSTEXPR
1528 _If_sv<_Tp, basic_string&>
1531 __sv_type __sv = __svt;
1532 return this->
append(__sv.data(), __sv.size());
1542 template<
typename _Tp>
1543 _GLIBCXX20_CONSTEXPR
1544 _If_sv<_Tp, basic_string&>
1545 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1547 __sv_type __sv = __svt;
1548 return _M_append(__sv.data()
1549 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1550 std::__sv_limit(__sv.size(), __pos, __n));
1558 _GLIBCXX20_CONSTEXPR
1562 const size_type __size = this->
size();
1564 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1565 traits_type::assign(this->_M_data()[__size], __c);
1566 this->_M_set_length(__size + 1);
1574 _GLIBCXX20_CONSTEXPR
1578#if __cplusplus >= 201103L
1579 if (_Alloc_traits::_S_propagate_on_copy_assign())
1581 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1582 && _M_get_allocator() != __str._M_get_allocator())
1586 if (__str.size() <= _S_local_capacity)
1588 _M_destroy(_M_allocated_capacity);
1589 _M_data(_M_use_local_data());
1594 const auto __len = __str.size();
1595 auto __alloc = __str._M_get_allocator();
1597 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1598 _M_destroy(_M_allocated_capacity);
1601 _M_set_length(__len);
1604 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1607 this->_M_assign(__str);
1611#if __cplusplus >= 201103L
1620 _GLIBCXX20_CONSTEXPR
1623 noexcept(_Alloc_traits::_S_nothrow_move())
1644 _GLIBCXX20_CONSTEXPR
1647 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1648 + __str._M_check(__pos,
"basic_string::assign"),
1649 __str._M_limit(__pos, __n)); }
1661 _GLIBCXX20_CONSTEXPR
1663 assign(
const _CharT* __s, size_type __n)
1665 __glibcxx_requires_string_len(__s, __n);
1666 return _M_replace(size_type(0), this->
size(), __s, __n);
1678 _GLIBCXX20_CONSTEXPR
1680 assign(
const _CharT* __s)
1682 __glibcxx_requires_string(__s);
1683 return _M_replace(size_type(0), this->
size(), __s,
1684 traits_type::length(__s));
1696 _GLIBCXX20_CONSTEXPR
1698 assign(size_type __n, _CharT __c)
1699 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1709#if __cplusplus >= 201103L
1710 template<
class _InputIterator,
1711 typename = std::_RequireInputIter<_InputIterator>>
1712 _GLIBCXX20_CONSTEXPR
1714 template<
class _InputIterator>
1717 assign(_InputIterator __first, _InputIterator __last)
1720#if __cplusplus >= 201103L
1726 _GLIBCXX20_CONSTEXPR
1728 assign(initializer_list<_CharT> __l)
1729 {
return this->
assign(__l.begin(), __l.size()); }
1732#if __cplusplus >= 201703L
1738 template<
typename _Tp>
1739 _GLIBCXX20_CONSTEXPR
1740 _If_sv<_Tp, basic_string&>
1743 __sv_type __sv = __svt;
1744 return this->
assign(__sv.data(), __sv.size());
1754 template<
typename _Tp>
1755 _GLIBCXX20_CONSTEXPR
1756 _If_sv<_Tp, basic_string&>
1757 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1759 __sv_type __sv = __svt;
1760 return _M_replace(size_type(0), this->
size(),
1762 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1763 std::__sv_limit(__sv.size(), __pos, __n));
1767#if __cplusplus >= 201103L
1783 _GLIBCXX20_CONSTEXPR
1785 insert(const_iterator __p, size_type __n, _CharT __c)
1787 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1788 const size_type __pos = __p -
begin();
1789 this->
replace(__p, __p, __n, __c);
1790 return iterator(this->_M_data() + __pos);
1807 insert(iterator __p, size_type __n, _CharT __c)
1808 { this->
replace(__p, __p, __n, __c); }
1811#if __cplusplus >= 201103L
1826 template<
class _InputIterator,
1827 typename = std::_RequireInputIter<_InputIterator>>
1828 _GLIBCXX20_CONSTEXPR
1830 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1832 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1833 const size_type __pos = __p -
begin();
1834 this->
replace(__p, __p, __beg, __end);
1835 return iterator(this->_M_data() + __pos);
1850 template<
class _InputIterator>
1852 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1853 { this->
replace(__p, __p, __beg, __end); }
1856#if __cplusplus >= 201103L
1863 _GLIBCXX20_CONSTEXPR
1865 insert(const_iterator __p, initializer_list<_CharT> __l)
1866 {
return this->
insert(__p, __l.begin(), __l.end()); }
1868#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1871 insert(iterator __p, initializer_list<_CharT> __l)
1873 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1874 this->
insert(__p -
begin(), __l.begin(), __l.size());
1891 _GLIBCXX20_CONSTEXPR
1894 {
return this->
replace(__pos1, size_type(0),
1895 __str._M_data(), __str.size()); }
1915 _GLIBCXX20_CONSTEXPR
1918 size_type __pos2, size_type __n =
npos)
1919 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1920 + __str._M_check(__pos2,
"basic_string::insert"),
1921 __str._M_limit(__pos2, __n)); }
1939 _GLIBCXX20_CONSTEXPR
1941 insert(size_type __pos,
const _CharT* __s, size_type __n)
1942 {
return this->
replace(__pos, size_type(0), __s, __n); }
1959 _GLIBCXX20_CONSTEXPR
1961 insert(size_type __pos,
const _CharT* __s)
1963 __glibcxx_requires_string(__s);
1964 return this->
replace(__pos, size_type(0), __s,
1965 traits_type::length(__s));
1984 _GLIBCXX20_CONSTEXPR
1986 insert(size_type __pos, size_type __n, _CharT __c)
1987 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1988 size_type(0), __n, __c); }
2003 _GLIBCXX20_CONSTEXPR
2005 insert(__const_iterator __p, _CharT __c)
2007 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2008 const size_type __pos = __p -
begin();
2009 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2010 return iterator(_M_data() + __pos);
2013#if __cplusplus >= 201703L
2020 template<
typename _Tp>
2021 _GLIBCXX20_CONSTEXPR
2022 _If_sv<_Tp, basic_string&>
2023 insert(size_type __pos,
const _Tp& __svt)
2025 __sv_type __sv = __svt;
2026 return this->
insert(__pos, __sv.data(), __sv.size());
2037 template<
typename _Tp>
2038 _GLIBCXX20_CONSTEXPR
2039 _If_sv<_Tp, basic_string&>
2040 insert(size_type __pos1,
const _Tp& __svt,
2041 size_type __pos2, size_type __n =
npos)
2043 __sv_type __sv = __svt;
2044 return this->
replace(__pos1, size_type(0),
2046 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2047 std::__sv_limit(__sv.size(), __pos2, __n));
2066 _GLIBCXX20_CONSTEXPR
2068 erase(size_type __pos = 0, size_type __n =
npos)
2070 _M_check(__pos,
"basic_string::erase");
2072 this->_M_set_length(__pos);
2074 this->_M_erase(__pos, _M_limit(__pos, __n));
2086 _GLIBCXX20_CONSTEXPR
2088 erase(__const_iterator __position)
2090 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2091 && __position <
end());
2092 const size_type __pos = __position -
begin();
2093 this->_M_erase(__pos, size_type(1));
2094 return iterator(_M_data() + __pos);
2106 _GLIBCXX20_CONSTEXPR
2108 erase(__const_iterator __first, __const_iterator __last)
2110 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2111 && __last <=
end());
2112 const size_type __pos = __first -
begin();
2113 if (__last ==
end())
2114 this->_M_set_length(__pos);
2116 this->_M_erase(__pos, __last - __first);
2117 return iterator(this->_M_data() + __pos);
2120#if __cplusplus >= 201103L
2126 _GLIBCXX20_CONSTEXPR
2130 __glibcxx_assert(!
empty());
2131 _M_erase(
size() - 1, 1);
2152 _GLIBCXX20_CONSTEXPR
2155 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2175 _GLIBCXX20_CONSTEXPR
2178 size_type __pos2, size_type __n2 =
npos)
2179 {
return this->
replace(__pos1, __n1, __str._M_data()
2180 + __str._M_check(__pos2,
"basic_string::replace"),
2181 __str._M_limit(__pos2, __n2)); }
2201 _GLIBCXX20_CONSTEXPR
2203 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2206 __glibcxx_requires_string_len(__s, __n2);
2207 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2208 _M_limit(__pos, __n1), __s, __n2);
2227 _GLIBCXX20_CONSTEXPR
2229 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2231 __glibcxx_requires_string(__s);
2232 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2252 _GLIBCXX20_CONSTEXPR
2254 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2255 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2256 _M_limit(__pos, __n1), __n2, __c); }
2271 _GLIBCXX20_CONSTEXPR
2273 replace(__const_iterator __i1, __const_iterator __i2,
2275 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2292 _GLIBCXX20_CONSTEXPR
2294 replace(__const_iterator __i1, __const_iterator __i2,
2295 const _CharT* __s, size_type __n)
2297 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2299 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2315 _GLIBCXX20_CONSTEXPR
2317 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2319 __glibcxx_requires_string(__s);
2320 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2337 _GLIBCXX20_CONSTEXPR
2339 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2342 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2344 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2362#if __cplusplus >= 201103L
2363 template<
class _InputIterator,
2364 typename = std::_RequireInputIter<_InputIterator>>
2365 _GLIBCXX20_CONSTEXPR
2367 replace(const_iterator __i1, const_iterator __i2,
2368 _InputIterator __k1, _InputIterator __k2)
2370 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2372 __glibcxx_requires_valid_range(__k1, __k2);
2373 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2374 std::__false_type());
2377 template<
class _InputIterator>
2378#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2379 typename __enable_if_not_native_iterator<_InputIterator>::__type
2383 replace(iterator __i1, iterator __i2,
2384 _InputIterator __k1, _InputIterator __k2)
2386 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2388 __glibcxx_requires_valid_range(__k1, __k2);
2389 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2390 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2396 _GLIBCXX20_CONSTEXPR
2398 replace(__const_iterator __i1, __const_iterator __i2,
2399 _CharT* __k1, _CharT* __k2)
2401 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2403 __glibcxx_requires_valid_range(__k1, __k2);
2408 _GLIBCXX20_CONSTEXPR
2410 replace(__const_iterator __i1, __const_iterator __i2,
2411 const _CharT* __k1,
const _CharT* __k2)
2413 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2415 __glibcxx_requires_valid_range(__k1, __k2);
2420 _GLIBCXX20_CONSTEXPR
2422 replace(__const_iterator __i1, __const_iterator __i2,
2423 iterator __k1, iterator __k2)
2425 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2427 __glibcxx_requires_valid_range(__k1, __k2);
2429 __k1.base(), __k2 - __k1);
2432 _GLIBCXX20_CONSTEXPR
2434 replace(__const_iterator __i1, __const_iterator __i2,
2435 const_iterator __k1, const_iterator __k2)
2437 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2439 __glibcxx_requires_valid_range(__k1, __k2);
2441 __k1.base(), __k2 - __k1);
2444#if __cplusplus >= 201103L
2459 _GLIBCXX20_CONSTEXPR
2461 initializer_list<_CharT> __l)
2462 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2465#if __cplusplus >= 201703L
2473 template<
typename _Tp>
2474 _GLIBCXX20_CONSTEXPR
2475 _If_sv<_Tp, basic_string&>
2476 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2478 __sv_type __sv = __svt;
2479 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2491 template<
typename _Tp>
2492 _GLIBCXX20_CONSTEXPR
2493 _If_sv<_Tp, basic_string&>
2494 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2495 size_type __pos2, size_type __n2 =
npos)
2497 __sv_type __sv = __svt;
2498 return this->
replace(__pos1, __n1,
2500 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2501 std::__sv_limit(__sv.size(), __pos2, __n2));
2513 template<
typename _Tp>
2514 _GLIBCXX20_CONSTEXPR
2515 _If_sv<_Tp, basic_string&>
2516 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2518 __sv_type __sv = __svt;
2519 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2524 template<
class _Integer>
2525 _GLIBCXX20_CONSTEXPR
2527 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2528 _Integer __n, _Integer __val, __true_type)
2529 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2531 template<
class _InputIterator>
2532 _GLIBCXX20_CONSTEXPR
2534 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2535 _InputIterator __k1, _InputIterator __k2,
2538 _GLIBCXX20_CONSTEXPR
2540 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2543 __attribute__((__noinline__, __noclone__, __cold__))
void
2544 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2545 const size_type __len2,
const size_type __how_much);
2547 _GLIBCXX20_CONSTEXPR
2549 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2550 const size_type __len2);
2552 _GLIBCXX20_CONSTEXPR
2554 _M_append(
const _CharT* __s, size_type __n);
2570 _GLIBCXX20_CONSTEXPR
2572 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2581 _GLIBCXX20_CONSTEXPR
2592 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2594 c_str() const _GLIBCXX_NOEXCEPT
2595 {
return _M_data(); }
2605 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2607 data() const _GLIBCXX_NOEXCEPT
2608 {
return _M_data(); }
2610#if __cplusplus >= 201703L
2617 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2620 {
return _M_data(); }
2626 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2629 {
return _M_get_allocator(); }
2643 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2645 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2658 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2662 {
return this->
find(__str.data(), __pos, __str.size()); }
2664#if __cplusplus >= 201703L
2671 template<
typename _Tp>
2672 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2673 _If_sv<_Tp, size_type>
2674 find(
const _Tp& __svt, size_type __pos = 0) const
2675 noexcept(is_same<_Tp, __sv_type>::value)
2677 __sv_type __sv = __svt;
2678 return this->
find(__sv.data(), __pos, __sv.size());
2692 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2694 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2696 __glibcxx_requires_string(__s);
2697 return this->
find(__s, __pos, traits_type::length(__s));
2710 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2712 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2724 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2728 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2730#if __cplusplus >= 201703L
2737 template<
typename _Tp>
2738 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2739 _If_sv<_Tp, size_type>
2740 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2741 noexcept(is_same<_Tp, __sv_type>::value)
2743 __sv_type __sv = __svt;
2744 return this->
rfind(__sv.data(), __pos, __sv.size());
2760 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2762 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2775 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2777 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2779 __glibcxx_requires_string(__s);
2780 return this->
rfind(__s, __pos, traits_type::length(__s));
2793 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2795 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2808 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2812 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2814#if __cplusplus >= 201703L
2822 template<
typename _Tp>
2823 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2824 _If_sv<_Tp, size_type>
2826 noexcept(is_same<_Tp, __sv_type>::value)
2828 __sv_type __sv = __svt;
2829 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2845 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2847 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2860 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2865 __glibcxx_requires_string(__s);
2866 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2881 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2883 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2884 {
return this->
find(__c, __pos); }
2897 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2901 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2903#if __cplusplus >= 201703L
2911 template<
typename _Tp>
2912 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2913 _If_sv<_Tp, size_type>
2915 noexcept(is_same<_Tp, __sv_type>::value)
2917 __sv_type __sv = __svt;
2918 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2934 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2936 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2949 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2954 __glibcxx_requires_string(__s);
2955 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2970 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2973 {
return this->
rfind(__c, __pos); }
2985 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2991#if __cplusplus >= 201703L
2999 template<
typename _Tp>
3000 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3001 _If_sv<_Tp, size_type>
3003 noexcept(is_same<_Tp, __sv_type>::value)
3005 __sv_type __sv = __svt;
3022 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3025 size_type __n)
const _GLIBCXX_NOEXCEPT;
3037 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3042 __glibcxx_requires_string(__s);
3056 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3072 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3078#if __cplusplus >= 201703L
3086 template<
typename _Tp>
3087 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3088 _If_sv<_Tp, size_type>
3090 noexcept(is_same<_Tp, __sv_type>::value)
3092 __sv_type __sv = __svt;
3109 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3112 size_type __n)
const _GLIBCXX_NOEXCEPT;
3124 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3129 __glibcxx_requires_string(__s);
3143 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3160 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3162 substr(size_type __pos = 0, size_type __n =
npos)
const
3164 _M_check(__pos,
"basic_string::substr"), __n); }
3180 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3184 const size_type __size = this->
size();
3185 const size_type __osize = __str.size();
3186 const size_type __len =
std::min(__size, __osize);
3188 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3190 __r = _S_compare(__size, __osize);
3194#if __cplusplus >= 201703L
3200 template<
typename _Tp>
3201 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3203 compare(
const _Tp& __svt)
const
3204 noexcept(is_same<_Tp, __sv_type>::value)
3206 __sv_type __sv = __svt;
3207 const size_type __size = this->
size();
3208 const size_type __osize = __sv.size();
3209 const size_type __len =
std::min(__size, __osize);
3211 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3213 __r = _S_compare(__size, __osize);
3225 template<
typename _Tp>
3226 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3228 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3229 noexcept(is_same<_Tp, __sv_type>::value)
3231 __sv_type __sv = __svt;
3232 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3245 template<
typename _Tp>
3246 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3248 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3249 size_type __pos2, size_type __n2 =
npos)
const
3250 noexcept(is_same<_Tp, __sv_type>::value)
3252 __sv_type __sv = __svt;
3253 return __sv_type(*
this)
3254 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3277 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3281 _M_check(__pos,
"basic_string::compare");
3282 __n = _M_limit(__pos, __n);
3283 const size_type __osize = __str.size();
3284 const size_type __len =
std::min(__n, __osize);
3285 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3287 __r = _S_compare(__n, __osize);
3314 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3317 size_type __pos2, size_type __n2 =
npos)
const
3319 _M_check(__pos1,
"basic_string::compare");
3320 __str._M_check(__pos2,
"basic_string::compare");
3321 __n1 = _M_limit(__pos1, __n1);
3322 __n2 = __str._M_limit(__pos2, __n2);
3323 const size_type __len =
std::min(__n1, __n2);
3324 int __r = traits_type::compare(_M_data() + __pos1,
3325 __str.data() + __pos2, __len);
3327 __r = _S_compare(__n1, __n2);
3345 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3347 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3349 __glibcxx_requires_string(__s);
3350 const size_type __size = this->
size();
3351 const size_type __osize = traits_type::length(__s);
3352 const size_type __len =
std::min(__size, __osize);
3353 int __r = traits_type::compare(_M_data(), __s, __len);
3355 __r = _S_compare(__size, __osize);
3380 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3382 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3384 __glibcxx_requires_string(__s);
3385 _M_check(__pos,
"basic_string::compare");
3386 __n1 = _M_limit(__pos, __n1);
3387 const size_type __osize = traits_type::length(__s);
3388 const size_type __len =
std::min(__n1, __osize);
3389 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3391 __r = _S_compare(__n1, __osize);
3419 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3421 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3422 size_type __n2)
const
3424 __glibcxx_requires_string_len(__s, __n2);
3425 _M_check(__pos,
"basic_string::compare");
3426 __n1 = _M_limit(__pos, __n1);
3427 const size_type __len =
std::min(__n1, __n2);
3428 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3430 __r = _S_compare(__n1, __n2);
3434#if __cplusplus >= 202002L
3437 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3438 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3442 starts_with(_CharT __x)
const noexcept
3443 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3445 [[nodiscard, __gnu__::__nonnull__]]
3447 starts_with(
const _CharT* __x)
const noexcept
3448 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3452 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3453 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3457 ends_with(_CharT __x)
const noexcept
3458 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3460 [[nodiscard, __gnu__::__nonnull__]]
3462 ends_with(
const _CharT* __x)
const noexcept
3463 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3466#if __cplusplus > 202002L
3469 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3470 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3474 contains(_CharT __x)
const noexcept
3475 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3477 [[nodiscard, __gnu__::__nonnull__]]
3479 contains(
const _CharT* __x)
const noexcept
3480 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3484 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3486_GLIBCXX_END_NAMESPACE_CXX11
3487_GLIBCXX_END_NAMESPACE_VERSION
3491namespace std _GLIBCXX_VISIBILITY(default)
3493_GLIBCXX_BEGIN_NAMESPACE_VERSION
3495#if __cpp_deduction_guides >= 201606
3496_GLIBCXX_BEGIN_NAMESPACE_CXX11
3497 template<
typename _InputIterator,
typename _CharT
3498 =
typename iterator_traits<_InputIterator>::value_type,
3499 typename _Allocator = allocator<_CharT>,
3500 typename = _RequireInputIter<_InputIterator>,
3501 typename = _RequireAllocator<_Allocator>>
3502 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3503 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3507 template<
typename _CharT,
typename _Traits,
3508 typename _Allocator = allocator<_CharT>,
3509 typename = _RequireAllocator<_Allocator>>
3510 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3511 -> basic_string<_CharT, _Traits, _Allocator>;
3513 template<
typename _CharT,
typename _Traits,
3514 typename _Allocator = allocator<_CharT>,
3515 typename = _RequireAllocator<_Allocator>>
3516 basic_string(basic_string_view<_CharT, _Traits>,
3517 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3518 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3519 const _Allocator& = _Allocator())
3520 -> basic_string<_CharT, _Traits, _Allocator>;
3521_GLIBCXX_END_NAMESPACE_CXX11
3524 template<
typename _Str>
3525 _GLIBCXX20_CONSTEXPR
3527 __str_concat(
typename _Str::value_type
const* __lhs,
3528 typename _Str::size_type __lhs_len,
3529 typename _Str::value_type
const* __rhs,
3530 typename _Str::size_type __rhs_len,
3531 typename _Str::allocator_type
const& __a)
3533 typedef typename _Str::allocator_type allocator_type;
3535 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3536 __str.reserve(__lhs_len + __rhs_len);
3537 __str.append(__lhs, __lhs_len);
3538 __str.append(__rhs, __rhs_len);
3549 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3550 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3551 inline basic_string<_CharT, _Traits, _Alloc>
3556 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3557 __rhs.c_str(), __rhs.size(),
3558 __lhs.get_allocator());
3567 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3568 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3569 inline basic_string<_CharT,_Traits,_Alloc>
3573 __glibcxx_requires_string(__lhs);
3575 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3576 __rhs.c_str(), __rhs.size(),
3577 __rhs.get_allocator());
3586 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3587 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3588 inline basic_string<_CharT,_Traits,_Alloc>
3592 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3593 __rhs.c_str(), __rhs.size(),
3594 __rhs.get_allocator());
3603 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3604 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3605 inline basic_string<_CharT, _Traits, _Alloc>
3607 const _CharT* __rhs)
3609 __glibcxx_requires_string(__rhs);
3611 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3612 __rhs, _Traits::length(__rhs),
3613 __lhs.get_allocator());
3621 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3622 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3623 inline basic_string<_CharT, _Traits, _Alloc>
3627 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3628 __builtin_addressof(__rhs), 1,
3629 __lhs.get_allocator());
3632#if __cplusplus >= 201103L
3633 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3634 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3635 inline basic_string<_CharT, _Traits, _Alloc>
3636 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3637 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3638 {
return std::move(__lhs.append(__rhs)); }
3640 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3641 _GLIBCXX20_CONSTEXPR
3642 inline basic_string<_CharT, _Traits, _Alloc>
3643 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3644 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3645 {
return std::move(__rhs.insert(0, __lhs)); }
3647 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3648 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3649 inline basic_string<_CharT, _Traits, _Alloc>
3650 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3651 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3653#if _GLIBCXX_USE_CXX11_ABI
3654 using _Alloc_traits = allocator_traits<_Alloc>;
3655 bool __use_rhs =
false;
3656 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3658 else if (__lhs.get_allocator() == __rhs.get_allocator())
3663 const auto __size = __lhs.size() + __rhs.size();
3664 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3665 return std::move(__rhs.insert(0, __lhs));
3670 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3671 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3672 inline basic_string<_CharT, _Traits, _Alloc>
3674 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3675 {
return std::move(__rhs.insert(0, __lhs)); }
3677 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3678 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3679 inline basic_string<_CharT, _Traits, _Alloc>
3681 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3682 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3684 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3685 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3686 inline basic_string<_CharT, _Traits, _Alloc>
3687 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3688 const _CharT* __rhs)
3689 {
return std::move(__lhs.append(__rhs)); }
3691 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3692 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3693 inline basic_string<_CharT, _Traits, _Alloc>
3694 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3696 {
return std::move(__lhs.append(1, __rhs)); }
3706 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3707 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3713 return __lhs.size() == __rhs.size()
3714 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3723 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3724 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3727 const _CharT* __rhs)
3729 return __lhs.size() == _Traits::length(__rhs)
3730 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3733#if __cpp_lib_three_way_comparison
3741 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3744 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3745 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3746 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3747 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3756 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3759 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3760 const _CharT* __rhs)
noexcept
3761 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3762 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3770 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3773 operator==(
const _CharT* __lhs,
3775 {
return __rhs == __lhs; }
3784 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3790 {
return !(__lhs == __rhs); }
3798 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3801 operator!=(
const _CharT* __lhs,
3803 {
return !(__rhs == __lhs); }
3811 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3815 const _CharT* __rhs)
3816 {
return !(__lhs == __rhs); }
3825 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3831 {
return __lhs.compare(__rhs) < 0; }
3839 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3843 const _CharT* __rhs)
3844 {
return __lhs.compare(__rhs) < 0; }
3852 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3855 operator<(
const _CharT* __lhs,
3857 {
return __rhs.compare(__lhs) > 0; }
3866 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3872 {
return __lhs.compare(__rhs) > 0; }
3880 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3884 const _CharT* __rhs)
3885 {
return __lhs.compare(__rhs) > 0; }
3893 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3896 operator>(
const _CharT* __lhs,
3898 {
return __rhs.compare(__lhs) < 0; }
3907 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3913 {
return __lhs.compare(__rhs) <= 0; }
3921 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3925 const _CharT* __rhs)
3926 {
return __lhs.compare(__rhs) <= 0; }
3934 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3937 operator<=(
const _CharT* __lhs,
3939 {
return __rhs.compare(__lhs) >= 0; }
3948 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3954 {
return __lhs.compare(__rhs) >= 0; }
3962 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3966 const _CharT* __rhs)
3967 {
return __lhs.compare(__rhs) >= 0; }
3975 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3978 operator>=(
const _CharT* __lhs,
3980 {
return __rhs.compare(__lhs) <= 0; }
3990 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3991 _GLIBCXX20_CONSTEXPR
3995 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
3996 { __lhs.swap(__rhs); }
4011 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4012 basic_istream<_CharT, _Traits>&
4013 operator>>(basic_istream<_CharT, _Traits>& __is,
4014 basic_string<_CharT, _Traits, _Alloc>& __str);
4017 basic_istream<char>&
4029 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4036 return __ostream_insert(__os, __str.data(), __str.size());
4052 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4053 basic_istream<_CharT, _Traits>&
4054 getline(basic_istream<_CharT, _Traits>& __is,
4055 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4069 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4070 inline basic_istream<_CharT, _Traits>&
4075#if __cplusplus >= 201103L
4077 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4078 inline basic_istream<_CharT, _Traits>&
4084 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4085 inline basic_istream<_CharT, _Traits>&
4092 basic_istream<char>&
4093 getline(basic_istream<char>& __in, basic_string<char>& __str,
4096#ifdef _GLIBCXX_USE_WCHAR_T
4098 basic_istream<wchar_t>&
4099 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4103_GLIBCXX_END_NAMESPACE_VERSION
4106#if __cplusplus >= 201103L
4111namespace std _GLIBCXX_VISIBILITY(default)
4113_GLIBCXX_BEGIN_NAMESPACE_VERSION
4114_GLIBCXX_BEGIN_NAMESPACE_CXX11
4116#if _GLIBCXX_USE_C99_STDLIB
4119 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4120 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4124 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4125 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4128 inline unsigned long
4129 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4130 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4134 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4135 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4138 inline unsigned long long
4139 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4140 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4145 stof(
const string& __str,
size_t* __idx = 0)
4146 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4149 stod(
const string& __str,
size_t* __idx = 0)
4150 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4153 stold(
const string& __str,
size_t* __idx = 0)
4154 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4161 to_string(
int __val)
4162#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4166 const bool __neg = __val < 0;
4167 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4168 const auto __len = __detail::__to_chars_len(__uval);
4169 string __str(__neg + __len,
'-');
4170 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4176 to_string(
unsigned __val)
4177#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4181 string __str(__detail::__to_chars_len(__val),
'\0');
4182 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4188 to_string(
long __val)
4189#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4193 const bool __neg = __val < 0;
4194 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4195 const auto __len = __detail::__to_chars_len(__uval);
4196 string __str(__neg + __len,
'-');
4197 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4203 to_string(
unsigned long __val)
4204#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4208 string __str(__detail::__to_chars_len(__val),
'\0');
4209 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4215 to_string(
long long __val)
4217 const bool __neg = __val < 0;
4218 const unsigned long long __uval
4219 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4220 const auto __len = __detail::__to_chars_len(__uval);
4221 string __str(__neg + __len,
'-');
4222 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4228 to_string(
unsigned long long __val)
4230 string __str(__detail::__to_chars_len(__val),
'\0');
4231 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4235#if _GLIBCXX_USE_C99_STDIO
4240 to_string(
float __val)
4243 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4244 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4250 to_string(
double __val)
4253 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4254 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4260 to_string(
long double __val)
4263 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4264 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4269#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4271 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4272 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4276 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4277 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4280 inline unsigned long
4281 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4282 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4286 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4287 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4290 inline unsigned long long
4291 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4292 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4297 stof(
const wstring& __str,
size_t* __idx = 0)
4298 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4301 stod(
const wstring& __str,
size_t* __idx = 0)
4302 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4305 stold(
const wstring& __str,
size_t* __idx = 0)
4306 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4308#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4312 to_wstring(
int __val)
4313 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
4318 to_wstring(
unsigned __val)
4319 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4320 4 *
sizeof(
unsigned),
4325 to_wstring(
long __val)
4326 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
4331 to_wstring(
unsigned long __val)
4332 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4333 4 *
sizeof(
unsigned long),
4338 to_wstring(
long long __val)
4339 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4340 4 *
sizeof(
long long),
4345 to_wstring(
unsigned long long __val)
4346 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4347 4 *
sizeof(
unsigned long long),
4352 to_wstring(
float __val)
4355 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4356 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4362 to_wstring(
double __val)
4365 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4366 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4372 to_wstring(
long double __val)
4375 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4376 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4382_GLIBCXX_END_NAMESPACE_CXX11
4383_GLIBCXX_END_NAMESPACE_VERSION
4388#if __cplusplus >= 201103L
4392namespace std _GLIBCXX_VISIBILITY(default)
4394_GLIBCXX_BEGIN_NAMESPACE_VERSION
4399 template<
typename _CharT,
typename _Alloc,
4400 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4401 struct __str_hash_base
4402 :
public __hash_base<size_t, _StrT>
4406 operator()(
const _StrT& __s)
const noexcept
4407 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4410#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4412 template<
typename _Alloc>
4414 :
public __str_hash_base<char, _Alloc>
4418 template<
typename _Alloc>
4420 :
public __str_hash_base<wchar_t, _Alloc>
4423 template<
typename _Alloc>
4430#ifdef _GLIBCXX_USE_CHAR8_T
4432 template<
typename _Alloc>
4433 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4434 :
public __str_hash_base<char8_t, _Alloc>
4439 template<
typename _Alloc>
4441 :
public __str_hash_base<char16_t, _Alloc>
4445 template<
typename _Alloc>
4447 :
public __str_hash_base<char32_t, _Alloc>
4450#if ! _GLIBCXX_INLINE_VERSION
4456#ifdef _GLIBCXX_USE_CHAR8_T
4457 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4461 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4462 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4467#if __cplusplus >= 201402L
4469#define __cpp_lib_string_udls 201304L
4471 inline namespace literals
4473 inline namespace string_literals
4475#pragma GCC diagnostic push
4476#pragma GCC diagnostic ignored "-Wliteral-suffix"
4478#if __cpp_lib_constexpr_string >= 201907L
4479# define _GLIBCXX_STRING_CONSTEXPR constexpr
4481# define _GLIBCXX_STRING_CONSTEXPR
4484 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4485 inline basic_string<char>
4486 operator""s(
const char* __str,
size_t __len)
4487 {
return basic_string<char>{__str, __len}; }
4489 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4490 inline basic_string<wchar_t>
4491 operator""s(
const wchar_t* __str,
size_t __len)
4492 {
return basic_string<wchar_t>{__str, __len}; }
4494#ifdef _GLIBCXX_USE_CHAR8_T
4495 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4496 inline basic_string<char8_t>
4497 operator""s(
const char8_t* __str,
size_t __len)
4498 {
return basic_string<char8_t>{__str, __len}; }
4501 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4502 inline basic_string<char16_t>
4503 operator""s(
const char16_t* __str,
size_t __len)
4504 {
return basic_string<char16_t>{__str, __len}; }
4506 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4507 inline basic_string<char32_t>
4508 operator""s(
const char32_t* __str,
size_t __len)
4509 {
return basic_string<char32_t>{__str, __len}; }
4511#undef _GLIBCXX_STRING_CONSTEXPR
4512#pragma GCC diagnostic pop
4516#if __cplusplus >= 201703L
4517 namespace __detail::__variant
4519 template<
typename>
struct _Never_valueless_alt;
4523 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4524 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4526 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4527 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4534_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr bool is_constant_evaluated() noexcept
Returns true only when called during constant evaluation.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
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.
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.
char_type widen(char __c) const
Widens characters.
Template class basic_istream.
Template class basic_ostream.
Primary class template hash.
Basis for explicit traits specializations.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
int compare(const basic_string &__str) const
Compare to a string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
void pop_back()
Remove the last character.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void reserve()
Equivalent to shrink_to_fit().
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_reverse_iterator crend() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
bool empty() const noexcept
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
const_iterator cbegin() const noexcept
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string() noexcept
Default constructor creates an empty string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.