34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
37#pragma GCC system_header
42#if __cplusplus >= 201103L
46#if __cplusplus >= 201703L
50#if ! _GLIBCXX_USE_CXX11_ABI
53namespace std _GLIBCXX_VISIBILITY(default)
55_GLIBCXX_BEGIN_NAMESPACE_VERSION
56_GLIBCXX_BEGIN_NAMESPACE_CXX11
58#ifdef __cpp_lib_is_constant_evaluated
60# define __cpp_lib_constexpr_string 201907L
61#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
63# define __cpp_lib_constexpr_string 201611L
84 template<
typename _CharT,
typename _Traits,
typename _Alloc>
88 rebind<_CharT>::other _Char_alloc_type;
90#if __cpp_lib_constexpr_string < 201907L
93 template<
typename _Traits2,
typename _Dummy_for_PR85282>
98 [[__gnu__::__always_inline__]]
99 static constexpr typename _Base::pointer
100 allocate(_Char_alloc_type& __a,
typename _Base::size_type __n)
102 pointer __p = _Base::allocate(__a, __n);
105 for (size_type __i = 0; __i < __n; ++__i)
106 std::construct_at(__builtin_addressof(__p[__i]));
111 template<
typename _Dummy_for_PR85282>
112 struct _Alloc_traits_impl<char_traits<_CharT>, _Dummy_for_PR85282>
118 using _Alloc_traits = _Alloc_traits_impl<_Traits, void>;
123 typedef _Traits traits_type;
124 typedef typename _Traits::char_type value_type;
125 typedef _Char_alloc_type allocator_type;
126 typedef typename _Alloc_traits::size_type size_type;
127 typedef typename _Alloc_traits::difference_type difference_type;
128 typedef typename _Alloc_traits::reference reference;
129 typedef typename _Alloc_traits::const_reference const_reference;
130 typedef typename _Alloc_traits::pointer pointer;
131 typedef typename _Alloc_traits::const_pointer const_pointer;
132 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
133 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
139 static const size_type
npos =
static_cast<size_type
>(-1);
143#if __cplusplus < 201103L
144 typedef iterator __const_iterator;
146 typedef const_iterator __const_iterator;
150#if __cplusplus >= 201703L
152 typedef basic_string_view<_CharT, _Traits> __sv_type;
154 template<
typename _Tp,
typename _Res>
156 __and_<is_convertible<const _Tp&, __sv_type>,
157 __not_<is_convertible<const _Tp*, const basic_string*>>,
158 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
164 _S_to_string_view(__sv_type __svt)
noexcept
173 _GLIBCXX20_CONSTEXPR
explicit
174 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
192 struct _Alloc_hider : allocator_type
194#if __cplusplus < 201103L
195 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
196 : allocator_type(__a), _M_p(__dat) { }
199 _Alloc_hider(pointer __dat,
const _Alloc& __a)
200 : allocator_type(__a), _M_p(__dat) { }
203 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
204 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
210 _Alloc_hider _M_dataplus;
211 size_type _M_string_length;
213 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
217 _CharT _M_local_buf[_S_local_capacity + 1];
218 size_type _M_allocated_capacity;
224 { _M_dataplus._M_p = __p; }
228 _M_length(size_type __length)
229 { _M_string_length = __length; }
234 {
return _M_dataplus._M_p; }
240#if __cplusplus >= 201103L
243 return pointer(_M_local_buf);
249 _M_local_data()
const
251#if __cplusplus >= 201103L
254 return const_pointer(_M_local_buf);
260 _M_capacity(size_type __capacity)
261 { _M_allocated_capacity = __capacity; }
265 _M_set_length(size_type __n)
268 traits_type::assign(_M_data()[__n], _CharT());
274 {
return _M_data() == _M_local_data(); }
279 _M_create(size_type&, size_type);
286 _M_destroy(_M_allocated_capacity);
291 _M_destroy(size_type __size)
throw()
292 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
294#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
297 template<
typename _InIterator>
299 _M_construct_aux(_InIterator __beg, _InIterator __end,
302 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
303 _M_construct(__beg, __end, _Tag());
308 template<
typename _Integer>
310 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
311 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
314 _M_construct_aux_2(size_type __req, _CharT __c)
315 { _M_construct(__req, __c); }
319 template<
typename _InIterator>
322 _M_construct(_InIterator __beg, _InIterator __end,
327 template<
typename _FwdIterator>
330 _M_construct(_FwdIterator __beg, _FwdIterator __end,
335 _M_construct(size_type __req, _CharT __c);
340 {
return _M_dataplus; }
343 const allocator_type&
344 _M_get_allocator()
const
345 {
return _M_dataplus; }
348 __attribute__((__always_inline__))
351 _M_use_local_data() _GLIBCXX_NOEXCEPT
353#if __cpp_lib_is_constant_evaluated
355 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
356 _M_local_buf[__i] = _CharT();
358 return _M_local_data();
363#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
366 template<
typename _Tp,
bool _Requires =
367 !__are_same<_Tp, _CharT*>::__value
368 && !__are_same<_Tp, const _CharT*>::__value
369 && !__are_same<_Tp, iterator>::__value
370 && !__are_same<_Tp, const_iterator>::__value>
371 struct __enable_if_not_native_iterator
372 {
typedef basic_string& __type; };
373 template<
typename _Tp>
374 struct __enable_if_not_native_iterator<_Tp, false> { };
379 _M_check(size_type __pos,
const char* __s)
const
381 if (__pos > this->
size())
382 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
383 "this->size() (which is %zu)"),
384 __s, __pos, this->
size());
390 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
393 __throw_length_error(__N(__s));
400 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
402 const bool __testoff = __off < this->
size() - __pos;
403 return __testoff ? __off : this->
size() - __pos;
408 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
410 return (less<const _CharT*>()(__s, _M_data())
411 || less<const _CharT*>()(_M_data() + this->
size(), __s));
418 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
421 traits_type::assign(*__d, *__s);
423 traits_type::copy(__d, __s, __n);
428 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
431 traits_type::assign(*__d, *__s);
433 traits_type::move(__d, __s, __n);
438 _S_assign(_CharT* __d, size_type __n, _CharT __c)
441 traits_type::assign(*__d, __c);
443 traits_type::assign(__d, __n, __c);
448 template<
class _Iterator>
451 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
453 for (; __k1 != __k2; ++__k1, (void)++__p)
454 traits_type::assign(*__p, *__k1);
459 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
460 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
464 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
466 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
470 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
471 { _S_copy(__p, __k1, __k2 - __k1); }
475 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
477 { _S_copy(__p, __k1, __k2 - __k1); }
481 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
483 const difference_type __d = difference_type(__n1 - __n2);
485 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
486 return __gnu_cxx::__numeric_traits<int>::__max;
487 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
488 return __gnu_cxx::__numeric_traits<int>::__min;
499 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
504 _M_erase(size_type __pos, size_type __n);
516 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
517 : _M_dataplus(_M_local_data())
529 : _M_dataplus(_M_local_data(), __a)
541 : _M_dataplus(_M_local_data(),
542 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
544 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
558 const _Alloc& __a = _Alloc())
559 : _M_dataplus(_M_local_data(), __a)
561 const _CharT* __start = __str._M_data()
562 + __str._M_check(__pos,
"basic_string::basic_string");
563 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
576 : _M_dataplus(_M_local_data())
578 const _CharT* __start = __str._M_data()
579 + __str._M_check(__pos,
"basic_string::basic_string");
580 _M_construct(__start, __start + __str._M_limit(__pos, __n),
593 size_type __n,
const _Alloc& __a)
594 : _M_dataplus(_M_local_data(), __a)
596 const _CharT* __start
597 = __str._M_data() + __str._M_check(__pos,
"string::string");
598 _M_construct(__start, __start + __str._M_limit(__pos, __n),
613 const _Alloc& __a = _Alloc())
614 : _M_dataplus(_M_local_data(), __a)
617 if (__s == 0 && __n > 0)
618 std::__throw_logic_error(__N(
"basic_string: "
619 "construction from null is not valid"));
628#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
631 template<
typename = _RequireAllocator<_Alloc>>
634 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
635 : _M_dataplus(_M_local_data(), __a)
639 std::__throw_logic_error(__N(
"basic_string: "
640 "construction from null is not valid"));
641 const _CharT* __end = __s + traits_type::length(__s);
642 _M_construct(__s, __end, forward_iterator_tag());
651#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
654 template<
typename = _RequireAllocator<_Alloc>>
657 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
658 : _M_dataplus(_M_local_data(), __a)
659 { _M_construct(__n, __c); }
661#if __cplusplus >= 201103L
671 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
673 if (__str._M_is_local())
675 traits_type::copy(_M_local_buf, __str._M_local_buf,
680 _M_data(__str._M_data());
681 _M_capacity(__str._M_allocated_capacity);
687 _M_length(__str.length());
688 __str._M_data(__str._M_local_data());
689 __str._M_set_length(0);
698 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
699 : _M_dataplus(_M_local_data(), __a)
704 : _M_dataplus(_M_local_data(), __a)
709 noexcept(_Alloc_traits::_S_always_equal())
710 : _M_dataplus(_M_local_data(), __a)
712 if (__str._M_is_local())
714 traits_type::copy(_M_local_buf, __str._M_local_buf,
716 _M_length(__str.length());
717 __str._M_set_length(0);
719 else if (_Alloc_traits::_S_always_equal()
720 || __str.get_allocator() == __a)
722 _M_data(__str._M_data());
723 _M_length(__str.length());
724 _M_capacity(__str._M_allocated_capacity);
725 __str._M_data(__str._M_local_buf);
726 __str._M_set_length(0);
733#if __cplusplus >= 202100L
744#if __cplusplus >= 201103L
745 template<
typename _InputIterator,
746 typename = std::_RequireInputIter<_InputIterator>>
748 template<
typename _InputIterator>
751 basic_string(_InputIterator __beg, _InputIterator __end,
752 const _Alloc& __a = _Alloc())
753 : _M_dataplus(_M_local_data(), __a)
755#if __cplusplus >= 201103L
758 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
759 _M_construct_aux(__beg, __end, _Integral());
763#if __cplusplus >= 201703L
771 template<
typename _Tp,
772 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
774 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
775 const _Alloc& __a = _Alloc())
783 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
786 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
787 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
805 return this->
assign(__str);
815 {
return this->
assign(__s); }
832#if __cplusplus >= 201103L
845 noexcept(_Alloc_traits::_S_nothrow_move())
847 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
848 || _M_get_allocator() == __str._M_get_allocator();
849 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
853 _M_destroy(_M_allocated_capacity);
854 _M_data(_M_local_data());
858 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
860 if (__str._M_is_local())
868 this->_S_copy(_M_data(), __str._M_data(), __str.size());
869 _M_set_length(__str.size());
872 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
875 pointer __data =
nullptr;
876 size_type __capacity;
883 __capacity = _M_allocated_capacity;
886 _M_destroy(_M_allocated_capacity);
889 _M_data(__str._M_data());
890 _M_length(__str.length());
891 _M_capacity(__str._M_allocated_capacity);
894 __str._M_data(__data);
895 __str._M_capacity(__capacity);
898 __str._M_data(__str._M_local_buf);
914 this->
assign(__l.begin(), __l.size());
919#if __cplusplus >= 201703L
924 template<
typename _Tp>
926 _If_sv<_Tp, basic_string&>
928 {
return this->
assign(__svt); }
935 operator __sv_type() const noexcept
936 {
return __sv_type(
data(),
size()); }
944 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
946 begin() _GLIBCXX_NOEXCEPT
947 {
return iterator(_M_data()); }
953 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
955 begin() const _GLIBCXX_NOEXCEPT
956 {
return const_iterator(_M_data()); }
962 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
964 end() _GLIBCXX_NOEXCEPT
965 {
return iterator(_M_data() + this->
size()); }
971 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
973 end() const _GLIBCXX_NOEXCEPT
974 {
return const_iterator(_M_data() + this->
size()); }
981 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
983 rbegin() _GLIBCXX_NOEXCEPT
984 {
return reverse_iterator(this->
end()); }
991 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
992 const_reverse_iterator
993 rbegin() const _GLIBCXX_NOEXCEPT
994 {
return const_reverse_iterator(this->
end()); }
1001 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1003 rend() _GLIBCXX_NOEXCEPT
1004 {
return reverse_iterator(this->
begin()); }
1011 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1012 const_reverse_iterator
1013 rend() const _GLIBCXX_NOEXCEPT
1014 {
return const_reverse_iterator(this->
begin()); }
1016#if __cplusplus >= 201103L
1021 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1024 {
return const_iterator(this->_M_data()); }
1030 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1032 cend() const noexcept
1033 {
return const_iterator(this->_M_data() + this->
size()); }
1040 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1041 const_reverse_iterator
1043 {
return const_reverse_iterator(this->
end()); }
1050 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1051 const_reverse_iterator
1052 crend() const noexcept
1053 {
return const_reverse_iterator(this->
begin()); }
1060 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1062 size() const _GLIBCXX_NOEXCEPT
1063 {
return _M_string_length; }
1067 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1069 length() const _GLIBCXX_NOEXCEPT
1070 {
return _M_string_length; }
1073 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1076 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1088 _GLIBCXX20_CONSTEXPR
1090 resize(size_type __n, _CharT __c);
1102 _GLIBCXX20_CONSTEXPR
1105 { this->
resize(__n, _CharT()); }
1107#if __cplusplus >= 201103L
1108#pragma GCC diagnostic push
1109#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1111 _GLIBCXX20_CONSTEXPR
1115#pragma GCC diagnostic pop
1118#if __cplusplus > 202002L
1119#define __cpp_lib_string_resize_and_overwrite 202110L
1120 template<
typename _Operation>
1122 resize_and_overwrite(size_type __n, _Operation __op);
1129 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1133 return _M_is_local() ? size_type(_S_local_capacity)
1134 : _M_allocated_capacity;
1154 _GLIBCXX20_CONSTEXPR
1161#if __cplusplus > 201703L
1162 [[deprecated(
"use shrink_to_fit() instead")]]
1164 _GLIBCXX20_CONSTEXPR
1171 _GLIBCXX20_CONSTEXPR
1173 clear() _GLIBCXX_NOEXCEPT
1174 { _M_set_length(0); }
1180 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1182 empty() const _GLIBCXX_NOEXCEPT
1183 {
return this->
size() == 0; }
1196 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1198 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1200 __glibcxx_assert(__pos <=
size());
1201 return _M_data()[__pos];
1214 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1220 __glibcxx_assert(__pos <=
size());
1222 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1223 return _M_data()[__pos];
1236 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1238 at(size_type __n)
const
1240 if (__n >= this->
size())
1241 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1242 "(which is %zu) >= this->size() "
1245 return _M_data()[__n];
1258 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1263 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1264 "(which is %zu) >= this->size() "
1267 return _M_data()[__n];
1270#if __cplusplus >= 201103L
1275 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1279 __glibcxx_assert(!
empty());
1287 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1289 front() const noexcept
1291 __glibcxx_assert(!
empty());
1299 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1303 __glibcxx_assert(!
empty());
1311 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1313 back() const noexcept
1315 __glibcxx_assert(!
empty());
1326 _GLIBCXX20_CONSTEXPR
1329 {
return this->
append(__str); }
1336 _GLIBCXX20_CONSTEXPR
1339 {
return this->
append(__s); }
1346 _GLIBCXX20_CONSTEXPR
1354#if __cplusplus >= 201103L
1360 _GLIBCXX20_CONSTEXPR
1363 {
return this->
append(__l.begin(), __l.size()); }
1366#if __cplusplus >= 201703L
1372 template<
typename _Tp>
1373 _GLIBCXX20_CONSTEXPR
1374 _If_sv<_Tp, basic_string&>
1376 {
return this->
append(__svt); }
1384 _GLIBCXX20_CONSTEXPR
1387 {
return this->
append(__str._M_data(), __str.size()); }
1402 _GLIBCXX20_CONSTEXPR
1405 {
return this->
append(__str._M_data()
1406 + __str._M_check(__pos,
"basic_string::append"),
1407 __str._M_limit(__pos, __n)); }
1415 _GLIBCXX20_CONSTEXPR
1417 append(
const _CharT* __s, size_type __n)
1419 __glibcxx_requires_string_len(__s, __n);
1420 _M_check_length(size_type(0), __n,
"basic_string::append");
1421 return _M_append(__s, __n);
1429 _GLIBCXX20_CONSTEXPR
1431 append(
const _CharT* __s)
1433 __glibcxx_requires_string(__s);
1434 const size_type __n = traits_type::length(__s);
1435 _M_check_length(size_type(0), __n,
"basic_string::append");
1436 return _M_append(__s, __n);
1447 _GLIBCXX20_CONSTEXPR
1449 append(size_type __n, _CharT __c)
1450 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1452#if __cplusplus >= 201103L
1458 _GLIBCXX20_CONSTEXPR
1460 append(initializer_list<_CharT> __l)
1461 {
return this->
append(__l.begin(), __l.size()); }
1472#if __cplusplus >= 201103L
1473 template<
class _InputIterator,
1474 typename = std::_RequireInputIter<_InputIterator>>
1475 _GLIBCXX20_CONSTEXPR
1477 template<
class _InputIterator>
1480 append(_InputIterator __first, _InputIterator __last)
1483#if __cplusplus >= 201703L
1489 template<
typename _Tp>
1490 _GLIBCXX20_CONSTEXPR
1491 _If_sv<_Tp, basic_string&>
1494 __sv_type __sv = __svt;
1495 return this->
append(__sv.data(), __sv.size());
1505 template<
typename _Tp>
1506 _GLIBCXX20_CONSTEXPR
1507 _If_sv<_Tp, basic_string&>
1508 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1510 __sv_type __sv = __svt;
1511 return _M_append(__sv.data()
1512 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1513 std::__sv_limit(__sv.size(), __pos, __n));
1521 _GLIBCXX20_CONSTEXPR
1525 const size_type __size = this->
size();
1527 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1528 traits_type::assign(this->_M_data()[__size], __c);
1529 this->_M_set_length(__size + 1);
1537 _GLIBCXX20_CONSTEXPR
1541#if __cplusplus >= 201103L
1542 if (_Alloc_traits::_S_propagate_on_copy_assign())
1544 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1545 && _M_get_allocator() != __str._M_get_allocator())
1549 if (__str.size() <= _S_local_capacity)
1551 _M_destroy(_M_allocated_capacity);
1552 _M_data(_M_use_local_data());
1557 const auto __len = __str.size();
1558 auto __alloc = __str._M_get_allocator();
1560 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1561 _M_destroy(_M_allocated_capacity);
1564 _M_set_length(__len);
1567 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1570 this->_M_assign(__str);
1574#if __cplusplus >= 201103L
1583 _GLIBCXX20_CONSTEXPR
1586 noexcept(_Alloc_traits::_S_nothrow_move())
1607 _GLIBCXX20_CONSTEXPR
1610 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1611 + __str._M_check(__pos,
"basic_string::assign"),
1612 __str._M_limit(__pos, __n)); }
1624 _GLIBCXX20_CONSTEXPR
1626 assign(
const _CharT* __s, size_type __n)
1628 __glibcxx_requires_string_len(__s, __n);
1629 return _M_replace(size_type(0), this->
size(), __s, __n);
1641 _GLIBCXX20_CONSTEXPR
1643 assign(
const _CharT* __s)
1645 __glibcxx_requires_string(__s);
1646 return _M_replace(size_type(0), this->
size(), __s,
1647 traits_type::length(__s));
1659 _GLIBCXX20_CONSTEXPR
1661 assign(size_type __n, _CharT __c)
1662 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1672#if __cplusplus >= 201103L
1673 template<
class _InputIterator,
1674 typename = std::_RequireInputIter<_InputIterator>>
1675 _GLIBCXX20_CONSTEXPR
1677 template<
class _InputIterator>
1680 assign(_InputIterator __first, _InputIterator __last)
1683#if __cplusplus >= 201103L
1689 _GLIBCXX20_CONSTEXPR
1691 assign(initializer_list<_CharT> __l)
1692 {
return this->
assign(__l.begin(), __l.size()); }
1695#if __cplusplus >= 201703L
1701 template<
typename _Tp>
1702 _GLIBCXX20_CONSTEXPR
1703 _If_sv<_Tp, basic_string&>
1706 __sv_type __sv = __svt;
1707 return this->
assign(__sv.data(), __sv.size());
1717 template<
typename _Tp>
1718 _GLIBCXX20_CONSTEXPR
1719 _If_sv<_Tp, basic_string&>
1720 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1722 __sv_type __sv = __svt;
1723 return _M_replace(size_type(0), this->
size(),
1725 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1726 std::__sv_limit(__sv.size(), __pos, __n));
1730#if __cplusplus >= 201103L
1746 _GLIBCXX20_CONSTEXPR
1748 insert(const_iterator __p, size_type __n, _CharT __c)
1750 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1751 const size_type __pos = __p -
begin();
1752 this->
replace(__p, __p, __n, __c);
1753 return iterator(this->_M_data() + __pos);
1770 insert(iterator __p, size_type __n, _CharT __c)
1771 { this->
replace(__p, __p, __n, __c); }
1774#if __cplusplus >= 201103L
1789 template<
class _InputIterator,
1790 typename = std::_RequireInputIter<_InputIterator>>
1791 _GLIBCXX20_CONSTEXPR
1793 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1795 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1796 const size_type __pos = __p -
begin();
1797 this->
replace(__p, __p, __beg, __end);
1798 return iterator(this->_M_data() + __pos);
1813 template<
class _InputIterator>
1815 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1816 { this->
replace(__p, __p, __beg, __end); }
1819#if __cplusplus >= 201103L
1826 _GLIBCXX20_CONSTEXPR
1828 insert(const_iterator __p, initializer_list<_CharT> __l)
1829 {
return this->
insert(__p, __l.begin(), __l.end()); }
1831#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1834 insert(iterator __p, initializer_list<_CharT> __l)
1836 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1837 this->
insert(__p -
begin(), __l.begin(), __l.size());
1854 _GLIBCXX20_CONSTEXPR
1857 {
return this->
replace(__pos1, size_type(0),
1858 __str._M_data(), __str.size()); }
1878 _GLIBCXX20_CONSTEXPR
1881 size_type __pos2, size_type __n =
npos)
1882 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1883 + __str._M_check(__pos2,
"basic_string::insert"),
1884 __str._M_limit(__pos2, __n)); }
1902 _GLIBCXX20_CONSTEXPR
1904 insert(size_type __pos,
const _CharT* __s, size_type __n)
1905 {
return this->
replace(__pos, size_type(0), __s, __n); }
1922 _GLIBCXX20_CONSTEXPR
1924 insert(size_type __pos,
const _CharT* __s)
1926 __glibcxx_requires_string(__s);
1927 return this->
replace(__pos, size_type(0), __s,
1928 traits_type::length(__s));
1947 _GLIBCXX20_CONSTEXPR
1949 insert(size_type __pos, size_type __n, _CharT __c)
1950 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1951 size_type(0), __n, __c); }
1966 _GLIBCXX20_CONSTEXPR
1968 insert(__const_iterator __p, _CharT __c)
1970 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1971 const size_type __pos = __p -
begin();
1972 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1973 return iterator(_M_data() + __pos);
1976#if __cplusplus >= 201703L
1983 template<
typename _Tp>
1984 _GLIBCXX20_CONSTEXPR
1985 _If_sv<_Tp, basic_string&>
1986 insert(size_type __pos,
const _Tp& __svt)
1988 __sv_type __sv = __svt;
1989 return this->
insert(__pos, __sv.data(), __sv.size());
2000 template<
typename _Tp>
2001 _GLIBCXX20_CONSTEXPR
2002 _If_sv<_Tp, basic_string&>
2003 insert(size_type __pos1,
const _Tp& __svt,
2004 size_type __pos2, size_type __n =
npos)
2006 __sv_type __sv = __svt;
2007 return this->
replace(__pos1, size_type(0),
2009 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2010 std::__sv_limit(__sv.size(), __pos2, __n));
2029 _GLIBCXX20_CONSTEXPR
2031 erase(size_type __pos = 0, size_type __n =
npos)
2033 _M_check(__pos,
"basic_string::erase");
2035 this->_M_set_length(__pos);
2037 this->_M_erase(__pos, _M_limit(__pos, __n));
2049 _GLIBCXX20_CONSTEXPR
2051 erase(__const_iterator __position)
2053 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2054 && __position <
end());
2055 const size_type __pos = __position -
begin();
2056 this->_M_erase(__pos, size_type(1));
2057 return iterator(_M_data() + __pos);
2069 _GLIBCXX20_CONSTEXPR
2071 erase(__const_iterator __first, __const_iterator __last)
2073 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2074 && __last <=
end());
2075 const size_type __pos = __first -
begin();
2076 if (__last ==
end())
2077 this->_M_set_length(__pos);
2079 this->_M_erase(__pos, __last - __first);
2080 return iterator(this->_M_data() + __pos);
2083#if __cplusplus >= 201103L
2089 _GLIBCXX20_CONSTEXPR
2093 __glibcxx_assert(!
empty());
2094 _M_erase(
size() - 1, 1);
2115 _GLIBCXX20_CONSTEXPR
2118 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2138 _GLIBCXX20_CONSTEXPR
2141 size_type __pos2, size_type __n2 =
npos)
2142 {
return this->
replace(__pos1, __n1, __str._M_data()
2143 + __str._M_check(__pos2,
"basic_string::replace"),
2144 __str._M_limit(__pos2, __n2)); }
2164 _GLIBCXX20_CONSTEXPR
2166 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2169 __glibcxx_requires_string_len(__s, __n2);
2170 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2171 _M_limit(__pos, __n1), __s, __n2);
2190 _GLIBCXX20_CONSTEXPR
2192 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2194 __glibcxx_requires_string(__s);
2195 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2215 _GLIBCXX20_CONSTEXPR
2217 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2218 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2219 _M_limit(__pos, __n1), __n2, __c); }
2234 _GLIBCXX20_CONSTEXPR
2236 replace(__const_iterator __i1, __const_iterator __i2,
2238 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2255 _GLIBCXX20_CONSTEXPR
2257 replace(__const_iterator __i1, __const_iterator __i2,
2258 const _CharT* __s, size_type __n)
2260 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2262 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2278 _GLIBCXX20_CONSTEXPR
2280 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2282 __glibcxx_requires_string(__s);
2283 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2300 _GLIBCXX20_CONSTEXPR
2302 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2305 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2307 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2325#if __cplusplus >= 201103L
2326 template<
class _InputIterator,
2327 typename = std::_RequireInputIter<_InputIterator>>
2328 _GLIBCXX20_CONSTEXPR
2330 replace(const_iterator __i1, const_iterator __i2,
2331 _InputIterator __k1, _InputIterator __k2)
2333 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2335 __glibcxx_requires_valid_range(__k1, __k2);
2336 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2337 std::__false_type());
2340 template<
class _InputIterator>
2341#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2342 typename __enable_if_not_native_iterator<_InputIterator>::__type
2346 replace(iterator __i1, iterator __i2,
2347 _InputIterator __k1, _InputIterator __k2)
2349 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2351 __glibcxx_requires_valid_range(__k1, __k2);
2352 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2353 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2359 _GLIBCXX20_CONSTEXPR
2361 replace(__const_iterator __i1, __const_iterator __i2,
2362 _CharT* __k1, _CharT* __k2)
2364 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2366 __glibcxx_requires_valid_range(__k1, __k2);
2371 _GLIBCXX20_CONSTEXPR
2373 replace(__const_iterator __i1, __const_iterator __i2,
2374 const _CharT* __k1,
const _CharT* __k2)
2376 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2378 __glibcxx_requires_valid_range(__k1, __k2);
2383 _GLIBCXX20_CONSTEXPR
2385 replace(__const_iterator __i1, __const_iterator __i2,
2386 iterator __k1, iterator __k2)
2388 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2390 __glibcxx_requires_valid_range(__k1, __k2);
2392 __k1.base(), __k2 - __k1);
2395 _GLIBCXX20_CONSTEXPR
2397 replace(__const_iterator __i1, __const_iterator __i2,
2398 const_iterator __k1, const_iterator __k2)
2400 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2402 __glibcxx_requires_valid_range(__k1, __k2);
2404 __k1.base(), __k2 - __k1);
2407#if __cplusplus >= 201103L
2422 _GLIBCXX20_CONSTEXPR
2424 initializer_list<_CharT> __l)
2425 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2428#if __cplusplus >= 201703L
2436 template<
typename _Tp>
2437 _GLIBCXX20_CONSTEXPR
2438 _If_sv<_Tp, basic_string&>
2439 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2441 __sv_type __sv = __svt;
2442 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2454 template<
typename _Tp>
2455 _GLIBCXX20_CONSTEXPR
2456 _If_sv<_Tp, basic_string&>
2457 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2458 size_type __pos2, size_type __n2 =
npos)
2460 __sv_type __sv = __svt;
2461 return this->
replace(__pos1, __n1,
2463 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2464 std::__sv_limit(__sv.size(), __pos2, __n2));
2476 template<
typename _Tp>
2477 _GLIBCXX20_CONSTEXPR
2478 _If_sv<_Tp, basic_string&>
2479 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2481 __sv_type __sv = __svt;
2482 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2487 template<
class _Integer>
2488 _GLIBCXX20_CONSTEXPR
2490 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2491 _Integer __n, _Integer __val, __true_type)
2492 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2494 template<
class _InputIterator>
2495 _GLIBCXX20_CONSTEXPR
2497 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2498 _InputIterator __k1, _InputIterator __k2,
2501 _GLIBCXX20_CONSTEXPR
2503 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2506 __attribute__((__noinline__, __noclone__, __cold__))
void
2507 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2508 const size_type __len2,
const size_type __how_much);
2510 _GLIBCXX20_CONSTEXPR
2512 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2513 const size_type __len2);
2515 _GLIBCXX20_CONSTEXPR
2517 _M_append(
const _CharT* __s, size_type __n);
2533 _GLIBCXX20_CONSTEXPR
2535 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2544 _GLIBCXX20_CONSTEXPR
2555 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2557 c_str() const _GLIBCXX_NOEXCEPT
2558 {
return _M_data(); }
2568 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2570 data() const _GLIBCXX_NOEXCEPT
2571 {
return _M_data(); }
2573#if __cplusplus >= 201703L
2580 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2583 {
return _M_data(); }
2589 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2592 {
return _M_get_allocator(); }
2606 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2608 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2621 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2625 {
return this->
find(__str.data(), __pos, __str.size()); }
2627#if __cplusplus >= 201703L
2634 template<
typename _Tp>
2635 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2636 _If_sv<_Tp, size_type>
2637 find(
const _Tp& __svt, size_type __pos = 0) const
2638 noexcept(is_same<_Tp, __sv_type>::value)
2640 __sv_type __sv = __svt;
2641 return this->
find(__sv.data(), __pos, __sv.size());
2655 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2657 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2659 __glibcxx_requires_string(__s);
2660 return this->
find(__s, __pos, traits_type::length(__s));
2673 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2675 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2687 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2691 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2693#if __cplusplus >= 201703L
2700 template<
typename _Tp>
2701 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2702 _If_sv<_Tp, size_type>
2703 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2704 noexcept(is_same<_Tp, __sv_type>::value)
2706 __sv_type __sv = __svt;
2707 return this->
rfind(__sv.data(), __pos, __sv.size());
2723 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2725 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2738 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2740 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2742 __glibcxx_requires_string(__s);
2743 return this->
rfind(__s, __pos, traits_type::length(__s));
2756 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2758 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2771 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2775 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2777#if __cplusplus >= 201703L
2785 template<
typename _Tp>
2786 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2787 _If_sv<_Tp, size_type>
2789 noexcept(is_same<_Tp, __sv_type>::value)
2791 __sv_type __sv = __svt;
2792 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2808 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2810 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2823 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2828 __glibcxx_requires_string(__s);
2829 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2844 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2846 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2847 {
return this->
find(__c, __pos); }
2860 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2864 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2866#if __cplusplus >= 201703L
2874 template<
typename _Tp>
2875 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2876 _If_sv<_Tp, size_type>
2878 noexcept(is_same<_Tp, __sv_type>::value)
2880 __sv_type __sv = __svt;
2881 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2897 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2899 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2912 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2917 __glibcxx_requires_string(__s);
2918 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2933 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2936 {
return this->
rfind(__c, __pos); }
2948 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2954#if __cplusplus >= 201703L
2962 template<
typename _Tp>
2963 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2964 _If_sv<_Tp, size_type>
2966 noexcept(is_same<_Tp, __sv_type>::value)
2968 __sv_type __sv = __svt;
2985 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2988 size_type __n)
const _GLIBCXX_NOEXCEPT;
3000 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3005 __glibcxx_requires_string(__s);
3019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3035 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3041#if __cplusplus >= 201703L
3049 template<
typename _Tp>
3050 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3051 _If_sv<_Tp, size_type>
3053 noexcept(is_same<_Tp, __sv_type>::value)
3055 __sv_type __sv = __svt;
3072 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3075 size_type __n)
const _GLIBCXX_NOEXCEPT;
3087 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3092 __glibcxx_requires_string(__s);
3106 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3123 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3125 substr(size_type __pos = 0, size_type __n =
npos)
const
3127 _M_check(__pos,
"basic_string::substr"), __n); }
3143 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3147 const size_type __size = this->
size();
3148 const size_type __osize = __str.size();
3149 const size_type __len =
std::min(__size, __osize);
3151 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3153 __r = _S_compare(__size, __osize);
3157#if __cplusplus >= 201703L
3163 template<
typename _Tp>
3164 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3166 compare(
const _Tp& __svt)
const
3167 noexcept(is_same<_Tp, __sv_type>::value)
3169 __sv_type __sv = __svt;
3170 const size_type __size = this->
size();
3171 const size_type __osize = __sv.size();
3172 const size_type __len =
std::min(__size, __osize);
3174 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3176 __r = _S_compare(__size, __osize);
3188 template<
typename _Tp>
3189 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3191 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3192 noexcept(is_same<_Tp, __sv_type>::value)
3194 __sv_type __sv = __svt;
3195 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3208 template<
typename _Tp>
3209 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3211 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3212 size_type __pos2, size_type __n2 =
npos)
const
3213 noexcept(is_same<_Tp, __sv_type>::value)
3215 __sv_type __sv = __svt;
3216 return __sv_type(*
this)
3217 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3240 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3244 _M_check(__pos,
"basic_string::compare");
3245 __n = _M_limit(__pos, __n);
3246 const size_type __osize = __str.size();
3247 const size_type __len =
std::min(__n, __osize);
3248 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3250 __r = _S_compare(__n, __osize);
3277 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3280 size_type __pos2, size_type __n2 =
npos)
const
3282 _M_check(__pos1,
"basic_string::compare");
3283 __str._M_check(__pos2,
"basic_string::compare");
3284 __n1 = _M_limit(__pos1, __n1);
3285 __n2 = __str._M_limit(__pos2, __n2);
3286 const size_type __len =
std::min(__n1, __n2);
3287 int __r = traits_type::compare(_M_data() + __pos1,
3288 __str.data() + __pos2, __len);
3290 __r = _S_compare(__n1, __n2);
3308 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3310 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3312 __glibcxx_requires_string(__s);
3313 const size_type __size = this->
size();
3314 const size_type __osize = traits_type::length(__s);
3315 const size_type __len =
std::min(__size, __osize);
3316 int __r = traits_type::compare(_M_data(), __s, __len);
3318 __r = _S_compare(__size, __osize);
3343 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3345 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3347 __glibcxx_requires_string(__s);
3348 _M_check(__pos,
"basic_string::compare");
3349 __n1 = _M_limit(__pos, __n1);
3350 const size_type __osize = traits_type::length(__s);
3351 const size_type __len =
std::min(__n1, __osize);
3352 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3354 __r = _S_compare(__n1, __osize);
3382 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3384 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3385 size_type __n2)
const
3387 __glibcxx_requires_string_len(__s, __n2);
3388 _M_check(__pos,
"basic_string::compare");
3389 __n1 = _M_limit(__pos, __n1);
3390 const size_type __len =
std::min(__n1, __n2);
3391 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3393 __r = _S_compare(__n1, __n2);
3397#if __cplusplus >= 202002L
3400 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3401 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3405 starts_with(_CharT __x)
const noexcept
3406 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3408 [[nodiscard, __gnu__::__nonnull__]]
3410 starts_with(
const _CharT* __x)
const noexcept
3411 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3415 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3416 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3420 ends_with(_CharT __x)
const noexcept
3421 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3423 [[nodiscard, __gnu__::__nonnull__]]
3425 ends_with(
const _CharT* __x)
const noexcept
3426 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3429#if __cplusplus > 202002L
3432 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3433 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3437 contains(_CharT __x)
const noexcept
3438 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3440 [[nodiscard, __gnu__::__nonnull__]]
3442 contains(
const _CharT* __x)
const noexcept
3443 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3447 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3449_GLIBCXX_END_NAMESPACE_CXX11
3450_GLIBCXX_END_NAMESPACE_VERSION
3454namespace std _GLIBCXX_VISIBILITY(default)
3456_GLIBCXX_BEGIN_NAMESPACE_VERSION
3458#if __cpp_deduction_guides >= 201606
3459_GLIBCXX_BEGIN_NAMESPACE_CXX11
3460 template<
typename _InputIterator,
typename _CharT
3461 =
typename iterator_traits<_InputIterator>::value_type,
3462 typename _Allocator = allocator<_CharT>,
3463 typename = _RequireInputIter<_InputIterator>,
3464 typename = _RequireAllocator<_Allocator>>
3465 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3466 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3470 template<
typename _CharT,
typename _Traits,
3471 typename _Allocator = allocator<_CharT>,
3472 typename = _RequireAllocator<_Allocator>>
3473 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3474 -> basic_string<_CharT, _Traits, _Allocator>;
3476 template<
typename _CharT,
typename _Traits,
3477 typename _Allocator = allocator<_CharT>,
3478 typename = _RequireAllocator<_Allocator>>
3479 basic_string(basic_string_view<_CharT, _Traits>,
3480 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3481 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3482 const _Allocator& = _Allocator())
3483 -> basic_string<_CharT, _Traits, _Allocator>;
3484_GLIBCXX_END_NAMESPACE_CXX11
3487 template<
typename _Str>
3488 _GLIBCXX20_CONSTEXPR
3490 __str_concat(
typename _Str::value_type
const* __lhs,
3491 typename _Str::size_type __lhs_len,
3492 typename _Str::value_type
const* __rhs,
3493 typename _Str::size_type __rhs_len,
3494 typename _Str::allocator_type
const& __a)
3496 typedef typename _Str::allocator_type allocator_type;
3498 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3499 __str.reserve(__lhs_len + __rhs_len);
3500 __str.append(__lhs, __lhs_len);
3501 __str.append(__rhs, __rhs_len);
3512 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3513 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3514 inline basic_string<_CharT, _Traits, _Alloc>
3519 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3520 __rhs.c_str(), __rhs.size(),
3521 __lhs.get_allocator());
3530 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3531 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3532 inline basic_string<_CharT,_Traits,_Alloc>
3536 __glibcxx_requires_string(__lhs);
3538 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3539 __rhs.c_str(), __rhs.size(),
3540 __rhs.get_allocator());
3549 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3550 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3551 inline basic_string<_CharT,_Traits,_Alloc>
3555 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3556 __rhs.c_str(), __rhs.size(),
3557 __rhs.get_allocator());
3566 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3567 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3568 inline basic_string<_CharT, _Traits, _Alloc>
3570 const _CharT* __rhs)
3572 __glibcxx_requires_string(__rhs);
3574 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3575 __rhs, _Traits::length(__rhs),
3576 __lhs.get_allocator());
3584 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3585 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3586 inline basic_string<_CharT, _Traits, _Alloc>
3590 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3591 __builtin_addressof(__rhs), 1,
3592 __lhs.get_allocator());
3595#if __cplusplus >= 201103L
3596 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3597 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3598 inline basic_string<_CharT, _Traits, _Alloc>
3599 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3600 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3601 {
return std::move(__lhs.append(__rhs)); }
3603 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3604 _GLIBCXX20_CONSTEXPR
3605 inline basic_string<_CharT, _Traits, _Alloc>
3606 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3607 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3608 {
return std::move(__rhs.insert(0, __lhs)); }
3610 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3611 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3612 inline basic_string<_CharT, _Traits, _Alloc>
3613 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3614 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3616#if _GLIBCXX_USE_CXX11_ABI
3617 using _Alloc_traits = allocator_traits<_Alloc>;
3618 bool __use_rhs =
false;
3619 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3621 else if (__lhs.get_allocator() == __rhs.get_allocator())
3626 const auto __size = __lhs.size() + __rhs.size();
3627 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3628 return std::move(__rhs.insert(0, __lhs));
3633 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3634 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3635 inline basic_string<_CharT, _Traits, _Alloc>
3637 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3638 {
return std::move(__rhs.insert(0, __lhs)); }
3640 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3641 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3642 inline basic_string<_CharT, _Traits, _Alloc>
3644 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3645 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3647 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3648 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3649 inline basic_string<_CharT, _Traits, _Alloc>
3650 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3651 const _CharT* __rhs)
3652 {
return std::move(__lhs.append(__rhs)); }
3654 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3655 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3656 inline basic_string<_CharT, _Traits, _Alloc>
3657 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3659 {
return std::move(__lhs.append(1, __rhs)); }
3669 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3670 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3676 return __lhs.size() == __rhs.size()
3677 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3686 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3687 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3690 const _CharT* __rhs)
3692 return __lhs.size() == _Traits::length(__rhs)
3693 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3696#if __cpp_lib_three_way_comparison
3704 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3707 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3708 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3709 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3710 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3719 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3722 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3723 const _CharT* __rhs)
noexcept
3724 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3725 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3733 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3736 operator==(
const _CharT* __lhs,
3738 {
return __rhs == __lhs; }
3747 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3753 {
return !(__lhs == __rhs); }
3761 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3764 operator!=(
const _CharT* __lhs,
3766 {
return !(__rhs == __lhs); }
3774 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3778 const _CharT* __rhs)
3779 {
return !(__lhs == __rhs); }
3788 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3794 {
return __lhs.compare(__rhs) < 0; }
3802 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3806 const _CharT* __rhs)
3807 {
return __lhs.compare(__rhs) < 0; }
3815 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3818 operator<(
const _CharT* __lhs,
3820 {
return __rhs.compare(__lhs) > 0; }
3829 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3835 {
return __lhs.compare(__rhs) > 0; }
3843 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3847 const _CharT* __rhs)
3848 {
return __lhs.compare(__rhs) > 0; }
3856 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3859 operator>(
const _CharT* __lhs,
3861 {
return __rhs.compare(__lhs) < 0; }
3870 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3876 {
return __lhs.compare(__rhs) <= 0; }
3884 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3888 const _CharT* __rhs)
3889 {
return __lhs.compare(__rhs) <= 0; }
3897 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3900 operator<=(
const _CharT* __lhs,
3902 {
return __rhs.compare(__lhs) >= 0; }
3911 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3917 {
return __lhs.compare(__rhs) >= 0; }
3925 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3929 const _CharT* __rhs)
3930 {
return __lhs.compare(__rhs) >= 0; }
3938 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3941 operator>=(
const _CharT* __lhs,
3943 {
return __rhs.compare(__lhs) <= 0; }
3953 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3954 _GLIBCXX20_CONSTEXPR
3958 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
3959 { __lhs.swap(__rhs); }
3974 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3975 basic_istream<_CharT, _Traits>&
3976 operator>>(basic_istream<_CharT, _Traits>& __is,
3977 basic_string<_CharT, _Traits, _Alloc>& __str);
3980 basic_istream<char>&
3992 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3999 return __ostream_insert(__os, __str.data(), __str.size());
4015 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4016 basic_istream<_CharT, _Traits>&
4017 getline(basic_istream<_CharT, _Traits>& __is,
4018 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4032 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4033 inline basic_istream<_CharT, _Traits>&
4038#if __cplusplus >= 201103L
4040 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4041 inline basic_istream<_CharT, _Traits>&
4047 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4048 inline basic_istream<_CharT, _Traits>&
4055 basic_istream<char>&
4056 getline(basic_istream<char>& __in, basic_string<char>& __str,
4059#ifdef _GLIBCXX_USE_WCHAR_T
4061 basic_istream<wchar_t>&
4062 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4066_GLIBCXX_END_NAMESPACE_VERSION
4069#if __cplusplus >= 201103L
4074namespace std _GLIBCXX_VISIBILITY(default)
4076_GLIBCXX_BEGIN_NAMESPACE_VERSION
4077_GLIBCXX_BEGIN_NAMESPACE_CXX11
4079#if _GLIBCXX_USE_C99_STDLIB
4082 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4083 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4087 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4088 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4091 inline unsigned long
4092 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4093 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4097 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4098 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4101 inline unsigned long long
4102 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4103 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4108 stof(
const string& __str,
size_t* __idx = 0)
4109 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4112 stod(
const string& __str,
size_t* __idx = 0)
4113 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4116 stold(
const string& __str,
size_t* __idx = 0)
4117 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4124 to_string(
int __val)
4125#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4129 const bool __neg = __val < 0;
4130 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4131 const auto __len = __detail::__to_chars_len(__uval);
4132 string __str(__neg + __len,
'-');
4133 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4139 to_string(
unsigned __val)
4140#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4144 string __str(__detail::__to_chars_len(__val),
'\0');
4145 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4151 to_string(
long __val)
4152#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4156 const bool __neg = __val < 0;
4157 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4158 const auto __len = __detail::__to_chars_len(__uval);
4159 string __str(__neg + __len,
'-');
4160 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4166 to_string(
unsigned long __val)
4167#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4171 string __str(__detail::__to_chars_len(__val),
'\0');
4172 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4178 to_string(
long long __val)
4180 const bool __neg = __val < 0;
4181 const unsigned long long __uval
4182 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4183 const auto __len = __detail::__to_chars_len(__uval);
4184 string __str(__neg + __len,
'-');
4185 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4191 to_string(
unsigned long long __val)
4193 string __str(__detail::__to_chars_len(__val),
'\0');
4194 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4198#if _GLIBCXX_USE_C99_STDIO
4203 to_string(
float __val)
4206 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4207 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4213 to_string(
double __val)
4216 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4217 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4223 to_string(
long double __val)
4226 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4227 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4232#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4234 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4235 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4239 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4240 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4243 inline unsigned long
4244 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4245 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4249 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4250 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4253 inline unsigned long long
4254 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4255 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4260 stof(
const wstring& __str,
size_t* __idx = 0)
4261 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4264 stod(
const wstring& __str,
size_t* __idx = 0)
4265 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4268 stold(
const wstring& __str,
size_t* __idx = 0)
4269 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4271#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4275 to_wstring(
int __val)
4276 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
4281 to_wstring(
unsigned __val)
4282 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4283 4 *
sizeof(
unsigned),
4288 to_wstring(
long __val)
4289 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
4294 to_wstring(
unsigned long __val)
4295 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4296 4 *
sizeof(
unsigned long),
4301 to_wstring(
long long __val)
4302 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4303 4 *
sizeof(
long long),
4308 to_wstring(
unsigned long long __val)
4309 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4310 4 *
sizeof(
unsigned long long),
4315 to_wstring(
float __val)
4318 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4319 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4325 to_wstring(
double __val)
4328 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4329 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4335 to_wstring(
long double __val)
4338 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4339 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4345_GLIBCXX_END_NAMESPACE_CXX11
4346_GLIBCXX_END_NAMESPACE_VERSION
4351#if __cplusplus >= 201103L
4355namespace std _GLIBCXX_VISIBILITY(default)
4357_GLIBCXX_BEGIN_NAMESPACE_VERSION
4362 template<
typename _CharT,
typename _Alloc,
4363 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4364 struct __str_hash_base
4365 :
public __hash_base<size_t, _StrT>
4369 operator()(
const _StrT& __s)
const noexcept
4370 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4373#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4375 template<
typename _Alloc>
4377 :
public __str_hash_base<char, _Alloc>
4381 template<
typename _Alloc>
4383 :
public __str_hash_base<wchar_t, _Alloc>
4386 template<
typename _Alloc>
4393#ifdef _GLIBCXX_USE_CHAR8_T
4395 template<
typename _Alloc>
4396 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4397 :
public __str_hash_base<char8_t, _Alloc>
4402 template<
typename _Alloc>
4404 :
public __str_hash_base<char16_t, _Alloc>
4408 template<
typename _Alloc>
4410 :
public __str_hash_base<char32_t, _Alloc>
4413#if ! _GLIBCXX_INLINE_VERSION
4419#ifdef _GLIBCXX_USE_CHAR8_T
4420 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4424 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4425 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4430#if __cplusplus >= 201402L
4432#define __cpp_lib_string_udls 201304L
4434 inline namespace literals
4436 inline namespace string_literals
4438#pragma GCC diagnostic push
4439#pragma GCC diagnostic ignored "-Wliteral-suffix"
4441#if __cpp_lib_constexpr_string >= 201907L
4442# define _GLIBCXX_STRING_CONSTEXPR constexpr
4444# define _GLIBCXX_STRING_CONSTEXPR
4447 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4448 inline basic_string<char>
4449 operator""s(
const char* __str,
size_t __len)
4450 {
return basic_string<char>{__str, __len}; }
4452 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4453 inline basic_string<wchar_t>
4454 operator""s(
const wchar_t* __str,
size_t __len)
4455 {
return basic_string<wchar_t>{__str, __len}; }
4457#ifdef _GLIBCXX_USE_CHAR8_T
4458 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4459 inline basic_string<char8_t>
4460 operator""s(
const char8_t* __str,
size_t __len)
4461 {
return basic_string<char8_t>{__str, __len}; }
4464 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4465 inline basic_string<char16_t>
4466 operator""s(
const char16_t* __str,
size_t __len)
4467 {
return basic_string<char16_t>{__str, __len}; }
4469 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4470 inline basic_string<char32_t>
4471 operator""s(
const char32_t* __str,
size_t __len)
4472 {
return basic_string<char32_t>{__str, __len}; }
4474#undef _GLIBCXX_STRING_CONSTEXPR
4475#pragma GCC diagnostic pop
4479#if __cplusplus >= 201703L
4480 namespace __detail::__variant
4482 template<
typename>
struct _Never_valueless_alt;
4486 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4487 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4489 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4490 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4497_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.