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 __cplusplus > 202302L
56#if ! _GLIBCXX_USE_CXX11_ABI
60namespace std _GLIBCXX_VISIBILITY(default)
62_GLIBCXX_BEGIN_NAMESPACE_VERSION
63_GLIBCXX_BEGIN_NAMESPACE_CXX11
85 template<
typename _CharT,
typename _Traits,
typename _Alloc>
88#if __cplusplus >= 202002L
89 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
90 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
91 using _Char_alloc_type = _Alloc;
94 rebind<_CharT>::other _Char_alloc_type;
101 typedef _Traits traits_type;
102 typedef typename _Traits::char_type value_type;
103 typedef _Char_alloc_type allocator_type;
104 typedef typename _Alloc_traits::size_type size_type;
105 typedef typename _Alloc_traits::difference_type difference_type;
106 typedef typename _Alloc_traits::reference reference;
107 typedef typename _Alloc_traits::const_reference const_reference;
108 typedef typename _Alloc_traits::pointer pointer;
109 typedef typename _Alloc_traits::const_pointer const_pointer;
110 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
111 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
117 static const size_type
npos =
static_cast<size_type
>(-1);
121#if __cplusplus < 201103L
122 typedef iterator __const_iterator;
124 typedef const_iterator __const_iterator;
128 static _GLIBCXX20_CONSTEXPR pointer
129 _S_allocate(_Char_alloc_type& __a, size_type __n)
132#if __glibcxx_constexpr_string >= 201907L
135 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
136 if (std::__is_constant_evaluated())
138 for (size_type __i = 0; __i < __n; ++__i)
139 std::construct_at(__builtin_addressof(__p[__i]));
144#if __cplusplus >= 201703L
148 template<
typename _Tp,
typename _Res>
150 __and_<is_convertible<const _Tp&, __sv_type>,
151 __not_<is_convertible<const _Tp*, const basic_string*>>,
152 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
158 _S_to_string_view(__sv_type __svt)
noexcept
167 _GLIBCXX20_CONSTEXPR
explicit
168 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
186 struct _Alloc_hider : allocator_type
188#if __cplusplus < 201103L
189 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
190 : allocator_type(__a), _M_p(__dat) { }
193 _Alloc_hider(pointer __dat,
const _Alloc& __a)
194 : allocator_type(__a), _M_p(__dat) { }
197 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
198 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
204 _Alloc_hider _M_dataplus;
205 size_type _M_string_length;
207 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
211 _CharT _M_local_buf[_S_local_capacity + 1];
212 size_type _M_allocated_capacity;
218 { _M_dataplus._M_p = __p; }
222 _M_length(size_type __length)
223 { _M_string_length = __length; }
228 {
return _M_dataplus._M_p; }
234#if __cplusplus >= 201103L
237 return pointer(_M_local_buf);
243 _M_local_data()
const
245#if __cplusplus >= 201103L
248 return const_pointer(_M_local_buf);
254 _M_capacity(size_type __capacity)
255 { _M_allocated_capacity = __capacity; }
259 _M_set_length(size_type __n)
262 traits_type::assign(_M_data()[__n], _CharT());
269 if (_M_data() == _M_local_data())
271 if (_M_string_length > _S_local_capacity)
272 __builtin_unreachable();
281 _M_create(size_type&, size_type);
288 _M_destroy(_M_allocated_capacity);
293 _M_destroy(size_type __size)
throw()
296#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
299 template<
typename _InIterator>
301 _M_construct_aux(_InIterator __beg, _InIterator __end,
304 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
305 _M_construct(__beg, __end, _Tag());
310 template<
typename _Integer>
312 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
313 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
316 _M_construct_aux_2(size_type __req, _CharT __c)
317 { _M_construct(__req, __c); }
321 template<
typename _InIterator>
324 _M_construct(_InIterator __beg, _InIterator __end,
329 template<
typename _FwdIterator>
332 _M_construct(_FwdIterator __beg, _FwdIterator __end,
337 _M_construct(size_type __req, _CharT __c);
342 {
return _M_dataplus; }
345 const allocator_type&
346 _M_get_allocator()
const
347 {
return _M_dataplus; }
350 __attribute__((__always_inline__))
353 _M_init_local_buf() _GLIBCXX_NOEXCEPT
355#if __glibcxx_is_constant_evaluated
356 if (std::is_constant_evaluated())
357 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
358 _M_local_buf[__i] = _CharT();
362 __attribute__((__always_inline__))
365 _M_use_local_data() _GLIBCXX_NOEXCEPT
367#if __cpp_lib_is_constant_evaluated
370 return _M_local_data();
375#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
378 template<
typename _Tp,
bool _Requires =
379 !__are_same<_Tp, _CharT*>::__value
380 && !__are_same<_Tp, const _CharT*>::__value
381 && !__are_same<_Tp, iterator>::__value
382 && !__are_same<_Tp, const_iterator>::__value>
383 struct __enable_if_not_native_iterator
384 {
typedef basic_string& __type; };
385 template<
typename _Tp>
386 struct __enable_if_not_native_iterator<_Tp, false> { };
391 _M_check(size_type __pos,
const char* __s)
const
393 if (__pos > this->
size())
394 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
395 "this->size() (which is %zu)"),
396 __s, __pos, this->
size());
402 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
405 __throw_length_error(__N(__s));
412 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
414 const bool __testoff = __off < this->
size() - __pos;
415 return __testoff ? __off : this->
size() - __pos;
420 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
422 return (less<const _CharT*>()(__s, _M_data())
423 || less<const _CharT*>()(_M_data() + this->
size(), __s));
430 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
433 traits_type::assign(*__d, *__s);
435 traits_type::copy(__d, __s, __n);
440 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
443 traits_type::assign(*__d, *__s);
445 traits_type::move(__d, __s, __n);
450 _S_assign(_CharT* __d, size_type __n, _CharT __c)
453 traits_type::assign(*__d, __c);
455 traits_type::assign(__d, __n, __c);
460 template<
class _Iterator>
463 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
465 for (; __k1 != __k2; ++__k1, (void)++__p)
466 traits_type::assign(*__p, *__k1);
471 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
472 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
476 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
478 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
482 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
483 { _S_copy(__p, __k1, __k2 - __k1); }
487 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
489 { _S_copy(__p, __k1, __k2 - __k1); }
493 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
495 const difference_type __d = difference_type(__n1 - __n2);
497 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
498 return __gnu_cxx::__numeric_traits<int>::__max;
499 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
500 return __gnu_cxx::__numeric_traits<int>::__min;
511 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
516 _M_erase(size_type __pos, size_type __n);
529 : _M_dataplus(_M_local_data())
541 : _M_dataplus(_M_local_data(), __a)
553 : _M_dataplus(_M_local_data(),
556 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
570 const _Alloc& __a = _Alloc())
571 : _M_dataplus(_M_local_data(), __a)
573 const _CharT* __start = __str._M_data()
574 + __str._M_check(__pos,
"basic_string::basic_string");
575 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
588 : _M_dataplus(_M_local_data())
590 const _CharT* __start = __str._M_data()
591 + __str._M_check(__pos,
"basic_string::basic_string");
592 _M_construct(__start, __start + __str._M_limit(__pos, __n),
605 size_type __n,
const _Alloc& __a)
606 : _M_dataplus(_M_local_data(), __a)
608 const _CharT* __start
609 = __str._M_data() + __str._M_check(__pos,
"string::string");
610 _M_construct(__start, __start + __str._M_limit(__pos, __n),
625 const _Alloc& __a = _Alloc())
626 : _M_dataplus(_M_local_data(), __a)
629 if (__s == 0 && __n > 0)
630 std::__throw_logic_error(__N(
"basic_string: "
631 "construction from null is not valid"));
640#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
643 template<
typename = _RequireAllocator<_Alloc>>
647 : _M_dataplus(_M_local_data(), __a)
651 std::__throw_logic_error(__N(
"basic_string: "
652 "construction from null is not valid"));
653 const _CharT* __end = __s + traits_type::length(__s);
663#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
666 template<
typename = _RequireAllocator<_Alloc>>
670 : _M_dataplus(_M_local_data(), __a)
671 { _M_construct(__n, __c); }
673#if __cplusplus >= 201103L
683 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
685 if (__str._M_is_local())
688 traits_type::copy(_M_local_buf, __str._M_local_buf,
693 _M_data(__str._M_data());
694 _M_capacity(__str._M_allocated_capacity);
700 _M_length(__str.length());
701 __str._M_data(__str._M_use_local_data());
702 __str._M_set_length(0);
712 : _M_dataplus(_M_local_data(), __a)
717 : _M_dataplus(_M_local_data(), __a)
722 noexcept(_Alloc_traits::_S_always_equal())
723 : _M_dataplus(_M_local_data(), __a)
725 if (__str._M_is_local())
728 traits_type::copy(_M_local_buf, __str._M_local_buf,
730 _M_length(__str.length());
731 __str._M_set_length(0);
733 else if (_Alloc_traits::_S_always_equal()
734 || __str.get_allocator() == __a)
736 _M_data(__str._M_data());
737 _M_length(__str.length());
738 _M_capacity(__str._M_allocated_capacity);
739 __str._M_data(__str._M_use_local_data());
740 __str._M_set_length(0);
747#if __cplusplus >= 202100L
758#if __cplusplus >= 201103L
759 template<
typename _InputIterator,
760 typename = std::_RequireInputIter<_InputIterator>>
762 template<
typename _InputIterator>
766 const _Alloc& __a = _Alloc())
767 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
769#if __cplusplus >= 201103L
772 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
773 _M_construct_aux(__beg, __end, _Integral());
777#if __cplusplus >= 201703L
785 template<
typename _Tp,
789 const _Alloc& __a = _Alloc())
797 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
801 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
819 return this->
assign(__str);
829 {
return this->
assign(__s); }
846#if __cplusplus >= 201103L
859 noexcept(_Alloc_traits::_S_nothrow_move())
861 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
862 || _M_get_allocator() == __str._M_get_allocator();
863 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
867 _M_destroy(_M_allocated_capacity);
868 _M_data(_M_local_data());
872 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
874 if (__str._M_is_local())
882 this->_S_copy(_M_data(), __str._M_data(), __str.size());
883 _M_set_length(__str.size());
886 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
889 pointer __data =
nullptr;
890 size_type __capacity;
897 __capacity = _M_allocated_capacity;
900 _M_destroy(_M_allocated_capacity);
903 _M_data(__str._M_data());
904 _M_length(__str.length());
905 _M_capacity(__str._M_allocated_capacity);
908 __str._M_data(__data);
909 __str._M_capacity(__capacity);
912 __str._M_data(__str._M_use_local_data());
928 this->
assign(__l.begin(), __l.size());
933#if __cplusplus >= 201703L
938 template<
typename _Tp>
940 _If_sv<_Tp, basic_string&>
942 {
return this->
assign(__svt); }
958 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
961 {
return iterator(_M_data()); }
967 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
970 {
return const_iterator(_M_data()); }
976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
979 {
return iterator(_M_data() + this->
size()); }
985 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
987 end() const _GLIBCXX_NOEXCEPT
988 {
return const_iterator(_M_data() + this->
size()); }
995 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1005 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1006 const_reverse_iterator
1015 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1025 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1026 const_reverse_iterator
1030#if __cplusplus >= 201103L
1035 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1038 {
return const_iterator(this->_M_data()); }
1044 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1047 {
return const_iterator(this->_M_data() + this->
size()); }
1054 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1055 const_reverse_iterator
1064 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1065 const_reverse_iterator
1074 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1077 {
return _M_string_length; }
1081 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1084 {
return _M_string_length; }
1087 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1102 _GLIBCXX20_CONSTEXPR
1104 resize(size_type __n, _CharT __c);
1116 _GLIBCXX20_CONSTEXPR
1119 { this->
resize(__n, _CharT()); }
1121#if __cplusplus >= 201103L
1122#pragma GCC diagnostic push
1123#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1125 _GLIBCXX20_CONSTEXPR
1129#pragma GCC diagnostic pop
1132#ifdef __glibcxx_string_resize_and_overwrite
1162 template<
typename _Operation>
1164 resize_and_overwrite(size_type __n, _Operation __op);
1167#if __cplusplus >= 201103L
1169 template<
typename _Operation>
1170 _GLIBCXX20_CONSTEXPR
void
1178 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1182 return _M_is_local() ? size_type(_S_local_capacity)
1183 : _M_allocated_capacity;
1203 _GLIBCXX20_CONSTEXPR
1210#if __cplusplus > 201703L
1211 [[deprecated(
"use shrink_to_fit() instead")]]
1213 _GLIBCXX20_CONSTEXPR
1220 _GLIBCXX20_CONSTEXPR
1223 { _M_set_length(0); }
1229 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1232 {
return this->
size() == 0; }
1245 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1249 __glibcxx_assert(__pos <=
size());
1250 return _M_data()[__pos];
1263 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1269 __glibcxx_assert(__pos <=
size());
1271 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1272 return _M_data()[__pos];
1285 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1289 if (__n >= this->
size())
1290 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1291 "(which is %zu) >= this->size() "
1294 return _M_data()[__n];
1307 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1312 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1313 "(which is %zu) >= this->size() "
1316 return _M_data()[__n];
1319#if __cplusplus >= 201103L
1324 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1328 __glibcxx_assert(!
empty());
1336 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1340 __glibcxx_assert(!
empty());
1348 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1352 __glibcxx_assert(!
empty());
1360 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1364 __glibcxx_assert(!
empty());
1375 _GLIBCXX20_CONSTEXPR
1378 {
return this->
append(__str); }
1385 _GLIBCXX20_CONSTEXPR
1388 {
return this->
append(__s); }
1395 _GLIBCXX20_CONSTEXPR
1403#if __cplusplus >= 201103L
1409 _GLIBCXX20_CONSTEXPR
1412 {
return this->
append(__l.begin(), __l.size()); }
1415#if __cplusplus >= 201703L
1421 template<
typename _Tp>
1422 _GLIBCXX20_CONSTEXPR
1423 _If_sv<_Tp, basic_string&>
1425 {
return this->
append(__svt); }
1433 _GLIBCXX20_CONSTEXPR
1436 {
return this->
append(__str._M_data(), __str.size()); }
1451 _GLIBCXX20_CONSTEXPR
1454 {
return this->
append(__str._M_data()
1455 + __str._M_check(__pos,
"basic_string::append"),
1456 __str._M_limit(__pos, __n)); }
1464 _GLIBCXX20_CONSTEXPR
1468 __glibcxx_requires_string_len(__s, __n);
1469 _M_check_length(size_type(0), __n,
"basic_string::append");
1470 return _M_append(__s, __n);
1478 _GLIBCXX20_CONSTEXPR
1482 __glibcxx_requires_string(__s);
1483 const size_type __n = traits_type::length(__s);
1484 _M_check_length(size_type(0), __n,
"basic_string::append");
1485 return _M_append(__s, __n);
1496 _GLIBCXX20_CONSTEXPR
1499 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1501#if __cplusplus >= 201103L
1507 _GLIBCXX20_CONSTEXPR
1510 {
return this->
append(__l.begin(), __l.size()); }
1521#if __cplusplus >= 201103L
1522 template<
class _InputIterator,
1523 typename = std::_RequireInputIter<_InputIterator>>
1524 _GLIBCXX20_CONSTEXPR
1526 template<
class _InputIterator>
1529 append(_InputIterator __first, _InputIterator __last)
1532#if __cplusplus >= 201703L
1538 template<
typename _Tp>
1539 _GLIBCXX20_CONSTEXPR
1540 _If_sv<_Tp, basic_string&>
1544 return this->
append(__sv.data(), __sv.size());
1554 template<
typename _Tp>
1555 _GLIBCXX20_CONSTEXPR
1556 _If_sv<_Tp, basic_string&>
1560 return _M_append(__sv.data()
1561 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1562 std::__sv_limit(__sv.size(), __pos, __n));
1570 _GLIBCXX20_CONSTEXPR
1574 const size_type __size = this->
size();
1576 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1577 traits_type::assign(this->_M_data()[__size], __c);
1578 this->_M_set_length(__size + 1);
1586 _GLIBCXX20_CONSTEXPR
1590#if __cplusplus >= 201103L
1591 if (_Alloc_traits::_S_propagate_on_copy_assign())
1593 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1594 && _M_get_allocator() != __str._M_get_allocator())
1598 if (__str.size() <= _S_local_capacity)
1600 _M_destroy(_M_allocated_capacity);
1601 _M_data(_M_use_local_data());
1606 const auto __len = __str.size();
1607 auto __alloc = __str._M_get_allocator();
1609 auto __ptr = _S_allocate(__alloc, __len + 1);
1610 _M_destroy(_M_allocated_capacity);
1613 _M_set_length(__len);
1616 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1619 this->_M_assign(__str);
1623#if __cplusplus >= 201103L
1632 _GLIBCXX20_CONSTEXPR
1635 noexcept(_Alloc_traits::_S_nothrow_move())
1656 _GLIBCXX20_CONSTEXPR
1659 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1660 + __str._M_check(__pos,
"basic_string::assign"),
1661 __str._M_limit(__pos, __n)); }
1673 _GLIBCXX20_CONSTEXPR
1677 __glibcxx_requires_string_len(__s, __n);
1678 return _M_replace(size_type(0), this->
size(), __s, __n);
1690 _GLIBCXX20_CONSTEXPR
1694 __glibcxx_requires_string(__s);
1695 return _M_replace(size_type(0), this->
size(), __s,
1696 traits_type::length(__s));
1708 _GLIBCXX20_CONSTEXPR
1711 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1721#if __cplusplus >= 201103L
1722#pragma GCC diagnostic push
1723#pragma GCC diagnostic ignored "-Wc++17-extensions"
1724 template<
class _InputIterator,
1725 typename = std::_RequireInputIter<_InputIterator>>
1726 _GLIBCXX20_CONSTEXPR
1728 assign(_InputIterator __first, _InputIterator __last)
1730#if __cplusplus >= 202002L
1731 if constexpr (contiguous_iterator<_InputIterator>
1732 && is_same_v<iter_value_t<_InputIterator>, _CharT>)
1734 if constexpr (__is_one_of<_InputIterator, const_iterator, iterator,
1735 const _CharT*, _CharT*>::value)
1738 __glibcxx_requires_valid_range(__first, __last);
1739 return _M_replace(size_type(0),
size(),
1740 std::__to_address(__first), __last - __first);
1745#pragma GCC diagnostic pop
1747 template<
class _InputIterator>
1749 assign(_InputIterator __first, _InputIterator __last)
1753#if __cplusplus >= 201103L
1759 _GLIBCXX20_CONSTEXPR
1765 const size_type __n = __l.size();
1771 _S_copy(_M_data(), __l.begin(), __n);
1778#if __cplusplus >= 201703L
1784 template<
typename _Tp>
1785 _GLIBCXX20_CONSTEXPR
1786 _If_sv<_Tp, basic_string&>
1790 return this->
assign(__sv.data(), __sv.size());
1800 template<
typename _Tp>
1801 _GLIBCXX20_CONSTEXPR
1802 _If_sv<_Tp, basic_string&>
1806 return _M_replace(size_type(0), this->
size(),
1808 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1809 std::__sv_limit(__sv.size(), __pos, __n));
1813#if __cplusplus >= 201103L
1829 _GLIBCXX20_CONSTEXPR
1831 insert(const_iterator __p, size_type __n, _CharT __c)
1833 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1834 const size_type __pos = __p -
begin();
1835 this->
replace(__p, __p, __n, __c);
1836 return iterator(this->_M_data() + __pos);
1854 { this->
replace(__p, __p, __n, __c); }
1857#if __cplusplus >= 201103L
1872 template<
class _InputIterator,
1873 typename = std::_RequireInputIter<_InputIterator>>
1874 _GLIBCXX20_CONSTEXPR
1876 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1878 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1879 const size_type __pos = __p -
begin();
1880 this->
replace(__p, __p, __beg, __end);
1881 return iterator(this->_M_data() + __pos);
1896 template<
class _InputIterator>
1899 { this->
replace(__p, __p, __beg, __end); }
1902#if __cplusplus >= 201103L
1909 _GLIBCXX20_CONSTEXPR
1912 {
return this->
insert(__p, __l.begin(), __l.end()); }
1914#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1919 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1920 this->
insert(__p -
begin(), __l.begin(), __l.size());
1937 _GLIBCXX20_CONSTEXPR
1940 {
return this->
replace(__pos1, size_type(0),
1941 __str._M_data(), __str.size()); }
1961 _GLIBCXX20_CONSTEXPR
1964 size_type __pos2, size_type __n =
npos)
1965 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1966 + __str._M_check(__pos2,
"basic_string::insert"),
1967 __str._M_limit(__pos2, __n)); }
1985 _GLIBCXX20_CONSTEXPR
1987 insert(size_type __pos,
const _CharT* __s, size_type __n)
1988 {
return this->
replace(__pos, size_type(0), __s, __n); }
2005 _GLIBCXX20_CONSTEXPR
2009 __glibcxx_requires_string(__s);
2010 return this->
replace(__pos, size_type(0), __s,
2011 traits_type::length(__s));
2030 _GLIBCXX20_CONSTEXPR
2032 insert(size_type __pos, size_type __n, _CharT __c)
2033 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2034 size_type(0), __n, __c); }
2049 _GLIBCXX20_CONSTEXPR
2053 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2054 const size_type __pos = __p -
begin();
2055 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2056 return iterator(_M_data() + __pos);
2059#if __cplusplus >= 201703L
2066 template<
typename _Tp>
2067 _GLIBCXX20_CONSTEXPR
2068 _If_sv<_Tp, basic_string&>
2072 return this->
insert(__pos, __sv.data(), __sv.size());
2083 template<
typename _Tp>
2084 _GLIBCXX20_CONSTEXPR
2085 _If_sv<_Tp, basic_string&>
2087 size_type __pos2, size_type __n =
npos)
2090 return this->
replace(__pos1, size_type(0),
2092 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2093 std::__sv_limit(__sv.size(), __pos2, __n));
2112 _GLIBCXX20_CONSTEXPR
2116 _M_check(__pos,
"basic_string::erase");
2118 this->_M_set_length(__pos);
2120 this->_M_erase(__pos, _M_limit(__pos, __n));
2132 _GLIBCXX20_CONSTEXPR
2136 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2137 && __position <
end());
2138 const size_type __pos = __position -
begin();
2139 this->_M_erase(__pos, size_type(1));
2140 return iterator(_M_data() + __pos);
2152 _GLIBCXX20_CONSTEXPR
2154 erase(__const_iterator __first, __const_iterator __last)
2156 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2157 && __last <=
end());
2158 const size_type __pos = __first -
begin();
2159 if (__last ==
end())
2160 this->_M_set_length(__pos);
2162 this->_M_erase(__pos, __last - __first);
2163 return iterator(this->_M_data() + __pos);
2166#if __cplusplus >= 201103L
2172 _GLIBCXX20_CONSTEXPR
2176 __glibcxx_assert(!
empty());
2177 _M_erase(
size() - 1, 1);
2198 _GLIBCXX20_CONSTEXPR
2201 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2221 _GLIBCXX20_CONSTEXPR
2224 size_type __pos2, size_type __n2 =
npos)
2225 {
return this->
replace(__pos1, __n1, __str._M_data()
2226 + __str._M_check(__pos2,
"basic_string::replace"),
2227 __str._M_limit(__pos2, __n2)); }
2247 _GLIBCXX20_CONSTEXPR
2249 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2252 __glibcxx_requires_string_len(__s, __n2);
2253 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2254 _M_limit(__pos, __n1), __s, __n2);
2273 _GLIBCXX20_CONSTEXPR
2275 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2277 __glibcxx_requires_string(__s);
2278 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2298 _GLIBCXX20_CONSTEXPR
2300 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2301 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2302 _M_limit(__pos, __n1), __n2, __c); }
2317 _GLIBCXX20_CONSTEXPR
2319 replace(__const_iterator __i1, __const_iterator __i2,
2321 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2338 _GLIBCXX20_CONSTEXPR
2340 replace(__const_iterator __i1, __const_iterator __i2,
2341 const _CharT* __s, size_type __n)
2343 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2345 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2361 _GLIBCXX20_CONSTEXPR
2363 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2365 __glibcxx_requires_string(__s);
2366 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2383 _GLIBCXX20_CONSTEXPR
2385 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2388 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2390 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2408#if __cplusplus >= 201103L
2409 template<
class _InputIterator,
2410 typename = std::_RequireInputIter<_InputIterator>>
2411 _GLIBCXX20_CONSTEXPR
2414 _InputIterator __k1, _InputIterator __k2)
2416 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2418 __glibcxx_requires_valid_range(__k1, __k2);
2419 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2420 std::__false_type());
2423 template<
class _InputIterator>
2424#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2425 typename __enable_if_not_native_iterator<_InputIterator>::__type
2430 _InputIterator __k1, _InputIterator __k2)
2432 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2434 __glibcxx_requires_valid_range(__k1, __k2);
2435 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2436 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2442 _GLIBCXX20_CONSTEXPR
2444 replace(__const_iterator __i1, __const_iterator __i2,
2445 _CharT* __k1, _CharT* __k2)
2447 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2449 __glibcxx_requires_valid_range(__k1, __k2);
2454 _GLIBCXX20_CONSTEXPR
2456 replace(__const_iterator __i1, __const_iterator __i2,
2457 const _CharT* __k1,
const _CharT* __k2)
2459 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2461 __glibcxx_requires_valid_range(__k1, __k2);
2466 _GLIBCXX20_CONSTEXPR
2468 replace(__const_iterator __i1, __const_iterator __i2,
2469 iterator __k1, iterator __k2)
2471 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2473 __glibcxx_requires_valid_range(__k1, __k2);
2475 __k1.base(), __k2 - __k1);
2478 _GLIBCXX20_CONSTEXPR
2480 replace(__const_iterator __i1, __const_iterator __i2,
2481 const_iterator __k1, const_iterator __k2)
2483 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2485 __glibcxx_requires_valid_range(__k1, __k2);
2487 __k1.base(), __k2 - __k1);
2490#if __cplusplus >= 201103L
2505 _GLIBCXX20_CONSTEXPR
2508 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2511#if __cplusplus >= 201703L
2519 template<
typename _Tp>
2520 _GLIBCXX20_CONSTEXPR
2521 _If_sv<_Tp, basic_string&>
2522 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2525 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2537 template<
typename _Tp>
2538 _GLIBCXX20_CONSTEXPR
2539 _If_sv<_Tp, basic_string&>
2540 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2541 size_type __pos2, size_type __n2 =
npos)
2544 return this->
replace(__pos1, __n1,
2546 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2547 std::__sv_limit(__sv.size(), __pos2, __n2));
2559 template<
typename _Tp>
2560 _GLIBCXX20_CONSTEXPR
2561 _If_sv<_Tp, basic_string&>
2562 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2565 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2570 template<
class _Integer>
2571 _GLIBCXX20_CONSTEXPR
2573 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2574 _Integer __n, _Integer __val, __true_type)
2575 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2577 template<
class _InputIterator>
2578 _GLIBCXX20_CONSTEXPR
2580 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2581 _InputIterator __k1, _InputIterator __k2,
2584 _GLIBCXX20_CONSTEXPR
2586 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2589 __attribute__((__noinline__, __noclone__, __cold__))
void
2590 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2591 const size_type __len2,
const size_type __how_much);
2593 _GLIBCXX20_CONSTEXPR
2595 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2596 const size_type __len2);
2598 _GLIBCXX20_CONSTEXPR
2600 _M_append(
const _CharT* __s, size_type __n);
2616 _GLIBCXX20_CONSTEXPR
2618 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2627 _GLIBCXX20_CONSTEXPR
2638 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2641 {
return _M_data(); }
2651 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2654 {
return _M_data(); }
2656#if __cplusplus >= 201703L
2663 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2666 {
return _M_data(); }
2672 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2675 {
return _M_get_allocator(); }
2689 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2691 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2704 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2708 {
return this->
find(__str.data(), __pos, __str.size()); }
2710#if __cplusplus >= 201703L
2717 template<
typename _Tp>
2718 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2719 _If_sv<_Tp, size_type>
2720 find(
const _Tp& __svt, size_type __pos = 0) const
2724 return this->
find(__sv.data(), __pos, __sv.size());
2738 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2740 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2742 __glibcxx_requires_string(__s);
2743 return this->
find(__s, __pos, traits_type::length(__s));
2756 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2758 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2770 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2774 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2776#if __cplusplus >= 201703L
2783 template<
typename _Tp>
2784 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2785 _If_sv<_Tp, size_type>
2790 return this->
rfind(__sv.data(), __pos, __sv.size());
2806 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2808 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2821 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2825 __glibcxx_requires_string(__s);
2826 return this->
rfind(__s, __pos, traits_type::length(__s));
2839 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2841 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2854 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2858 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2860#if __cplusplus >= 201703L
2868 template<
typename _Tp>
2869 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2870 _If_sv<_Tp, size_type>
2875 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2891 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2893 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2906 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2911 __glibcxx_requires_string(__s);
2912 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2927 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2930 {
return this->
find(__c, __pos); }
2943 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2947 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2949#if __cplusplus >= 201703L
2957 template<
typename _Tp>
2958 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2959 _If_sv<_Tp, size_type>
2964 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2980 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2982 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2995 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3000 __glibcxx_requires_string(__s);
3001 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3016 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3019 {
return this->
rfind(__c, __pos); }
3031 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3037#if __cplusplus >= 201703L
3045 template<
typename _Tp>
3046 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3047 _If_sv<_Tp, size_type>
3068 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3071 size_type __n)
const _GLIBCXX_NOEXCEPT;
3083 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3088 __glibcxx_requires_string(__s);
3102 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3118 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3124#if __cplusplus >= 201703L
3132 template<
typename _Tp>
3133 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3134 _If_sv<_Tp, size_type>
3155 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3158 size_type __n)
const _GLIBCXX_NOEXCEPT;
3170 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3175 __glibcxx_requires_string(__s);
3189 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3206 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3210 _M_check(__pos,
"basic_string::substr"), __n); }
3226 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3230 const size_type __size = this->
size();
3231 const size_type __osize = __str.size();
3232 const size_type __len =
std::min(__size, __osize);
3234 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3236 __r = _S_compare(__size, __osize);
3240#if __cplusplus >= 201703L
3246 template<
typename _Tp>
3247 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3253 const size_type __size = this->
size();
3254 const size_type __osize = __sv.size();
3255 const size_type __len =
std::min(__size, __osize);
3257 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3259 __r = _S_compare(__size, __osize);
3271 template<
typename _Tp>
3272 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3274 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3278 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3291 template<
typename _Tp>
3292 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3294 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3295 size_type __pos2, size_type __n2 =
npos)
const
3300 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3323 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3327 _M_check(__pos,
"basic_string::compare");
3328 __n = _M_limit(__pos, __n);
3329 const size_type __osize = __str.size();
3330 const size_type __len =
std::min(__n, __osize);
3331 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3333 __r = _S_compare(__n, __osize);
3360 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3363 size_type __pos2, size_type __n2 =
npos)
const
3365 _M_check(__pos1,
"basic_string::compare");
3366 __str._M_check(__pos2,
"basic_string::compare");
3367 __n1 = _M_limit(__pos1, __n1);
3368 __n2 = __str._M_limit(__pos2, __n2);
3369 const size_type __len =
std::min(__n1, __n2);
3370 int __r = traits_type::compare(_M_data() + __pos1,
3371 __str.data() + __pos2, __len);
3373 __r = _S_compare(__n1, __n2);
3391 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3393 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3395 __glibcxx_requires_string(__s);
3396 const size_type __size = this->
size();
3397 const size_type __osize = traits_type::length(__s);
3398 const size_type __len =
std::min(__size, __osize);
3399 int __r = traits_type::compare(_M_data(), __s, __len);
3401 __r = _S_compare(__size, __osize);
3426 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3428 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3430 __glibcxx_requires_string(__s);
3431 _M_check(__pos,
"basic_string::compare");
3432 __n1 = _M_limit(__pos, __n1);
3433 const size_type __osize = traits_type::length(__s);
3434 const size_type __len =
std::min(__n1, __osize);
3435 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3437 __r = _S_compare(__n1, __osize);
3465 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3467 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3468 size_type __n2)
const
3470 __glibcxx_requires_string_len(__s, __n2);
3471 _M_check(__pos,
"basic_string::compare");
3472 __n1 = _M_limit(__pos, __n1);
3473 const size_type __len =
std::min(__n1, __n2);
3474 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3476 __r = _S_compare(__n1, __n2);
3480#if __cplusplus >= 202002L
3484 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3488 starts_with(_CharT __x)
const noexcept
3489 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3491 [[nodiscard, __gnu__::__nonnull__]]
3493 starts_with(
const _CharT* __x)
const noexcept
3494 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3498 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3499 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3503 ends_with(_CharT __x)
const noexcept
3504 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3506 [[nodiscard, __gnu__::__nonnull__]]
3508 ends_with(
const _CharT* __x)
const noexcept
3509 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3512#if __cplusplus > 202002L
3515 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3516 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3520 contains(_CharT __x)
const noexcept
3521 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3523 [[nodiscard, __gnu__::__nonnull__]]
3525 contains(
const _CharT* __x)
const noexcept
3526 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3530 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3532_GLIBCXX_END_NAMESPACE_CXX11
3533_GLIBCXX_END_NAMESPACE_VERSION
3537namespace std _GLIBCXX_VISIBILITY(default)
3539_GLIBCXX_BEGIN_NAMESPACE_VERSION
3541#if __cpp_deduction_guides >= 201606
3542_GLIBCXX_BEGIN_NAMESPACE_CXX11
3543 template<
typename _InputIterator,
typename _CharT
3544 =
typename iterator_traits<_InputIterator>::value_type,
3545 typename _Allocator = allocator<_CharT>,
3546 typename = _RequireInputIter<_InputIterator>,
3547 typename = _RequireAllocator<_Allocator>>
3548 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3549 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3553 template<
typename _CharT,
typename _Traits,
3554 typename _Allocator = allocator<_CharT>,
3555 typename = _RequireAllocator<_Allocator>>
3556 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3557 -> basic_string<_CharT, _Traits, _Allocator>;
3559 template<
typename _CharT,
typename _Traits,
3560 typename _Allocator = allocator<_CharT>,
3561 typename = _RequireAllocator<_Allocator>>
3562 basic_string(basic_string_view<_CharT, _Traits>,
3563 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3564 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3565 const _Allocator& = _Allocator())
3566 -> basic_string<_CharT, _Traits, _Allocator>;
3567_GLIBCXX_END_NAMESPACE_CXX11
3570 template<
typename _Str>
3571 _GLIBCXX20_CONSTEXPR
3573 __str_concat(
typename _Str::value_type
const* __lhs,
3574 typename _Str::size_type __lhs_len,
3575 typename _Str::value_type
const* __rhs,
3576 typename _Str::size_type __rhs_len,
3577 typename _Str::allocator_type
const& __a)
3579 typedef typename _Str::allocator_type allocator_type;
3581 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3582 __str.reserve(__lhs_len + __rhs_len);
3583 __str.append(__lhs, __lhs_len);
3584 __str.append(__rhs, __rhs_len);
3595 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3596 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3597 inline basic_string<_CharT, _Traits, _Alloc>
3602 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3603 __rhs.c_str(), __rhs.size(),
3604 __lhs.get_allocator());
3613 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3614 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3615 inline basic_string<_CharT,_Traits,_Alloc>
3619 __glibcxx_requires_string(__lhs);
3621 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3622 __rhs.c_str(), __rhs.size(),
3623 __rhs.get_allocator());
3632 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3633 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3634 inline basic_string<_CharT,_Traits,_Alloc>
3638 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3639 __rhs.c_str(), __rhs.size(),
3640 __rhs.get_allocator());
3649 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3650 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3651 inline basic_string<_CharT, _Traits, _Alloc>
3653 const _CharT* __rhs)
3655 __glibcxx_requires_string(__rhs);
3657 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3658 __rhs, _Traits::length(__rhs),
3659 __lhs.get_allocator());
3667 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3668 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3669 inline basic_string<_CharT, _Traits, _Alloc>
3673 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3674 __builtin_addressof(__rhs), 1,
3675 __lhs.get_allocator());
3678#if __cplusplus >= 201103L
3679 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3680 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3681 inline basic_string<_CharT, _Traits, _Alloc>
3682 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3683 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3684 {
return std::move(__lhs.append(__rhs)); }
3686 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3687 _GLIBCXX20_CONSTEXPR
3688 inline basic_string<_CharT, _Traits, _Alloc>
3689 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3690 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3691 {
return std::move(__rhs.insert(0, __lhs)); }
3693 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3694 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3695 inline basic_string<_CharT, _Traits, _Alloc>
3696 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3697 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3699#if _GLIBCXX_USE_CXX11_ABI
3700 using _Alloc_traits = allocator_traits<_Alloc>;
3701 bool __use_rhs =
false;
3702 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3704 else if (__lhs.get_allocator() == __rhs.get_allocator())
3709 const auto __size = __lhs.size() + __rhs.size();
3710 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3711 return std::move(__rhs.insert(0, __lhs));
3716 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3717 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3718 inline basic_string<_CharT, _Traits, _Alloc>
3720 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3721 {
return std::move(__rhs.insert(0, __lhs)); }
3723 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3724 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3725 inline basic_string<_CharT, _Traits, _Alloc>
3727 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3728 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3730 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3731 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3732 inline basic_string<_CharT, _Traits, _Alloc>
3733 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3734 const _CharT* __rhs)
3735 {
return std::move(__lhs.append(__rhs)); }
3737 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3738 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3739 inline basic_string<_CharT, _Traits, _Alloc>
3740 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3742 {
return std::move(__lhs.append(1, __rhs)); }
3752 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3753 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3759 return __lhs.size() == __rhs.size()
3760 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3769 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3770 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3773 const _CharT* __rhs)
3775 return __lhs.size() == _Traits::length(__rhs)
3776 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3779#if __cpp_lib_three_way_comparison
3787 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3792 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3793 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3802 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3806 const _CharT* __rhs)
noexcept
3807 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3808 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3816 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3819 operator==(
const _CharT* __lhs,
3820 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3821 {
return __rhs == __lhs; }
3830 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3833 operator!=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3834 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3836 {
return !(__lhs == __rhs); }
3844 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3847 operator!=(
const _CharT* __lhs,
3848 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3849 {
return !(__rhs == __lhs); }
3857 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3860 operator!=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3861 const _CharT* __rhs)
3862 {
return !(__lhs == __rhs); }
3871 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3874 operator<(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3875 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3877 {
return __lhs.compare(__rhs) < 0; }
3885 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3888 operator<(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3889 const _CharT* __rhs)
3890 {
return __lhs.compare(__rhs) < 0; }
3898 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3902 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3903 {
return __rhs.compare(__lhs) > 0; }
3912 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3915 operator>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3916 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3918 {
return __lhs.compare(__rhs) > 0; }
3926 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3929 operator>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3930 const _CharT* __rhs)
3931 {
return __lhs.compare(__rhs) > 0; }
3939 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3943 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3944 {
return __rhs.compare(__lhs) < 0; }
3953 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3956 operator<=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3957 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3959 {
return __lhs.compare(__rhs) <= 0; }
3967 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3970 operator<=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3971 const _CharT* __rhs)
3972 {
return __lhs.compare(__rhs) <= 0; }
3980 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3984 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3985 {
return __rhs.compare(__lhs) >= 0; }
3994 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3997 operator>=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3998 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4000 {
return __lhs.compare(__rhs) >= 0; }
4008 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4011 operator>=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4012 const _CharT* __rhs)
4013 {
return __lhs.compare(__rhs) >= 0; }
4021 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4025 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4026 {
return __rhs.compare(__lhs) <= 0; }
4036 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4037 _GLIBCXX20_CONSTEXPR
4041 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4042 { __lhs.swap(__rhs); }
4057 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4058 basic_istream<_CharT, _Traits>&
4059 operator>>(basic_istream<_CharT, _Traits>& __is,
4060 basic_string<_CharT, _Traits, _Alloc>& __str);
4063 basic_istream<char>&
4075 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4082 return __ostream_insert(__os, __str.data(), __str.size());
4098 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4099 basic_istream<_CharT, _Traits>&
4100 getline(basic_istream<_CharT, _Traits>& __is,
4101 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4116 inline basic_istream<_CharT, _Traits>&
4121#if __cplusplus >= 201103L
4123 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4124 inline basic_istream<_CharT, _Traits>&
4130 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4131 inline basic_istream<_CharT, _Traits>&
4138 basic_istream<char>&
4139 getline(basic_istream<char>& __in, basic_string<char>& __str,
4142#ifdef _GLIBCXX_USE_WCHAR_T
4144 basic_istream<wchar_t>&
4145 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4149_GLIBCXX_END_NAMESPACE_VERSION
4152#if __cplusplus >= 201103L
4157namespace std _GLIBCXX_VISIBILITY(default)
4159_GLIBCXX_BEGIN_NAMESPACE_VERSION
4160_GLIBCXX_BEGIN_NAMESPACE_CXX11
4164 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4165 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4169 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4170 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4173 inline unsigned long
4174 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4175 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4178#if _GLIBCXX_USE_C99_STDLIB
4180 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4181 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4184 inline unsigned long long
4185 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4186 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4188#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4190 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4191 {
return std::stol(__str, __idx, __base); }
4193 inline unsigned long long
4194 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4195 {
return std::stoul(__str, __idx, __base); }
4199 stod(
const string& __str,
size_t* __idx = 0)
4200 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4202#if _GLIBCXX_HAVE_STRTOF
4205 stof(
const string& __str,
size_t* __idx = 0)
4206 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4209 stof(
const string& __str,
size_t* __idx = 0)
4211 double __d = std::stod(__str, __idx);
4212 if (__builtin_isfinite(__d) && __d != 0.0)
4214 double __abs_d = __builtin_fabs(__d);
4215 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4218 std::__throw_out_of_range(
"stof");
4225#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4227 stold(
const string& __str,
size_t* __idx = 0)
4228 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4229#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4231 stold(
const string& __str,
size_t* __idx = 0)
4232 {
return std::stod(__str, __idx); }
4240 to_string(
int __val)
4241#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4245 const bool __neg = __val < 0;
4246 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4247 const auto __len = __detail::__to_chars_len(__uval);
4249 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4251 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4259 to_string(
unsigned __val)
4260#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4264 const auto __len = __detail::__to_chars_len(__val);
4266 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4267 __detail::__to_chars_10_impl(__p, __n, __val);
4275 to_string(
long __val)
4276#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4280 const bool __neg = __val < 0;
4281 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4282 const auto __len = __detail::__to_chars_len(__uval);
4284 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4286 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4294 to_string(
unsigned long __val)
4295#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4299 const auto __len = __detail::__to_chars_len(__val);
4301 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4302 __detail::__to_chars_10_impl(__p, __n, __val);
4310 to_string(
long long __val)
4312 const bool __neg = __val < 0;
4313 const unsigned long long __uval
4314 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4315 const auto __len = __detail::__to_chars_len(__uval);
4317 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4319 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4327 to_string(
unsigned long long __val)
4329 const auto __len = __detail::__to_chars_len(__val);
4331 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4332 __detail::__to_chars_10_impl(__p, __n, __val);
4338#if __glibcxx_to_string >= 202306L
4342 to_string(
float __val)
4347 __str.resize_and_overwrite(__len,
4348 [__val, &__len] (
char* __p,
size_t __n) {
4349 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4350 if (__err == errc{}) [[likely]]
4355 }
while (__str.empty());
4361 to_string(
double __val)
4366 __str.resize_and_overwrite(__len,
4367 [__val, &__len] (
char* __p,
size_t __n) {
4368 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4369 if (__err == errc{}) [[likely]]
4374 }
while (__str.empty());
4380 to_string(
long double __val)
4385 __str.resize_and_overwrite(__len,
4386 [__val, &__len] (
char* __p,
size_t __n) {
4387 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4388 if (__err == errc{}) [[likely]]
4393 }
while (__str.empty());
4396#elif _GLIBCXX_USE_C99_STDIO
4401 to_string(
float __val)
4404 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4405 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4411 to_string(
double __val)
4414 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4415 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4421 to_string(
long double __val)
4424 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4425 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4430#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4432 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4433 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4437 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4438 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4441 inline unsigned long
4442 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4443 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4447 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4448 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4451 inline unsigned long long
4452 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4453 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4458 stof(
const wstring& __str,
size_t* __idx = 0)
4459 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4462 stod(
const wstring& __str,
size_t* __idx = 0)
4463 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4466 stold(
const wstring& __str,
size_t* __idx = 0)
4467 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4470#ifdef _GLIBCXX_USE_WCHAR_T
4471#pragma GCC diagnostic push
4472#pragma GCC diagnostic ignored "-Wc++17-extensions"
4473 _GLIBCXX20_CONSTEXPR
4475 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4479 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4480 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4482 for (
int __i = 0; __i < __len; ++__i)
4483 __wout[__i] = (
wchar_t) __s[__i];
4488 for (
int __i =
'0'; __i <=
'9'; ++__i)
4489 __wc[__i] = L
'0' + __i;
4514 for (
int __i = 0; __i < __len; ++__i)
4515 __wout[__i] = __wc[(
int)__s[__i]];
4519#if __glibcxx_constexpr_string >= 201907L
4523#if __cplusplus >= 201703L
4524 __to_wstring_numeric(string_view __s)
4526 __to_wstring_numeric(
const string& __s)
4529 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4530 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4531 return wstring(__s.data(), __s.data() + __s.size());
4535 auto __f = __s.data();
4536 __ws.__resize_and_overwrite(__s.size(),
4537 [__f] (
wchar_t* __to,
int __n) {
4538 std::__to_wstring_numeric(__f, __n, __to);
4544#pragma GCC diagnostic pop
4548 to_wstring(
int __val)
4549 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4553 to_wstring(
unsigned __val)
4554 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4558 to_wstring(
long __val)
4559 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4563 to_wstring(
unsigned long __val)
4564 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4568 to_wstring(
long long __val)
4569 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4573 to_wstring(
unsigned long long __val)
4574 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4576#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4579 to_wstring(
float __val)
4580 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4584 to_wstring(
double __val)
4585 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4589 to_wstring(
long double __val)
4590 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4594_GLIBCXX_END_NAMESPACE_CXX11
4595_GLIBCXX_END_NAMESPACE_VERSION
4600#if __cplusplus >= 201103L
4604namespace std _GLIBCXX_VISIBILITY(default)
4606_GLIBCXX_BEGIN_NAMESPACE_VERSION
4611 template<
typename _CharT,
typename _Alloc,
4612 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4613 struct __str_hash_base
4614 :
public __hash_base<size_t, _StrT>
4618 operator()(
const _StrT& __s)
const noexcept
4619 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4622#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4624 template<
typename _Alloc>
4626 :
public __str_hash_base<char, _Alloc>
4630 template<
typename _Alloc>
4632 :
public __str_hash_base<wchar_t, _Alloc>
4635 template<
typename _Alloc>
4642#ifdef _GLIBCXX_USE_CHAR8_T
4644 template<
typename _Alloc>
4645 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4646 :
public __str_hash_base<char8_t, _Alloc>
4651 template<
typename _Alloc>
4653 :
public __str_hash_base<char16_t, _Alloc>
4657 template<
typename _Alloc>
4659 :
public __str_hash_base<char32_t, _Alloc>
4662#if ! _GLIBCXX_INLINE_VERSION
4668#ifdef _GLIBCXX_USE_CHAR8_T
4669 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4673 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4674 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4679#ifdef __glibcxx_string_udls
4680 inline namespace literals
4682 inline namespace string_literals
4684#pragma GCC diagnostic push
4685#pragma GCC diagnostic ignored "-Wliteral-suffix"
4687#if __glibcxx_constexpr_string >= 201907L
4688# define _GLIBCXX_STRING_CONSTEXPR constexpr
4690# define _GLIBCXX_STRING_CONSTEXPR
4693 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4694 inline basic_string<char>
4695 operator""s(
const char* __str,
size_t __len)
4696 {
return basic_string<char>{__str, __len}; }
4698 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4699 inline basic_string<wchar_t>
4700 operator""s(
const wchar_t* __str,
size_t __len)
4701 {
return basic_string<wchar_t>{__str, __len}; }
4703#ifdef _GLIBCXX_USE_CHAR8_T
4704 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4705 inline basic_string<char8_t>
4706 operator""s(
const char8_t* __str,
size_t __len)
4707 {
return basic_string<char8_t>{__str, __len}; }
4710 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4711 inline basic_string<char16_t>
4712 operator""s(
const char16_t* __str,
size_t __len)
4713 {
return basic_string<char16_t>{__str, __len}; }
4715 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4716 inline basic_string<char32_t>
4717 operator""s(
const char32_t* __str,
size_t __len)
4718 {
return basic_string<char32_t>{__str, __len}; }
4720#undef _GLIBCXX_STRING_CONSTEXPR
4721#pragma GCC diagnostic pop
4726#if __cplusplus >= 201703L
4727 namespace __detail::__variant
4729 template<
typename>
struct _Never_valueless_alt;
4733 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4734 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4736 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4737 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4743_GLIBCXX_END_NAMESPACE_VERSION
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
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 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.
A non-owning reference to a string.
Primary class template hash.
is_nothrow_default_constructible
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
static constexpr pointer allocate(_Alloc &__a, size_type __n)
static constexpr size_type max_size(const _Alloc &__a) noexcept
Managing sequences of characters and character-like objects.
constexpr _If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
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 basic_string & append(const basic_string &__str, size_type __pos, size_type __n=npos)
Append a substring.
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 _If_sv< _Tp, basic_string & > append(const _Tp &__svt, size_type __pos, size_type __n=npos)
Append a range of characters from a string_view.
constexpr _If_sv< _Tp, int > compare(size_type __pos, size_type __n, const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
constexpr 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.
constexpr _If_sv< _Tp, int > compare(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
constexpr basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
constexpr const_reverse_iterator rend() const noexcept
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 basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
constexpr void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
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 reference back() noexcept
constexpr _If_sv< _Tp, size_type > find_first_not_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character not in a string_view.
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 _If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
constexpr size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr _If_sv< _Tp, size_type > find_last_not_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character not in a string_view.
constexpr const_reverse_iterator crbegin() const noexcept
constexpr basic_string() noexcept(/*conditional */)
Default constructor creates an empty string.
constexpr _If_sv< _Tp, size_type > find(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a string_view.
constexpr _If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
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 iterator erase(__const_iterator __first, __const_iterator __last)
Remove a range of characters.
constexpr _If_sv< _Tp, basic_string & > replace(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos)
Replace range of characters with string_view.
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 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 _If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
constexpr basic_string & operator=(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Move assign the value of str to this string.
constexpr _If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
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
Find last position of a string.
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 _If_sv< _Tp, size_type > find_last_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character of string.
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 _If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
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(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
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 capacity() const noexcept
constexpr _If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
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.
constexpr basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
static const size_type npos
Value returned by various member functions when they fail.
constexpr size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr _If_sv< _Tp, basic_string & > assign(const _Tp &__svt, size_type __pos, size_type __n=npos)
Set value from a range of characters in a string_view.
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 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 int compare(const basic_string &__str) const
Compare to a string.
constexpr _If_sv< _Tp, size_type > find_first_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character of a string_view.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2) const
Compare substring against a character array.
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 _If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
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.
constexpr _If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
constexpr _If_sv< _Tp, size_type > rfind(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a string_view.
Basis for explicit traits specializations.
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.