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
86 template<
typename _CharT,
typename _Traits,
typename _Alloc>
90 rebind<_CharT>::other _Char_alloc_type;
96 typedef _Traits traits_type;
97 typedef typename _Traits::char_type value_type;
98 typedef _Char_alloc_type allocator_type;
99 typedef typename _Alloc_traits::size_type size_type;
100 typedef typename _Alloc_traits::difference_type difference_type;
101 typedef typename _Alloc_traits::reference reference;
102 typedef typename _Alloc_traits::const_reference const_reference;
103 typedef typename _Alloc_traits::pointer pointer;
104 typedef typename _Alloc_traits::const_pointer const_pointer;
105 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
106 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
112 static const size_type
npos =
static_cast<size_type
>(-1);
116#if __cplusplus < 201103L
117 typedef iterator __const_iterator;
119 typedef const_iterator __const_iterator;
123 static _GLIBCXX20_CONSTEXPR pointer
124 _S_allocate(_Char_alloc_type& __a, size_type __n)
126 pointer __p = _Alloc_traits::allocate(__a, __n);
127#if __cpp_lib_constexpr_string >= 201907L
130 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
131 if (std::__is_constant_evaluated())
133 for (size_type __i = 0; __i < __n; ++__i)
134 std::construct_at(__builtin_addressof(__p[__i]));
139#if __cplusplus >= 201703L
141 typedef basic_string_view<_CharT, _Traits> __sv_type;
143 template<
typename _Tp,
typename _Res>
145 __and_<is_convertible<const _Tp&, __sv_type>,
146 __not_<is_convertible<const _Tp*, const basic_string*>>,
147 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
153 _S_to_string_view(__sv_type __svt)
noexcept
162 _GLIBCXX20_CONSTEXPR
explicit
163 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
181 struct _Alloc_hider : allocator_type
183#if __cplusplus < 201103L
184 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
185 : allocator_type(__a), _M_p(__dat) { }
188 _Alloc_hider(pointer __dat,
const _Alloc& __a)
189 : allocator_type(__a), _M_p(__dat) { }
192 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
193 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
199 _Alloc_hider _M_dataplus;
200 size_type _M_string_length;
202 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
206 _CharT _M_local_buf[_S_local_capacity + 1];
207 size_type _M_allocated_capacity;
213 { _M_dataplus._M_p = __p; }
217 _M_length(size_type __length)
218 { _M_string_length = __length; }
223 {
return _M_dataplus._M_p; }
229#if __cplusplus >= 201103L
232 return pointer(_M_local_buf);
238 _M_local_data()
const
240#if __cplusplus >= 201103L
243 return const_pointer(_M_local_buf);
249 _M_capacity(size_type __capacity)
250 { _M_allocated_capacity = __capacity; }
254 _M_set_length(size_type __n)
257 traits_type::assign(_M_data()[__n], _CharT());
264 if (_M_data() == _M_local_data())
266 if (_M_string_length > _S_local_capacity)
267 __builtin_unreachable();
276 _M_create(size_type&, size_type);
283 _M_destroy(_M_allocated_capacity);
288 _M_destroy(size_type __size)
throw()
289 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
291#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
294 template<
typename _InIterator>
296 _M_construct_aux(_InIterator __beg, _InIterator __end,
299 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
300 _M_construct(__beg, __end, _Tag());
305 template<
typename _Integer>
307 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
308 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
311 _M_construct_aux_2(size_type __req, _CharT __c)
312 { _M_construct(__req, __c); }
316 template<
typename _InIterator>
319 _M_construct(_InIterator __beg, _InIterator __end,
324 template<
typename _FwdIterator>
327 _M_construct(_FwdIterator __beg, _FwdIterator __end,
332 _M_construct(size_type __req, _CharT __c);
337 {
return _M_dataplus; }
340 const allocator_type&
341 _M_get_allocator()
const
342 {
return _M_dataplus; }
345 __attribute__((__always_inline__))
348 _M_init_local_buf() _GLIBCXX_NOEXCEPT
350#if __cpp_lib_is_constant_evaluated
352 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
353 _M_local_buf[__i] = _CharT();
357 __attribute__((__always_inline__))
360 _M_use_local_data() _GLIBCXX_NOEXCEPT
362#if __cpp_lib_is_constant_evaluated
365 return _M_local_data();
370#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
373 template<
typename _Tp,
bool _Requires =
374 !__are_same<_Tp, _CharT*>::__value
375 && !__are_same<_Tp, const _CharT*>::__value
376 && !__are_same<_Tp, iterator>::__value
377 && !__are_same<_Tp, const_iterator>::__value>
378 struct __enable_if_not_native_iterator
379 {
typedef basic_string& __type; };
380 template<
typename _Tp>
381 struct __enable_if_not_native_iterator<_Tp, false> { };
386 _M_check(size_type __pos,
const char* __s)
const
388 if (__pos > this->
size())
389 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
390 "this->size() (which is %zu)"),
391 __s, __pos, this->
size());
397 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
400 __throw_length_error(__N(__s));
407 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
409 const bool __testoff = __off < this->
size() - __pos;
410 return __testoff ? __off : this->
size() - __pos;
415 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
417 return (less<const _CharT*>()(__s, _M_data())
418 || less<const _CharT*>()(_M_data() + this->
size(), __s));
425 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
428 traits_type::assign(*__d, *__s);
430 traits_type::copy(__d, __s, __n);
435 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
438 traits_type::assign(*__d, *__s);
440 traits_type::move(__d, __s, __n);
445 _S_assign(_CharT* __d, size_type __n, _CharT __c)
448 traits_type::assign(*__d, __c);
450 traits_type::assign(__d, __n, __c);
455 template<
class _Iterator>
458 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
460 for (; __k1 != __k2; ++__k1, (void)++__p)
461 traits_type::assign(*__p, *__k1);
466 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
467 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
471 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
473 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
477 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
478 { _S_copy(__p, __k1, __k2 - __k1); }
482 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
484 { _S_copy(__p, __k1, __k2 - __k1); }
488 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
490 const difference_type __d = difference_type(__n1 - __n2);
492 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
493 return __gnu_cxx::__numeric_traits<int>::__max;
494 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
495 return __gnu_cxx::__numeric_traits<int>::__min;
506 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
511 _M_erase(size_type __pos, size_type __n);
523 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
524 : _M_dataplus(_M_local_data())
536 : _M_dataplus(_M_local_data(), __a)
548 : _M_dataplus(_M_local_data(),
549 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
551 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
565 const _Alloc& __a = _Alloc())
566 : _M_dataplus(_M_local_data(), __a)
568 const _CharT* __start = __str._M_data()
569 + __str._M_check(__pos,
"basic_string::basic_string");
570 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
583 : _M_dataplus(_M_local_data())
585 const _CharT* __start = __str._M_data()
586 + __str._M_check(__pos,
"basic_string::basic_string");
587 _M_construct(__start, __start + __str._M_limit(__pos, __n),
600 size_type __n,
const _Alloc& __a)
601 : _M_dataplus(_M_local_data(), __a)
603 const _CharT* __start
604 = __str._M_data() + __str._M_check(__pos,
"string::string");
605 _M_construct(__start, __start + __str._M_limit(__pos, __n),
620 const _Alloc& __a = _Alloc())
621 : _M_dataplus(_M_local_data(), __a)
624 if (__s == 0 && __n > 0)
625 std::__throw_logic_error(__N(
"basic_string: "
626 "construction from null is not valid"));
635#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
638 template<
typename = _RequireAllocator<_Alloc>>
641 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
642 : _M_dataplus(_M_local_data(), __a)
646 std::__throw_logic_error(__N(
"basic_string: "
647 "construction from null is not valid"));
648 const _CharT* __end = __s + traits_type::length(__s);
649 _M_construct(__s, __end, forward_iterator_tag());
658#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
661 template<
typename = _RequireAllocator<_Alloc>>
664 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
665 : _M_dataplus(_M_local_data(), __a)
666 { _M_construct(__n, __c); }
668#if __cplusplus >= 201103L
678 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
680 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_use_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())
723 traits_type::copy(_M_local_buf, __str._M_local_buf,
725 _M_length(__str.length());
726 __str._M_set_length(0);
728 else if (_Alloc_traits::_S_always_equal()
729 || __str.get_allocator() == __a)
731 _M_data(__str._M_data());
732 _M_length(__str.length());
733 _M_capacity(__str._M_allocated_capacity);
734 __str._M_data(__str._M_use_local_data());
735 __str._M_set_length(0);
742#if __cplusplus >= 202100L
753#if __cplusplus >= 201103L
754 template<
typename _InputIterator,
755 typename = std::_RequireInputIter<_InputIterator>>
757 template<
typename _InputIterator>
760 basic_string(_InputIterator __beg, _InputIterator __end,
761 const _Alloc& __a = _Alloc())
762 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
764#if __cplusplus >= 201103L
767 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
768 _M_construct_aux(__beg, __end, _Integral());
772#if __cplusplus >= 201703L
780 template<
typename _Tp,
781 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
783 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
784 const _Alloc& __a = _Alloc())
792 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
795 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
796 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
814 return this->
assign(__str);
824 {
return this->
assign(__s); }
841#if __cplusplus >= 201103L
854 noexcept(_Alloc_traits::_S_nothrow_move())
856 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
857 || _M_get_allocator() == __str._M_get_allocator();
858 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
862 _M_destroy(_M_allocated_capacity);
863 _M_data(_M_local_data());
867 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
869 if (__str._M_is_local())
877 this->_S_copy(_M_data(), __str._M_data(), __str.size());
878 _M_set_length(__str.size());
881 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
884 pointer __data =
nullptr;
885 size_type __capacity;
892 __capacity = _M_allocated_capacity;
895 _M_destroy(_M_allocated_capacity);
898 _M_data(__str._M_data());
899 _M_length(__str.length());
900 _M_capacity(__str._M_allocated_capacity);
903 __str._M_data(__data);
904 __str._M_capacity(__capacity);
907 __str._M_data(__str._M_use_local_data());
923 this->
assign(__l.begin(), __l.size());
928#if __cplusplus >= 201703L
933 template<
typename _Tp>
935 _If_sv<_Tp, basic_string&>
937 {
return this->
assign(__svt); }
944 operator __sv_type() const noexcept
945 {
return __sv_type(
data(),
size()); }
953 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
955 begin() _GLIBCXX_NOEXCEPT
956 {
return iterator(_M_data()); }
962 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
964 begin() const _GLIBCXX_NOEXCEPT
965 {
return const_iterator(_M_data()); }
971 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
973 end() _GLIBCXX_NOEXCEPT
974 {
return iterator(_M_data() + this->
size()); }
980 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
982 end() const _GLIBCXX_NOEXCEPT
983 {
return const_iterator(_M_data() + this->
size()); }
990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
992 rbegin() _GLIBCXX_NOEXCEPT
993 {
return reverse_iterator(this->
end()); }
1000 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1001 const_reverse_iterator
1002 rbegin() const _GLIBCXX_NOEXCEPT
1003 {
return const_reverse_iterator(this->
end()); }
1010 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1012 rend() _GLIBCXX_NOEXCEPT
1013 {
return reverse_iterator(this->
begin()); }
1020 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1021 const_reverse_iterator
1022 rend() const _GLIBCXX_NOEXCEPT
1023 {
return const_reverse_iterator(this->
begin()); }
1025#if __cplusplus >= 201103L
1030 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1033 {
return const_iterator(this->_M_data()); }
1039 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1041 cend() const noexcept
1042 {
return const_iterator(this->_M_data() + this->
size()); }
1049 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1050 const_reverse_iterator
1052 {
return const_reverse_iterator(this->
end()); }
1059 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1060 const_reverse_iterator
1061 crend() const noexcept
1062 {
return const_reverse_iterator(this->
begin()); }
1069 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1071 size() const _GLIBCXX_NOEXCEPT
1072 {
return _M_string_length; }
1076 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1078 length() const _GLIBCXX_NOEXCEPT
1079 {
return _M_string_length; }
1082 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1085 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1097 _GLIBCXX20_CONSTEXPR
1099 resize(size_type __n, _CharT __c);
1111 _GLIBCXX20_CONSTEXPR
1114 { this->
resize(__n, _CharT()); }
1116#if __cplusplus >= 201103L
1117#pragma GCC diagnostic push
1118#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1120 _GLIBCXX20_CONSTEXPR
1124#pragma GCC diagnostic pop
1127#if __cplusplus > 202002L
1128#define __cpp_lib_string_resize_and_overwrite 202110L
1158 template<
typename _Operation>
1160 resize_and_overwrite(size_type __n, _Operation __op);
1167 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1171 return _M_is_local() ? size_type(_S_local_capacity)
1172 : _M_allocated_capacity;
1192 _GLIBCXX20_CONSTEXPR
1199#if __cplusplus > 201703L
1200 [[deprecated(
"use shrink_to_fit() instead")]]
1202 _GLIBCXX20_CONSTEXPR
1209 _GLIBCXX20_CONSTEXPR
1211 clear() _GLIBCXX_NOEXCEPT
1212 { _M_set_length(0); }
1218 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1220 empty() const _GLIBCXX_NOEXCEPT
1221 {
return this->
size() == 0; }
1234 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1236 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1238 __glibcxx_assert(__pos <=
size());
1239 return _M_data()[__pos];
1252 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1258 __glibcxx_assert(__pos <=
size());
1260 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1261 return _M_data()[__pos];
1274 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1276 at(size_type __n)
const
1278 if (__n >= this->
size())
1279 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1280 "(which is %zu) >= this->size() "
1283 return _M_data()[__n];
1296 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1301 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1302 "(which is %zu) >= this->size() "
1305 return _M_data()[__n];
1308#if __cplusplus >= 201103L
1313 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1317 __glibcxx_assert(!
empty());
1325 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1327 front() const noexcept
1329 __glibcxx_assert(!
empty());
1337 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1341 __glibcxx_assert(!
empty());
1349 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1351 back() const noexcept
1353 __glibcxx_assert(!
empty());
1364 _GLIBCXX20_CONSTEXPR
1367 {
return this->
append(__str); }
1374 _GLIBCXX20_CONSTEXPR
1377 {
return this->
append(__s); }
1384 _GLIBCXX20_CONSTEXPR
1392#if __cplusplus >= 201103L
1398 _GLIBCXX20_CONSTEXPR
1401 {
return this->
append(__l.begin(), __l.size()); }
1404#if __cplusplus >= 201703L
1410 template<
typename _Tp>
1411 _GLIBCXX20_CONSTEXPR
1412 _If_sv<_Tp, basic_string&>
1414 {
return this->
append(__svt); }
1422 _GLIBCXX20_CONSTEXPR
1425 {
return this->
append(__str._M_data(), __str.size()); }
1440 _GLIBCXX20_CONSTEXPR
1443 {
return this->
append(__str._M_data()
1444 + __str._M_check(__pos,
"basic_string::append"),
1445 __str._M_limit(__pos, __n)); }
1453 _GLIBCXX20_CONSTEXPR
1455 append(
const _CharT* __s, size_type __n)
1457 __glibcxx_requires_string_len(__s, __n);
1458 _M_check_length(size_type(0), __n,
"basic_string::append");
1459 return _M_append(__s, __n);
1467 _GLIBCXX20_CONSTEXPR
1469 append(
const _CharT* __s)
1471 __glibcxx_requires_string(__s);
1472 const size_type __n = traits_type::length(__s);
1473 _M_check_length(size_type(0), __n,
"basic_string::append");
1474 return _M_append(__s, __n);
1485 _GLIBCXX20_CONSTEXPR
1487 append(size_type __n, _CharT __c)
1488 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1490#if __cplusplus >= 201103L
1496 _GLIBCXX20_CONSTEXPR
1498 append(initializer_list<_CharT> __l)
1499 {
return this->
append(__l.begin(), __l.size()); }
1510#if __cplusplus >= 201103L
1511 template<
class _InputIterator,
1512 typename = std::_RequireInputIter<_InputIterator>>
1513 _GLIBCXX20_CONSTEXPR
1515 template<
class _InputIterator>
1518 append(_InputIterator __first, _InputIterator __last)
1521#if __cplusplus >= 201703L
1527 template<
typename _Tp>
1528 _GLIBCXX20_CONSTEXPR
1529 _If_sv<_Tp, basic_string&>
1532 __sv_type __sv = __svt;
1533 return this->
append(__sv.data(), __sv.size());
1543 template<
typename _Tp>
1544 _GLIBCXX20_CONSTEXPR
1545 _If_sv<_Tp, basic_string&>
1546 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1548 __sv_type __sv = __svt;
1549 return _M_append(__sv.data()
1550 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1551 std::__sv_limit(__sv.size(), __pos, __n));
1559 _GLIBCXX20_CONSTEXPR
1563 const size_type __size = this->
size();
1565 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1566 traits_type::assign(this->_M_data()[__size], __c);
1567 this->_M_set_length(__size + 1);
1575 _GLIBCXX20_CONSTEXPR
1579#if __cplusplus >= 201103L
1580 if (_Alloc_traits::_S_propagate_on_copy_assign())
1582 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1583 && _M_get_allocator() != __str._M_get_allocator())
1587 if (__str.size() <= _S_local_capacity)
1589 _M_destroy(_M_allocated_capacity);
1590 _M_data(_M_use_local_data());
1595 const auto __len = __str.size();
1596 auto __alloc = __str._M_get_allocator();
1598 auto __ptr = _S_allocate(__alloc, __len + 1);
1599 _M_destroy(_M_allocated_capacity);
1602 _M_set_length(__len);
1605 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1608 this->_M_assign(__str);
1612#if __cplusplus >= 201103L
1621 _GLIBCXX20_CONSTEXPR
1624 noexcept(_Alloc_traits::_S_nothrow_move())
1645 _GLIBCXX20_CONSTEXPR
1648 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1649 + __str._M_check(__pos,
"basic_string::assign"),
1650 __str._M_limit(__pos, __n)); }
1662 _GLIBCXX20_CONSTEXPR
1664 assign(
const _CharT* __s, size_type __n)
1666 __glibcxx_requires_string_len(__s, __n);
1667 return _M_replace(size_type(0), this->
size(), __s, __n);
1679 _GLIBCXX20_CONSTEXPR
1681 assign(
const _CharT* __s)
1683 __glibcxx_requires_string(__s);
1684 return _M_replace(size_type(0), this->
size(), __s,
1685 traits_type::length(__s));
1697 _GLIBCXX20_CONSTEXPR
1699 assign(size_type __n, _CharT __c)
1700 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1710#if __cplusplus >= 201103L
1711 template<
class _InputIterator,
1712 typename = std::_RequireInputIter<_InputIterator>>
1713 _GLIBCXX20_CONSTEXPR
1715 template<
class _InputIterator>
1718 assign(_InputIterator __first, _InputIterator __last)
1721#if __cplusplus >= 201103L
1727 _GLIBCXX20_CONSTEXPR
1729 assign(initializer_list<_CharT> __l)
1730 {
return this->
assign(__l.begin(), __l.size()); }
1733#if __cplusplus >= 201703L
1739 template<
typename _Tp>
1740 _GLIBCXX20_CONSTEXPR
1741 _If_sv<_Tp, basic_string&>
1744 __sv_type __sv = __svt;
1745 return this->
assign(__sv.data(), __sv.size());
1755 template<
typename _Tp>
1756 _GLIBCXX20_CONSTEXPR
1757 _If_sv<_Tp, basic_string&>
1758 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1760 __sv_type __sv = __svt;
1761 return _M_replace(size_type(0), this->
size(),
1763 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1764 std::__sv_limit(__sv.size(), __pos, __n));
1768#if __cplusplus >= 201103L
1784 _GLIBCXX20_CONSTEXPR
1786 insert(const_iterator __p, size_type __n, _CharT __c)
1788 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1789 const size_type __pos = __p -
begin();
1790 this->
replace(__p, __p, __n, __c);
1791 return iterator(this->_M_data() + __pos);
1808 insert(iterator __p, size_type __n, _CharT __c)
1809 { this->
replace(__p, __p, __n, __c); }
1812#if __cplusplus >= 201103L
1827 template<
class _InputIterator,
1828 typename = std::_RequireInputIter<_InputIterator>>
1829 _GLIBCXX20_CONSTEXPR
1831 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1833 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1834 const size_type __pos = __p -
begin();
1835 this->
replace(__p, __p, __beg, __end);
1836 return iterator(this->_M_data() + __pos);
1851 template<
class _InputIterator>
1853 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1854 { this->
replace(__p, __p, __beg, __end); }
1857#if __cplusplus >= 201103L
1864 _GLIBCXX20_CONSTEXPR
1866 insert(const_iterator __p, initializer_list<_CharT> __l)
1867 {
return this->
insert(__p, __l.begin(), __l.end()); }
1869#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1872 insert(iterator __p, initializer_list<_CharT> __l)
1874 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1875 this->
insert(__p -
begin(), __l.begin(), __l.size());
1892 _GLIBCXX20_CONSTEXPR
1895 {
return this->
replace(__pos1, size_type(0),
1896 __str._M_data(), __str.size()); }
1916 _GLIBCXX20_CONSTEXPR
1919 size_type __pos2, size_type __n =
npos)
1920 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1921 + __str._M_check(__pos2,
"basic_string::insert"),
1922 __str._M_limit(__pos2, __n)); }
1940 _GLIBCXX20_CONSTEXPR
1942 insert(size_type __pos,
const _CharT* __s, size_type __n)
1943 {
return this->
replace(__pos, size_type(0), __s, __n); }
1960 _GLIBCXX20_CONSTEXPR
1962 insert(size_type __pos,
const _CharT* __s)
1964 __glibcxx_requires_string(__s);
1965 return this->
replace(__pos, size_type(0), __s,
1966 traits_type::length(__s));
1985 _GLIBCXX20_CONSTEXPR
1987 insert(size_type __pos, size_type __n, _CharT __c)
1988 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1989 size_type(0), __n, __c); }
2004 _GLIBCXX20_CONSTEXPR
2006 insert(__const_iterator __p, _CharT __c)
2008 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2009 const size_type __pos = __p -
begin();
2010 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2011 return iterator(_M_data() + __pos);
2014#if __cplusplus >= 201703L
2021 template<
typename _Tp>
2022 _GLIBCXX20_CONSTEXPR
2023 _If_sv<_Tp, basic_string&>
2024 insert(size_type __pos,
const _Tp& __svt)
2026 __sv_type __sv = __svt;
2027 return this->
insert(__pos, __sv.data(), __sv.size());
2038 template<
typename _Tp>
2039 _GLIBCXX20_CONSTEXPR
2040 _If_sv<_Tp, basic_string&>
2041 insert(size_type __pos1,
const _Tp& __svt,
2042 size_type __pos2, size_type __n =
npos)
2044 __sv_type __sv = __svt;
2045 return this->
replace(__pos1, size_type(0),
2047 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2048 std::__sv_limit(__sv.size(), __pos2, __n));
2067 _GLIBCXX20_CONSTEXPR
2069 erase(size_type __pos = 0, size_type __n =
npos)
2071 _M_check(__pos,
"basic_string::erase");
2073 this->_M_set_length(__pos);
2075 this->_M_erase(__pos, _M_limit(__pos, __n));
2087 _GLIBCXX20_CONSTEXPR
2089 erase(__const_iterator __position)
2091 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2092 && __position <
end());
2093 const size_type __pos = __position -
begin();
2094 this->_M_erase(__pos, size_type(1));
2095 return iterator(_M_data() + __pos);
2107 _GLIBCXX20_CONSTEXPR
2109 erase(__const_iterator __first, __const_iterator __last)
2111 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2112 && __last <=
end());
2113 const size_type __pos = __first -
begin();
2114 if (__last ==
end())
2115 this->_M_set_length(__pos);
2117 this->_M_erase(__pos, __last - __first);
2118 return iterator(this->_M_data() + __pos);
2121#if __cplusplus >= 201103L
2127 _GLIBCXX20_CONSTEXPR
2131 __glibcxx_assert(!
empty());
2132 _M_erase(
size() - 1, 1);
2153 _GLIBCXX20_CONSTEXPR
2156 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2176 _GLIBCXX20_CONSTEXPR
2179 size_type __pos2, size_type __n2 =
npos)
2180 {
return this->
replace(__pos1, __n1, __str._M_data()
2181 + __str._M_check(__pos2,
"basic_string::replace"),
2182 __str._M_limit(__pos2, __n2)); }
2202 _GLIBCXX20_CONSTEXPR
2204 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2207 __glibcxx_requires_string_len(__s, __n2);
2208 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2209 _M_limit(__pos, __n1), __s, __n2);
2228 _GLIBCXX20_CONSTEXPR
2230 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2232 __glibcxx_requires_string(__s);
2233 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2253 _GLIBCXX20_CONSTEXPR
2255 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2256 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2257 _M_limit(__pos, __n1), __n2, __c); }
2272 _GLIBCXX20_CONSTEXPR
2274 replace(__const_iterator __i1, __const_iterator __i2,
2276 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2293 _GLIBCXX20_CONSTEXPR
2295 replace(__const_iterator __i1, __const_iterator __i2,
2296 const _CharT* __s, size_type __n)
2298 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2300 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2316 _GLIBCXX20_CONSTEXPR
2318 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2320 __glibcxx_requires_string(__s);
2321 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2338 _GLIBCXX20_CONSTEXPR
2340 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2343 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2345 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2363#if __cplusplus >= 201103L
2364 template<
class _InputIterator,
2365 typename = std::_RequireInputIter<_InputIterator>>
2366 _GLIBCXX20_CONSTEXPR
2368 replace(const_iterator __i1, const_iterator __i2,
2369 _InputIterator __k1, _InputIterator __k2)
2371 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2373 __glibcxx_requires_valid_range(__k1, __k2);
2374 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2375 std::__false_type());
2378 template<
class _InputIterator>
2379#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2380 typename __enable_if_not_native_iterator<_InputIterator>::__type
2384 replace(iterator __i1, iterator __i2,
2385 _InputIterator __k1, _InputIterator __k2)
2387 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2389 __glibcxx_requires_valid_range(__k1, __k2);
2390 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2391 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2397 _GLIBCXX20_CONSTEXPR
2399 replace(__const_iterator __i1, __const_iterator __i2,
2400 _CharT* __k1, _CharT* __k2)
2402 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2404 __glibcxx_requires_valid_range(__k1, __k2);
2409 _GLIBCXX20_CONSTEXPR
2411 replace(__const_iterator __i1, __const_iterator __i2,
2412 const _CharT* __k1,
const _CharT* __k2)
2414 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2416 __glibcxx_requires_valid_range(__k1, __k2);
2421 _GLIBCXX20_CONSTEXPR
2423 replace(__const_iterator __i1, __const_iterator __i2,
2424 iterator __k1, iterator __k2)
2426 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2428 __glibcxx_requires_valid_range(__k1, __k2);
2430 __k1.base(), __k2 - __k1);
2433 _GLIBCXX20_CONSTEXPR
2435 replace(__const_iterator __i1, __const_iterator __i2,
2436 const_iterator __k1, const_iterator __k2)
2438 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2440 __glibcxx_requires_valid_range(__k1, __k2);
2442 __k1.base(), __k2 - __k1);
2445#if __cplusplus >= 201103L
2460 _GLIBCXX20_CONSTEXPR
2462 initializer_list<_CharT> __l)
2463 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2466#if __cplusplus >= 201703L
2474 template<
typename _Tp>
2475 _GLIBCXX20_CONSTEXPR
2476 _If_sv<_Tp, basic_string&>
2477 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2479 __sv_type __sv = __svt;
2480 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2492 template<
typename _Tp>
2493 _GLIBCXX20_CONSTEXPR
2494 _If_sv<_Tp, basic_string&>
2495 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2496 size_type __pos2, size_type __n2 =
npos)
2498 __sv_type __sv = __svt;
2499 return this->
replace(__pos1, __n1,
2501 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2502 std::__sv_limit(__sv.size(), __pos2, __n2));
2514 template<
typename _Tp>
2515 _GLIBCXX20_CONSTEXPR
2516 _If_sv<_Tp, basic_string&>
2517 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2519 __sv_type __sv = __svt;
2520 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2525 template<
class _Integer>
2526 _GLIBCXX20_CONSTEXPR
2528 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2529 _Integer __n, _Integer __val, __true_type)
2530 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2532 template<
class _InputIterator>
2533 _GLIBCXX20_CONSTEXPR
2535 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2536 _InputIterator __k1, _InputIterator __k2,
2539 _GLIBCXX20_CONSTEXPR
2541 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2544 __attribute__((__noinline__, __noclone__, __cold__))
void
2545 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2546 const size_type __len2,
const size_type __how_much);
2548 _GLIBCXX20_CONSTEXPR
2550 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2551 const size_type __len2);
2553 _GLIBCXX20_CONSTEXPR
2555 _M_append(
const _CharT* __s, size_type __n);
2571 _GLIBCXX20_CONSTEXPR
2573 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2582 _GLIBCXX20_CONSTEXPR
2593 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2595 c_str() const _GLIBCXX_NOEXCEPT
2596 {
return _M_data(); }
2606 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2608 data() const _GLIBCXX_NOEXCEPT
2609 {
return _M_data(); }
2611#if __cplusplus >= 201703L
2618 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2621 {
return _M_data(); }
2627 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2630 {
return _M_get_allocator(); }
2644 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2646 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2659 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2663 {
return this->
find(__str.data(), __pos, __str.size()); }
2665#if __cplusplus >= 201703L
2672 template<
typename _Tp>
2673 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2674 _If_sv<_Tp, size_type>
2675 find(
const _Tp& __svt, size_type __pos = 0) const
2676 noexcept(is_same<_Tp, __sv_type>::value)
2678 __sv_type __sv = __svt;
2679 return this->
find(__sv.data(), __pos, __sv.size());
2693 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2695 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2697 __glibcxx_requires_string(__s);
2698 return this->
find(__s, __pos, traits_type::length(__s));
2711 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2713 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2725 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2729 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2731#if __cplusplus >= 201703L
2738 template<
typename _Tp>
2739 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2740 _If_sv<_Tp, size_type>
2741 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2742 noexcept(is_same<_Tp, __sv_type>::value)
2744 __sv_type __sv = __svt;
2745 return this->
rfind(__sv.data(), __pos, __sv.size());
2761 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2763 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2776 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2778 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2780 __glibcxx_requires_string(__s);
2781 return this->
rfind(__s, __pos, traits_type::length(__s));
2794 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2796 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2809 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2813 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2815#if __cplusplus >= 201703L
2823 template<
typename _Tp>
2824 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2825 _If_sv<_Tp, size_type>
2827 noexcept(is_same<_Tp, __sv_type>::value)
2829 __sv_type __sv = __svt;
2830 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2846 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2848 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2861 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2866 __glibcxx_requires_string(__s);
2867 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2882 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2884 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2885 {
return this->
find(__c, __pos); }
2898 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2902 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2904#if __cplusplus >= 201703L
2912 template<
typename _Tp>
2913 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2914 _If_sv<_Tp, size_type>
2916 noexcept(is_same<_Tp, __sv_type>::value)
2918 __sv_type __sv = __svt;
2919 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2935 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2937 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2950 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2955 __glibcxx_requires_string(__s);
2956 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2971 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2974 {
return this->
rfind(__c, __pos); }
2986 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2992#if __cplusplus >= 201703L
3000 template<
typename _Tp>
3001 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3002 _If_sv<_Tp, size_type>
3004 noexcept(is_same<_Tp, __sv_type>::value)
3006 __sv_type __sv = __svt;
3023 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3026 size_type __n)
const _GLIBCXX_NOEXCEPT;
3038 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3043 __glibcxx_requires_string(__s);
3057 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3073 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3079#if __cplusplus >= 201703L
3087 template<
typename _Tp>
3088 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3089 _If_sv<_Tp, size_type>
3091 noexcept(is_same<_Tp, __sv_type>::value)
3093 __sv_type __sv = __svt;
3110 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3113 size_type __n)
const _GLIBCXX_NOEXCEPT;
3125 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3130 __glibcxx_requires_string(__s);
3144 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3161 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3163 substr(size_type __pos = 0, size_type __n =
npos)
const
3165 _M_check(__pos,
"basic_string::substr"), __n); }
3181 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3185 const size_type __size = this->
size();
3186 const size_type __osize = __str.size();
3187 const size_type __len =
std::min(__size, __osize);
3189 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3191 __r = _S_compare(__size, __osize);
3195#if __cplusplus >= 201703L
3201 template<
typename _Tp>
3202 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3204 compare(
const _Tp& __svt)
const
3205 noexcept(is_same<_Tp, __sv_type>::value)
3207 __sv_type __sv = __svt;
3208 const size_type __size = this->
size();
3209 const size_type __osize = __sv.size();
3210 const size_type __len =
std::min(__size, __osize);
3212 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3214 __r = _S_compare(__size, __osize);
3226 template<
typename _Tp>
3227 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3229 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3230 noexcept(is_same<_Tp, __sv_type>::value)
3232 __sv_type __sv = __svt;
3233 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3246 template<
typename _Tp>
3247 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3249 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3250 size_type __pos2, size_type __n2 =
npos)
const
3251 noexcept(is_same<_Tp, __sv_type>::value)
3253 __sv_type __sv = __svt;
3254 return __sv_type(*
this)
3255 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3278 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3282 _M_check(__pos,
"basic_string::compare");
3283 __n = _M_limit(__pos, __n);
3284 const size_type __osize = __str.size();
3285 const size_type __len =
std::min(__n, __osize);
3286 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3288 __r = _S_compare(__n, __osize);
3315 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3318 size_type __pos2, size_type __n2 =
npos)
const
3320 _M_check(__pos1,
"basic_string::compare");
3321 __str._M_check(__pos2,
"basic_string::compare");
3322 __n1 = _M_limit(__pos1, __n1);
3323 __n2 = __str._M_limit(__pos2, __n2);
3324 const size_type __len =
std::min(__n1, __n2);
3325 int __r = traits_type::compare(_M_data() + __pos1,
3326 __str.data() + __pos2, __len);
3328 __r = _S_compare(__n1, __n2);
3346 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3348 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3350 __glibcxx_requires_string(__s);
3351 const size_type __size = this->
size();
3352 const size_type __osize = traits_type::length(__s);
3353 const size_type __len =
std::min(__size, __osize);
3354 int __r = traits_type::compare(_M_data(), __s, __len);
3356 __r = _S_compare(__size, __osize);
3381 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3383 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3385 __glibcxx_requires_string(__s);
3386 _M_check(__pos,
"basic_string::compare");
3387 __n1 = _M_limit(__pos, __n1);
3388 const size_type __osize = traits_type::length(__s);
3389 const size_type __len =
std::min(__n1, __osize);
3390 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3392 __r = _S_compare(__n1, __osize);
3420 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3422 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3423 size_type __n2)
const
3425 __glibcxx_requires_string_len(__s, __n2);
3426 _M_check(__pos,
"basic_string::compare");
3427 __n1 = _M_limit(__pos, __n1);
3428 const size_type __len =
std::min(__n1, __n2);
3429 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3431 __r = _S_compare(__n1, __n2);
3435#if __cplusplus >= 202002L
3438 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3439 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3443 starts_with(_CharT __x)
const noexcept
3444 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3446 [[nodiscard, __gnu__::__nonnull__]]
3448 starts_with(
const _CharT* __x)
const noexcept
3449 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3453 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3454 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3458 ends_with(_CharT __x)
const noexcept
3459 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3461 [[nodiscard, __gnu__::__nonnull__]]
3463 ends_with(
const _CharT* __x)
const noexcept
3464 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3467#if __cplusplus > 202002L
3470 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3471 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3475 contains(_CharT __x)
const noexcept
3476 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3478 [[nodiscard, __gnu__::__nonnull__]]
3480 contains(
const _CharT* __x)
const noexcept
3481 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3485 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3487_GLIBCXX_END_NAMESPACE_CXX11
3488_GLIBCXX_END_NAMESPACE_VERSION
3492namespace std _GLIBCXX_VISIBILITY(default)
3494_GLIBCXX_BEGIN_NAMESPACE_VERSION
3496#if __cpp_deduction_guides >= 201606
3497_GLIBCXX_BEGIN_NAMESPACE_CXX11
3498 template<
typename _InputIterator,
typename _CharT
3499 =
typename iterator_traits<_InputIterator>::value_type,
3500 typename _Allocator = allocator<_CharT>,
3501 typename = _RequireInputIter<_InputIterator>,
3502 typename = _RequireAllocator<_Allocator>>
3503 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3504 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3508 template<
typename _CharT,
typename _Traits,
3509 typename _Allocator = allocator<_CharT>,
3510 typename = _RequireAllocator<_Allocator>>
3511 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3512 -> basic_string<_CharT, _Traits, _Allocator>;
3514 template<
typename _CharT,
typename _Traits,
3515 typename _Allocator = allocator<_CharT>,
3516 typename = _RequireAllocator<_Allocator>>
3517 basic_string(basic_string_view<_CharT, _Traits>,
3518 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3519 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3520 const _Allocator& = _Allocator())
3521 -> basic_string<_CharT, _Traits, _Allocator>;
3522_GLIBCXX_END_NAMESPACE_CXX11
3525 template<
typename _Str>
3526 _GLIBCXX20_CONSTEXPR
3528 __str_concat(
typename _Str::value_type
const* __lhs,
3529 typename _Str::size_type __lhs_len,
3530 typename _Str::value_type
const* __rhs,
3531 typename _Str::size_type __rhs_len,
3532 typename _Str::allocator_type
const& __a)
3534 typedef typename _Str::allocator_type allocator_type;
3536 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3537 __str.reserve(__lhs_len + __rhs_len);
3538 __str.append(__lhs, __lhs_len);
3539 __str.append(__rhs, __rhs_len);
3550 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3551 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3552 inline basic_string<_CharT, _Traits, _Alloc>
3557 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3558 __rhs.c_str(), __rhs.size(),
3559 __lhs.get_allocator());
3568 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3569 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3570 inline basic_string<_CharT,_Traits,_Alloc>
3574 __glibcxx_requires_string(__lhs);
3576 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3577 __rhs.c_str(), __rhs.size(),
3578 __rhs.get_allocator());
3587 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3588 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3589 inline basic_string<_CharT,_Traits,_Alloc>
3593 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3594 __rhs.c_str(), __rhs.size(),
3595 __rhs.get_allocator());
3604 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3605 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3606 inline basic_string<_CharT, _Traits, _Alloc>
3608 const _CharT* __rhs)
3610 __glibcxx_requires_string(__rhs);
3612 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3613 __rhs, _Traits::length(__rhs),
3614 __lhs.get_allocator());
3622 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3623 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3624 inline basic_string<_CharT, _Traits, _Alloc>
3628 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3629 __builtin_addressof(__rhs), 1,
3630 __lhs.get_allocator());
3633#if __cplusplus >= 201103L
3634 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3635 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3636 inline basic_string<_CharT, _Traits, _Alloc>
3637 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3638 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3639 {
return std::move(__lhs.append(__rhs)); }
3641 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3642 _GLIBCXX20_CONSTEXPR
3643 inline basic_string<_CharT, _Traits, _Alloc>
3644 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3645 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3646 {
return std::move(__rhs.insert(0, __lhs)); }
3648 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3649 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3650 inline basic_string<_CharT, _Traits, _Alloc>
3651 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3652 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3654#if _GLIBCXX_USE_CXX11_ABI
3655 using _Alloc_traits = allocator_traits<_Alloc>;
3656 bool __use_rhs =
false;
3657 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3659 else if (__lhs.get_allocator() == __rhs.get_allocator())
3664 const auto __size = __lhs.size() + __rhs.size();
3665 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3666 return std::move(__rhs.insert(0, __lhs));
3671 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3672 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3673 inline basic_string<_CharT, _Traits, _Alloc>
3675 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3676 {
return std::move(__rhs.insert(0, __lhs)); }
3678 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3679 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3680 inline basic_string<_CharT, _Traits, _Alloc>
3682 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3683 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3685 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3686 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3687 inline basic_string<_CharT, _Traits, _Alloc>
3688 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3689 const _CharT* __rhs)
3690 {
return std::move(__lhs.append(__rhs)); }
3692 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3693 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3694 inline basic_string<_CharT, _Traits, _Alloc>
3695 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3697 {
return std::move(__lhs.append(1, __rhs)); }
3707 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3708 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3714 return __lhs.size() == __rhs.size()
3715 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3724 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3725 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3728 const _CharT* __rhs)
3730 return __lhs.size() == _Traits::length(__rhs)
3731 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3734#if __cpp_lib_three_way_comparison
3742 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3745 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3746 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3747 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3748 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3757 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3760 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3761 const _CharT* __rhs)
noexcept
3762 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3763 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3771 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3774 operator==(
const _CharT* __lhs,
3776 {
return __rhs == __lhs; }
3785 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3791 {
return !(__lhs == __rhs); }
3799 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3802 operator!=(
const _CharT* __lhs,
3804 {
return !(__rhs == __lhs); }
3812 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3816 const _CharT* __rhs)
3817 {
return !(__lhs == __rhs); }
3826 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3832 {
return __lhs.compare(__rhs) < 0; }
3840 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3844 const _CharT* __rhs)
3845 {
return __lhs.compare(__rhs) < 0; }
3853 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3856 operator<(
const _CharT* __lhs,
3858 {
return __rhs.compare(__lhs) > 0; }
3867 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3873 {
return __lhs.compare(__rhs) > 0; }
3881 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3885 const _CharT* __rhs)
3886 {
return __lhs.compare(__rhs) > 0; }
3894 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3897 operator>(
const _CharT* __lhs,
3899 {
return __rhs.compare(__lhs) < 0; }
3908 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3914 {
return __lhs.compare(__rhs) <= 0; }
3922 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3926 const _CharT* __rhs)
3927 {
return __lhs.compare(__rhs) <= 0; }
3935 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3938 operator<=(
const _CharT* __lhs,
3940 {
return __rhs.compare(__lhs) >= 0; }
3949 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3955 {
return __lhs.compare(__rhs) >= 0; }
3963 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3967 const _CharT* __rhs)
3968 {
return __lhs.compare(__rhs) >= 0; }
3976 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3979 operator>=(
const _CharT* __lhs,
3981 {
return __rhs.compare(__lhs) <= 0; }
3991 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3992 _GLIBCXX20_CONSTEXPR
3996 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
3997 { __lhs.swap(__rhs); }
4012 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4013 basic_istream<_CharT, _Traits>&
4014 operator>>(basic_istream<_CharT, _Traits>& __is,
4015 basic_string<_CharT, _Traits, _Alloc>& __str);
4018 basic_istream<char>&
4030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4037 return __ostream_insert(__os, __str.data(), __str.size());
4053 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4054 basic_istream<_CharT, _Traits>&
4055 getline(basic_istream<_CharT, _Traits>& __is,
4056 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4070 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4071 inline basic_istream<_CharT, _Traits>&
4076#if __cplusplus >= 201103L
4078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4079 inline basic_istream<_CharT, _Traits>&
4085 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4086 inline basic_istream<_CharT, _Traits>&
4093 basic_istream<char>&
4094 getline(basic_istream<char>& __in, basic_string<char>& __str,
4097#ifdef _GLIBCXX_USE_WCHAR_T
4099 basic_istream<wchar_t>&
4100 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4104_GLIBCXX_END_NAMESPACE_VERSION
4107#if __cplusplus >= 201103L
4112namespace std _GLIBCXX_VISIBILITY(default)
4114_GLIBCXX_BEGIN_NAMESPACE_VERSION
4115_GLIBCXX_BEGIN_NAMESPACE_CXX11
4117#if _GLIBCXX_USE_C99_STDLIB
4120 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4121 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4125 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4126 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4129 inline unsigned long
4130 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4131 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4135 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4136 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4139 inline unsigned long long
4140 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4141 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4146 stof(
const string& __str,
size_t* __idx = 0)
4147 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4150 stod(
const string& __str,
size_t* __idx = 0)
4151 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4154 stold(
const string& __str,
size_t* __idx = 0)
4155 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4162 to_string(
int __val)
4163#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4167 const bool __neg = __val < 0;
4168 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4169 const auto __len = __detail::__to_chars_len(__uval);
4170 string __str(__neg + __len,
'-');
4171 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4177 to_string(
unsigned __val)
4178#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4182 string __str(__detail::__to_chars_len(__val),
'\0');
4183 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4189 to_string(
long __val)
4190#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4194 const bool __neg = __val < 0;
4195 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4196 const auto __len = __detail::__to_chars_len(__uval);
4197 string __str(__neg + __len,
'-');
4198 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4204 to_string(
unsigned long __val)
4205#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4209 string __str(__detail::__to_chars_len(__val),
'\0');
4210 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4216 to_string(
long long __val)
4218 const bool __neg = __val < 0;
4219 const unsigned long long __uval
4220 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4221 const auto __len = __detail::__to_chars_len(__uval);
4222 string __str(__neg + __len,
'-');
4223 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4229 to_string(
unsigned long long __val)
4231 string __str(__detail::__to_chars_len(__val),
'\0');
4232 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4236#if _GLIBCXX_USE_C99_STDIO
4241 to_string(
float __val)
4244 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4245 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4251 to_string(
double __val)
4254 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4255 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4261 to_string(
long double __val)
4264 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4265 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4270#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4272 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4273 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4277 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4278 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4281 inline unsigned long
4282 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4283 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4287 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4288 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4291 inline unsigned long long
4292 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4293 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4298 stof(
const wstring& __str,
size_t* __idx = 0)
4299 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4302 stod(
const wstring& __str,
size_t* __idx = 0)
4303 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4306 stold(
const wstring& __str,
size_t* __idx = 0)
4307 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4309#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4313 to_wstring(
int __val)
4314 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
4319 to_wstring(
unsigned __val)
4320 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4321 4 *
sizeof(
unsigned),
4326 to_wstring(
long __val)
4327 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
4332 to_wstring(
unsigned long __val)
4333 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4334 4 *
sizeof(
unsigned long),
4339 to_wstring(
long long __val)
4340 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4341 4 *
sizeof(
long long),
4346 to_wstring(
unsigned long long __val)
4347 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4348 4 *
sizeof(
unsigned long long),
4353 to_wstring(
float __val)
4356 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4357 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4363 to_wstring(
double __val)
4366 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4367 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4373 to_wstring(
long double __val)
4376 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4377 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4383_GLIBCXX_END_NAMESPACE_CXX11
4384_GLIBCXX_END_NAMESPACE_VERSION
4389#if __cplusplus >= 201103L
4393namespace std _GLIBCXX_VISIBILITY(default)
4395_GLIBCXX_BEGIN_NAMESPACE_VERSION
4400 template<
typename _CharT,
typename _Alloc,
4401 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4402 struct __str_hash_base
4403 :
public __hash_base<size_t, _StrT>
4407 operator()(
const _StrT& __s)
const noexcept
4408 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4411#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4413 template<
typename _Alloc>
4415 :
public __str_hash_base<char, _Alloc>
4419 template<
typename _Alloc>
4421 :
public __str_hash_base<wchar_t, _Alloc>
4424 template<
typename _Alloc>
4431#ifdef _GLIBCXX_USE_CHAR8_T
4433 template<
typename _Alloc>
4434 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4435 :
public __str_hash_base<char8_t, _Alloc>
4440 template<
typename _Alloc>
4442 :
public __str_hash_base<char16_t, _Alloc>
4446 template<
typename _Alloc>
4448 :
public __str_hash_base<char32_t, _Alloc>
4451#if ! _GLIBCXX_INLINE_VERSION
4457#ifdef _GLIBCXX_USE_CHAR8_T
4458 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4462 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4463 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4468#if __cplusplus >= 201402L
4470#define __cpp_lib_string_udls 201304L
4472 inline namespace literals
4474 inline namespace string_literals
4476#pragma GCC diagnostic push
4477#pragma GCC diagnostic ignored "-Wliteral-suffix"
4479#if __cpp_lib_constexpr_string >= 201907L
4480# define _GLIBCXX_STRING_CONSTEXPR constexpr
4482# define _GLIBCXX_STRING_CONSTEXPR
4485 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4486 inline basic_string<char>
4487 operator""s(
const char* __str,
size_t __len)
4488 {
return basic_string<char>{__str, __len}; }
4490 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4491 inline basic_string<wchar_t>
4492 operator""s(
const wchar_t* __str,
size_t __len)
4493 {
return basic_string<wchar_t>{__str, __len}; }
4495#ifdef _GLIBCXX_USE_CHAR8_T
4496 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4497 inline basic_string<char8_t>
4498 operator""s(
const char8_t* __str,
size_t __len)
4499 {
return basic_string<char8_t>{__str, __len}; }
4502 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4503 inline basic_string<char16_t>
4504 operator""s(
const char16_t* __str,
size_t __len)
4505 {
return basic_string<char16_t>{__str, __len}; }
4507 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4508 inline basic_string<char32_t>
4509 operator""s(
const char32_t* __str,
size_t __len)
4510 {
return basic_string<char32_t>{__str, __len}; }
4512#undef _GLIBCXX_STRING_CONSTEXPR
4513#pragma GCC diagnostic pop
4517#if __cplusplus >= 201703L
4518 namespace __detail::__variant
4520 template<
typename>
struct _Never_valueless_alt;
4524 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4525 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4527 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4528 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4535_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.