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
1149 template<
typename _Operation>
1151 resize_and_overwrite(size_type __n, _Operation __op);
1158 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1162 return _M_is_local() ? size_type(_S_local_capacity)
1163 : _M_allocated_capacity;
1183 _GLIBCXX20_CONSTEXPR
1190#if __cplusplus > 201703L
1191 [[deprecated(
"use shrink_to_fit() instead")]]
1193 _GLIBCXX20_CONSTEXPR
1200 _GLIBCXX20_CONSTEXPR
1202 clear() _GLIBCXX_NOEXCEPT
1203 { _M_set_length(0); }
1209 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1211 empty() const _GLIBCXX_NOEXCEPT
1212 {
return this->
size() == 0; }
1225 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1227 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1229 __glibcxx_assert(__pos <=
size());
1230 return _M_data()[__pos];
1243 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1249 __glibcxx_assert(__pos <=
size());
1251 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1252 return _M_data()[__pos];
1265 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1267 at(size_type __n)
const
1269 if (__n >= this->
size())
1270 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1271 "(which is %zu) >= this->size() "
1274 return _M_data()[__n];
1287 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1292 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1293 "(which is %zu) >= this->size() "
1296 return _M_data()[__n];
1299#if __cplusplus >= 201103L
1304 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1308 __glibcxx_assert(!
empty());
1316 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1318 front() const noexcept
1320 __glibcxx_assert(!
empty());
1328 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1332 __glibcxx_assert(!
empty());
1340 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1342 back() const noexcept
1344 __glibcxx_assert(!
empty());
1355 _GLIBCXX20_CONSTEXPR
1358 {
return this->
append(__str); }
1365 _GLIBCXX20_CONSTEXPR
1368 {
return this->
append(__s); }
1375 _GLIBCXX20_CONSTEXPR
1383#if __cplusplus >= 201103L
1389 _GLIBCXX20_CONSTEXPR
1392 {
return this->
append(__l.begin(), __l.size()); }
1395#if __cplusplus >= 201703L
1401 template<
typename _Tp>
1402 _GLIBCXX20_CONSTEXPR
1403 _If_sv<_Tp, basic_string&>
1405 {
return this->
append(__svt); }
1413 _GLIBCXX20_CONSTEXPR
1416 {
return this->
append(__str._M_data(), __str.size()); }
1431 _GLIBCXX20_CONSTEXPR
1434 {
return this->
append(__str._M_data()
1435 + __str._M_check(__pos,
"basic_string::append"),
1436 __str._M_limit(__pos, __n)); }
1444 _GLIBCXX20_CONSTEXPR
1446 append(
const _CharT* __s, size_type __n)
1448 __glibcxx_requires_string_len(__s, __n);
1449 _M_check_length(size_type(0), __n,
"basic_string::append");
1450 return _M_append(__s, __n);
1458 _GLIBCXX20_CONSTEXPR
1460 append(
const _CharT* __s)
1462 __glibcxx_requires_string(__s);
1463 const size_type __n = traits_type::length(__s);
1464 _M_check_length(size_type(0), __n,
"basic_string::append");
1465 return _M_append(__s, __n);
1476 _GLIBCXX20_CONSTEXPR
1478 append(size_type __n, _CharT __c)
1479 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1481#if __cplusplus >= 201103L
1487 _GLIBCXX20_CONSTEXPR
1489 append(initializer_list<_CharT> __l)
1490 {
return this->
append(__l.begin(), __l.size()); }
1501#if __cplusplus >= 201103L
1502 template<
class _InputIterator,
1503 typename = std::_RequireInputIter<_InputIterator>>
1504 _GLIBCXX20_CONSTEXPR
1506 template<
class _InputIterator>
1509 append(_InputIterator __first, _InputIterator __last)
1512#if __cplusplus >= 201703L
1518 template<
typename _Tp>
1519 _GLIBCXX20_CONSTEXPR
1520 _If_sv<_Tp, basic_string&>
1523 __sv_type __sv = __svt;
1524 return this->
append(__sv.data(), __sv.size());
1534 template<
typename _Tp>
1535 _GLIBCXX20_CONSTEXPR
1536 _If_sv<_Tp, basic_string&>
1537 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1539 __sv_type __sv = __svt;
1540 return _M_append(__sv.data()
1541 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1542 std::__sv_limit(__sv.size(), __pos, __n));
1550 _GLIBCXX20_CONSTEXPR
1554 const size_type __size = this->
size();
1556 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1557 traits_type::assign(this->_M_data()[__size], __c);
1558 this->_M_set_length(__size + 1);
1566 _GLIBCXX20_CONSTEXPR
1570#if __cplusplus >= 201103L
1571 if (_Alloc_traits::_S_propagate_on_copy_assign())
1573 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1574 && _M_get_allocator() != __str._M_get_allocator())
1578 if (__str.size() <= _S_local_capacity)
1580 _M_destroy(_M_allocated_capacity);
1581 _M_data(_M_use_local_data());
1586 const auto __len = __str.size();
1587 auto __alloc = __str._M_get_allocator();
1589 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1590 _M_destroy(_M_allocated_capacity);
1593 _M_set_length(__len);
1596 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1599 this->_M_assign(__str);
1603#if __cplusplus >= 201103L
1612 _GLIBCXX20_CONSTEXPR
1615 noexcept(_Alloc_traits::_S_nothrow_move())
1636 _GLIBCXX20_CONSTEXPR
1639 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1640 + __str._M_check(__pos,
"basic_string::assign"),
1641 __str._M_limit(__pos, __n)); }
1653 _GLIBCXX20_CONSTEXPR
1655 assign(
const _CharT* __s, size_type __n)
1657 __glibcxx_requires_string_len(__s, __n);
1658 return _M_replace(size_type(0), this->
size(), __s, __n);
1670 _GLIBCXX20_CONSTEXPR
1672 assign(
const _CharT* __s)
1674 __glibcxx_requires_string(__s);
1675 return _M_replace(size_type(0), this->
size(), __s,
1676 traits_type::length(__s));
1688 _GLIBCXX20_CONSTEXPR
1690 assign(size_type __n, _CharT __c)
1691 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1701#if __cplusplus >= 201103L
1702 template<
class _InputIterator,
1703 typename = std::_RequireInputIter<_InputIterator>>
1704 _GLIBCXX20_CONSTEXPR
1706 template<
class _InputIterator>
1709 assign(_InputIterator __first, _InputIterator __last)
1712#if __cplusplus >= 201103L
1718 _GLIBCXX20_CONSTEXPR
1720 assign(initializer_list<_CharT> __l)
1721 {
return this->
assign(__l.begin(), __l.size()); }
1724#if __cplusplus >= 201703L
1730 template<
typename _Tp>
1731 _GLIBCXX20_CONSTEXPR
1732 _If_sv<_Tp, basic_string&>
1735 __sv_type __sv = __svt;
1736 return this->
assign(__sv.data(), __sv.size());
1746 template<
typename _Tp>
1747 _GLIBCXX20_CONSTEXPR
1748 _If_sv<_Tp, basic_string&>
1749 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1751 __sv_type __sv = __svt;
1752 return _M_replace(size_type(0), this->
size(),
1754 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1755 std::__sv_limit(__sv.size(), __pos, __n));
1759#if __cplusplus >= 201103L
1775 _GLIBCXX20_CONSTEXPR
1777 insert(const_iterator __p, size_type __n, _CharT __c)
1779 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1780 const size_type __pos = __p -
begin();
1781 this->
replace(__p, __p, __n, __c);
1782 return iterator(this->_M_data() + __pos);
1799 insert(iterator __p, size_type __n, _CharT __c)
1800 { this->
replace(__p, __p, __n, __c); }
1803#if __cplusplus >= 201103L
1818 template<
class _InputIterator,
1819 typename = std::_RequireInputIter<_InputIterator>>
1820 _GLIBCXX20_CONSTEXPR
1822 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1824 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1825 const size_type __pos = __p -
begin();
1826 this->
replace(__p, __p, __beg, __end);
1827 return iterator(this->_M_data() + __pos);
1842 template<
class _InputIterator>
1844 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1845 { this->
replace(__p, __p, __beg, __end); }
1848#if __cplusplus >= 201103L
1855 _GLIBCXX20_CONSTEXPR
1857 insert(const_iterator __p, initializer_list<_CharT> __l)
1858 {
return this->
insert(__p, __l.begin(), __l.end()); }
1860#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1863 insert(iterator __p, initializer_list<_CharT> __l)
1865 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1866 this->
insert(__p -
begin(), __l.begin(), __l.size());
1883 _GLIBCXX20_CONSTEXPR
1886 {
return this->
replace(__pos1, size_type(0),
1887 __str._M_data(), __str.size()); }
1907 _GLIBCXX20_CONSTEXPR
1910 size_type __pos2, size_type __n =
npos)
1911 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1912 + __str._M_check(__pos2,
"basic_string::insert"),
1913 __str._M_limit(__pos2, __n)); }
1931 _GLIBCXX20_CONSTEXPR
1933 insert(size_type __pos,
const _CharT* __s, size_type __n)
1934 {
return this->
replace(__pos, size_type(0), __s, __n); }
1951 _GLIBCXX20_CONSTEXPR
1953 insert(size_type __pos,
const _CharT* __s)
1955 __glibcxx_requires_string(__s);
1956 return this->
replace(__pos, size_type(0), __s,
1957 traits_type::length(__s));
1976 _GLIBCXX20_CONSTEXPR
1978 insert(size_type __pos, size_type __n, _CharT __c)
1979 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1980 size_type(0), __n, __c); }
1995 _GLIBCXX20_CONSTEXPR
1997 insert(__const_iterator __p, _CharT __c)
1999 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2000 const size_type __pos = __p -
begin();
2001 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2002 return iterator(_M_data() + __pos);
2005#if __cplusplus >= 201703L
2012 template<
typename _Tp>
2013 _GLIBCXX20_CONSTEXPR
2014 _If_sv<_Tp, basic_string&>
2015 insert(size_type __pos,
const _Tp& __svt)
2017 __sv_type __sv = __svt;
2018 return this->
insert(__pos, __sv.data(), __sv.size());
2029 template<
typename _Tp>
2030 _GLIBCXX20_CONSTEXPR
2031 _If_sv<_Tp, basic_string&>
2032 insert(size_type __pos1,
const _Tp& __svt,
2033 size_type __pos2, size_type __n =
npos)
2035 __sv_type __sv = __svt;
2036 return this->
replace(__pos1, size_type(0),
2038 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2039 std::__sv_limit(__sv.size(), __pos2, __n));
2058 _GLIBCXX20_CONSTEXPR
2060 erase(size_type __pos = 0, size_type __n =
npos)
2062 _M_check(__pos,
"basic_string::erase");
2064 this->_M_set_length(__pos);
2066 this->_M_erase(__pos, _M_limit(__pos, __n));
2078 _GLIBCXX20_CONSTEXPR
2080 erase(__const_iterator __position)
2082 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2083 && __position <
end());
2084 const size_type __pos = __position -
begin();
2085 this->_M_erase(__pos, size_type(1));
2086 return iterator(_M_data() + __pos);
2098 _GLIBCXX20_CONSTEXPR
2100 erase(__const_iterator __first, __const_iterator __last)
2102 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2103 && __last <=
end());
2104 const size_type __pos = __first -
begin();
2105 if (__last ==
end())
2106 this->_M_set_length(__pos);
2108 this->_M_erase(__pos, __last - __first);
2109 return iterator(this->_M_data() + __pos);
2112#if __cplusplus >= 201103L
2118 _GLIBCXX20_CONSTEXPR
2122 __glibcxx_assert(!
empty());
2123 _M_erase(
size() - 1, 1);
2144 _GLIBCXX20_CONSTEXPR
2147 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2167 _GLIBCXX20_CONSTEXPR
2170 size_type __pos2, size_type __n2 =
npos)
2171 {
return this->
replace(__pos1, __n1, __str._M_data()
2172 + __str._M_check(__pos2,
"basic_string::replace"),
2173 __str._M_limit(__pos2, __n2)); }
2193 _GLIBCXX20_CONSTEXPR
2195 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2198 __glibcxx_requires_string_len(__s, __n2);
2199 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2200 _M_limit(__pos, __n1), __s, __n2);
2219 _GLIBCXX20_CONSTEXPR
2221 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2223 __glibcxx_requires_string(__s);
2224 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2244 _GLIBCXX20_CONSTEXPR
2246 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2247 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2248 _M_limit(__pos, __n1), __n2, __c); }
2263 _GLIBCXX20_CONSTEXPR
2265 replace(__const_iterator __i1, __const_iterator __i2,
2267 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2284 _GLIBCXX20_CONSTEXPR
2286 replace(__const_iterator __i1, __const_iterator __i2,
2287 const _CharT* __s, size_type __n)
2289 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2291 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2307 _GLIBCXX20_CONSTEXPR
2309 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2311 __glibcxx_requires_string(__s);
2312 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2329 _GLIBCXX20_CONSTEXPR
2331 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2334 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2336 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2354#if __cplusplus >= 201103L
2355 template<
class _InputIterator,
2356 typename = std::_RequireInputIter<_InputIterator>>
2357 _GLIBCXX20_CONSTEXPR
2359 replace(const_iterator __i1, const_iterator __i2,
2360 _InputIterator __k1, _InputIterator __k2)
2362 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2364 __glibcxx_requires_valid_range(__k1, __k2);
2365 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2366 std::__false_type());
2369 template<
class _InputIterator>
2370#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2371 typename __enable_if_not_native_iterator<_InputIterator>::__type
2375 replace(iterator __i1, iterator __i2,
2376 _InputIterator __k1, _InputIterator __k2)
2378 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2380 __glibcxx_requires_valid_range(__k1, __k2);
2381 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2382 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2388 _GLIBCXX20_CONSTEXPR
2390 replace(__const_iterator __i1, __const_iterator __i2,
2391 _CharT* __k1, _CharT* __k2)
2393 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2395 __glibcxx_requires_valid_range(__k1, __k2);
2400 _GLIBCXX20_CONSTEXPR
2402 replace(__const_iterator __i1, __const_iterator __i2,
2403 const _CharT* __k1,
const _CharT* __k2)
2405 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2407 __glibcxx_requires_valid_range(__k1, __k2);
2412 _GLIBCXX20_CONSTEXPR
2414 replace(__const_iterator __i1, __const_iterator __i2,
2415 iterator __k1, iterator __k2)
2417 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2419 __glibcxx_requires_valid_range(__k1, __k2);
2421 __k1.base(), __k2 - __k1);
2424 _GLIBCXX20_CONSTEXPR
2426 replace(__const_iterator __i1, __const_iterator __i2,
2427 const_iterator __k1, const_iterator __k2)
2429 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2431 __glibcxx_requires_valid_range(__k1, __k2);
2433 __k1.base(), __k2 - __k1);
2436#if __cplusplus >= 201103L
2451 _GLIBCXX20_CONSTEXPR
2453 initializer_list<_CharT> __l)
2454 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2457#if __cplusplus >= 201703L
2465 template<
typename _Tp>
2466 _GLIBCXX20_CONSTEXPR
2467 _If_sv<_Tp, basic_string&>
2468 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2470 __sv_type __sv = __svt;
2471 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2483 template<
typename _Tp>
2484 _GLIBCXX20_CONSTEXPR
2485 _If_sv<_Tp, basic_string&>
2486 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2487 size_type __pos2, size_type __n2 =
npos)
2489 __sv_type __sv = __svt;
2490 return this->
replace(__pos1, __n1,
2492 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2493 std::__sv_limit(__sv.size(), __pos2, __n2));
2505 template<
typename _Tp>
2506 _GLIBCXX20_CONSTEXPR
2507 _If_sv<_Tp, basic_string&>
2508 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2510 __sv_type __sv = __svt;
2511 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2516 template<
class _Integer>
2517 _GLIBCXX20_CONSTEXPR
2519 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2520 _Integer __n, _Integer __val, __true_type)
2521 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2523 template<
class _InputIterator>
2524 _GLIBCXX20_CONSTEXPR
2526 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2527 _InputIterator __k1, _InputIterator __k2,
2530 _GLIBCXX20_CONSTEXPR
2532 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2535 __attribute__((__noinline__, __noclone__, __cold__))
void
2536 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2537 const size_type __len2,
const size_type __how_much);
2539 _GLIBCXX20_CONSTEXPR
2541 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2542 const size_type __len2);
2544 _GLIBCXX20_CONSTEXPR
2546 _M_append(
const _CharT* __s, size_type __n);
2562 _GLIBCXX20_CONSTEXPR
2564 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2573 _GLIBCXX20_CONSTEXPR
2584 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2586 c_str() const _GLIBCXX_NOEXCEPT
2587 {
return _M_data(); }
2597 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2599 data() const _GLIBCXX_NOEXCEPT
2600 {
return _M_data(); }
2602#if __cplusplus >= 201703L
2609 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2612 {
return _M_data(); }
2618 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2621 {
return _M_get_allocator(); }
2635 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2637 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2650 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2654 {
return this->
find(__str.data(), __pos, __str.size()); }
2656#if __cplusplus >= 201703L
2663 template<
typename _Tp>
2664 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2665 _If_sv<_Tp, size_type>
2666 find(
const _Tp& __svt, size_type __pos = 0) const
2667 noexcept(is_same<_Tp, __sv_type>::value)
2669 __sv_type __sv = __svt;
2670 return this->
find(__sv.data(), __pos, __sv.size());
2684 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2686 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2688 __glibcxx_requires_string(__s);
2689 return this->
find(__s, __pos, traits_type::length(__s));
2702 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2704 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2716 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2720 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2722#if __cplusplus >= 201703L
2729 template<
typename _Tp>
2730 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2731 _If_sv<_Tp, size_type>
2732 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2733 noexcept(is_same<_Tp, __sv_type>::value)
2735 __sv_type __sv = __svt;
2736 return this->
rfind(__sv.data(), __pos, __sv.size());
2752 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2754 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2767 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2769 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2771 __glibcxx_requires_string(__s);
2772 return this->
rfind(__s, __pos, traits_type::length(__s));
2785 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2787 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2800 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2804 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2806#if __cplusplus >= 201703L
2814 template<
typename _Tp>
2815 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2816 _If_sv<_Tp, size_type>
2818 noexcept(is_same<_Tp, __sv_type>::value)
2820 __sv_type __sv = __svt;
2821 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2837 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2839 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2852 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2857 __glibcxx_requires_string(__s);
2858 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2873 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2875 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2876 {
return this->
find(__c, __pos); }
2889 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2893 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2895#if __cplusplus >= 201703L
2903 template<
typename _Tp>
2904 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2905 _If_sv<_Tp, size_type>
2907 noexcept(is_same<_Tp, __sv_type>::value)
2909 __sv_type __sv = __svt;
2910 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2926 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2928 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2941 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2946 __glibcxx_requires_string(__s);
2947 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2962 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2965 {
return this->
rfind(__c, __pos); }
2977 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2983#if __cplusplus >= 201703L
2991 template<
typename _Tp>
2992 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2993 _If_sv<_Tp, size_type>
2995 noexcept(is_same<_Tp, __sv_type>::value)
2997 __sv_type __sv = __svt;
3014 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3017 size_type __n)
const _GLIBCXX_NOEXCEPT;
3029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3034 __glibcxx_requires_string(__s);
3048 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3064 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3070#if __cplusplus >= 201703L
3078 template<
typename _Tp>
3079 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3080 _If_sv<_Tp, size_type>
3082 noexcept(is_same<_Tp, __sv_type>::value)
3084 __sv_type __sv = __svt;
3101 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3104 size_type __n)
const _GLIBCXX_NOEXCEPT;
3116 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3121 __glibcxx_requires_string(__s);
3135 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3152 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3154 substr(size_type __pos = 0, size_type __n =
npos)
const
3156 _M_check(__pos,
"basic_string::substr"), __n); }
3172 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3176 const size_type __size = this->
size();
3177 const size_type __osize = __str.size();
3178 const size_type __len =
std::min(__size, __osize);
3180 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3182 __r = _S_compare(__size, __osize);
3186#if __cplusplus >= 201703L
3192 template<
typename _Tp>
3193 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3195 compare(
const _Tp& __svt)
const
3196 noexcept(is_same<_Tp, __sv_type>::value)
3198 __sv_type __sv = __svt;
3199 const size_type __size = this->
size();
3200 const size_type __osize = __sv.size();
3201 const size_type __len =
std::min(__size, __osize);
3203 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3205 __r = _S_compare(__size, __osize);
3217 template<
typename _Tp>
3218 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3220 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3221 noexcept(is_same<_Tp, __sv_type>::value)
3223 __sv_type __sv = __svt;
3224 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3237 template<
typename _Tp>
3238 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3240 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3241 size_type __pos2, size_type __n2 =
npos)
const
3242 noexcept(is_same<_Tp, __sv_type>::value)
3244 __sv_type __sv = __svt;
3245 return __sv_type(*
this)
3246 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3269 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3273 _M_check(__pos,
"basic_string::compare");
3274 __n = _M_limit(__pos, __n);
3275 const size_type __osize = __str.size();
3276 const size_type __len =
std::min(__n, __osize);
3277 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3279 __r = _S_compare(__n, __osize);
3306 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3309 size_type __pos2, size_type __n2 =
npos)
const
3311 _M_check(__pos1,
"basic_string::compare");
3312 __str._M_check(__pos2,
"basic_string::compare");
3313 __n1 = _M_limit(__pos1, __n1);
3314 __n2 = __str._M_limit(__pos2, __n2);
3315 const size_type __len =
std::min(__n1, __n2);
3316 int __r = traits_type::compare(_M_data() + __pos1,
3317 __str.data() + __pos2, __len);
3319 __r = _S_compare(__n1, __n2);
3337 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3339 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3341 __glibcxx_requires_string(__s);
3342 const size_type __size = this->
size();
3343 const size_type __osize = traits_type::length(__s);
3344 const size_type __len =
std::min(__size, __osize);
3345 int __r = traits_type::compare(_M_data(), __s, __len);
3347 __r = _S_compare(__size, __osize);
3372 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3374 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3376 __glibcxx_requires_string(__s);
3377 _M_check(__pos,
"basic_string::compare");
3378 __n1 = _M_limit(__pos, __n1);
3379 const size_type __osize = traits_type::length(__s);
3380 const size_type __len =
std::min(__n1, __osize);
3381 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3383 __r = _S_compare(__n1, __osize);
3411 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3413 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3414 size_type __n2)
const
3416 __glibcxx_requires_string_len(__s, __n2);
3417 _M_check(__pos,
"basic_string::compare");
3418 __n1 = _M_limit(__pos, __n1);
3419 const size_type __len =
std::min(__n1, __n2);
3420 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3422 __r = _S_compare(__n1, __n2);
3426#if __cplusplus >= 202002L
3429 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3430 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3434 starts_with(_CharT __x)
const noexcept
3435 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3437 [[nodiscard, __gnu__::__nonnull__]]
3439 starts_with(
const _CharT* __x)
const noexcept
3440 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3444 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3445 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3449 ends_with(_CharT __x)
const noexcept
3450 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3452 [[nodiscard, __gnu__::__nonnull__]]
3454 ends_with(
const _CharT* __x)
const noexcept
3455 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3458#if __cplusplus > 202002L
3461 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3462 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3466 contains(_CharT __x)
const noexcept
3467 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3469 [[nodiscard, __gnu__::__nonnull__]]
3471 contains(
const _CharT* __x)
const noexcept
3472 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3476 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3478_GLIBCXX_END_NAMESPACE_CXX11
3479_GLIBCXX_END_NAMESPACE_VERSION
3483namespace std _GLIBCXX_VISIBILITY(default)
3485_GLIBCXX_BEGIN_NAMESPACE_VERSION
3487#if __cpp_deduction_guides >= 201606
3488_GLIBCXX_BEGIN_NAMESPACE_CXX11
3489 template<
typename _InputIterator,
typename _CharT
3490 =
typename iterator_traits<_InputIterator>::value_type,
3491 typename _Allocator = allocator<_CharT>,
3492 typename = _RequireInputIter<_InputIterator>,
3493 typename = _RequireAllocator<_Allocator>>
3494 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3495 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3499 template<
typename _CharT,
typename _Traits,
3500 typename _Allocator = allocator<_CharT>,
3501 typename = _RequireAllocator<_Allocator>>
3502 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3503 -> basic_string<_CharT, _Traits, _Allocator>;
3505 template<
typename _CharT,
typename _Traits,
3506 typename _Allocator = allocator<_CharT>,
3507 typename = _RequireAllocator<_Allocator>>
3508 basic_string(basic_string_view<_CharT, _Traits>,
3509 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3510 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3511 const _Allocator& = _Allocator())
3512 -> basic_string<_CharT, _Traits, _Allocator>;
3513_GLIBCXX_END_NAMESPACE_CXX11
3516 template<
typename _Str>
3517 _GLIBCXX20_CONSTEXPR
3519 __str_concat(
typename _Str::value_type
const* __lhs,
3520 typename _Str::size_type __lhs_len,
3521 typename _Str::value_type
const* __rhs,
3522 typename _Str::size_type __rhs_len,
3523 typename _Str::allocator_type
const& __a)
3525 typedef typename _Str::allocator_type allocator_type;
3527 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3528 __str.reserve(__lhs_len + __rhs_len);
3529 __str.append(__lhs, __lhs_len);
3530 __str.append(__rhs, __rhs_len);
3541 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3542 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3543 inline basic_string<_CharT, _Traits, _Alloc>
3548 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3549 __rhs.c_str(), __rhs.size(),
3550 __lhs.get_allocator());
3559 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3560 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3561 inline basic_string<_CharT,_Traits,_Alloc>
3565 __glibcxx_requires_string(__lhs);
3567 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3568 __rhs.c_str(), __rhs.size(),
3569 __rhs.get_allocator());
3578 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3579 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3580 inline basic_string<_CharT,_Traits,_Alloc>
3584 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3585 __rhs.c_str(), __rhs.size(),
3586 __rhs.get_allocator());
3595 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3596 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3597 inline basic_string<_CharT, _Traits, _Alloc>
3599 const _CharT* __rhs)
3601 __glibcxx_requires_string(__rhs);
3603 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3604 __rhs, _Traits::length(__rhs),
3605 __lhs.get_allocator());
3613 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3614 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3615 inline basic_string<_CharT, _Traits, _Alloc>
3619 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3620 __builtin_addressof(__rhs), 1,
3621 __lhs.get_allocator());
3624#if __cplusplus >= 201103L
3625 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3626 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3627 inline basic_string<_CharT, _Traits, _Alloc>
3628 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3629 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3630 {
return std::move(__lhs.append(__rhs)); }
3632 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3633 _GLIBCXX20_CONSTEXPR
3634 inline basic_string<_CharT, _Traits, _Alloc>
3635 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3636 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3637 {
return std::move(__rhs.insert(0, __lhs)); }
3639 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3640 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3641 inline basic_string<_CharT, _Traits, _Alloc>
3642 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3643 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3645#if _GLIBCXX_USE_CXX11_ABI
3646 using _Alloc_traits = allocator_traits<_Alloc>;
3647 bool __use_rhs =
false;
3648 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3650 else if (__lhs.get_allocator() == __rhs.get_allocator())
3655 const auto __size = __lhs.size() + __rhs.size();
3656 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3657 return std::move(__rhs.insert(0, __lhs));
3662 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3663 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3664 inline basic_string<_CharT, _Traits, _Alloc>
3666 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3667 {
return std::move(__rhs.insert(0, __lhs)); }
3669 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3670 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3671 inline basic_string<_CharT, _Traits, _Alloc>
3673 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3674 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3676 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3677 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3678 inline basic_string<_CharT, _Traits, _Alloc>
3679 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3680 const _CharT* __rhs)
3681 {
return std::move(__lhs.append(__rhs)); }
3683 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3684 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3685 inline basic_string<_CharT, _Traits, _Alloc>
3686 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3688 {
return std::move(__lhs.append(1, __rhs)); }
3698 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3699 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3705 return __lhs.size() == __rhs.size()
3706 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3715 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3716 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3719 const _CharT* __rhs)
3721 return __lhs.size() == _Traits::length(__rhs)
3722 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3725#if __cpp_lib_three_way_comparison
3733 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3736 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3737 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3738 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3739 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3748 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3751 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3752 const _CharT* __rhs)
noexcept
3753 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3754 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3762 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3765 operator==(
const _CharT* __lhs,
3767 {
return __rhs == __lhs; }
3776 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3782 {
return !(__lhs == __rhs); }
3790 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3793 operator!=(
const _CharT* __lhs,
3795 {
return !(__rhs == __lhs); }
3803 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3807 const _CharT* __rhs)
3808 {
return !(__lhs == __rhs); }
3817 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3823 {
return __lhs.compare(__rhs) < 0; }
3831 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3835 const _CharT* __rhs)
3836 {
return __lhs.compare(__rhs) < 0; }
3844 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3847 operator<(
const _CharT* __lhs,
3849 {
return __rhs.compare(__lhs) > 0; }
3858 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3864 {
return __lhs.compare(__rhs) > 0; }
3872 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3876 const _CharT* __rhs)
3877 {
return __lhs.compare(__rhs) > 0; }
3885 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3888 operator>(
const _CharT* __lhs,
3890 {
return __rhs.compare(__lhs) < 0; }
3899 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3905 {
return __lhs.compare(__rhs) <= 0; }
3913 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3917 const _CharT* __rhs)
3918 {
return __lhs.compare(__rhs) <= 0; }
3926 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3929 operator<=(
const _CharT* __lhs,
3931 {
return __rhs.compare(__lhs) >= 0; }
3940 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3946 {
return __lhs.compare(__rhs) >= 0; }
3954 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3958 const _CharT* __rhs)
3959 {
return __lhs.compare(__rhs) >= 0; }
3967 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3970 operator>=(
const _CharT* __lhs,
3972 {
return __rhs.compare(__lhs) <= 0; }
3982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3983 _GLIBCXX20_CONSTEXPR
3987 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
3988 { __lhs.swap(__rhs); }
4003 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4004 basic_istream<_CharT, _Traits>&
4005 operator>>(basic_istream<_CharT, _Traits>& __is,
4006 basic_string<_CharT, _Traits, _Alloc>& __str);
4009 basic_istream<char>&
4021 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4028 return __ostream_insert(__os, __str.data(), __str.size());
4044 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4045 basic_istream<_CharT, _Traits>&
4046 getline(basic_istream<_CharT, _Traits>& __is,
4047 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4061 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4062 inline basic_istream<_CharT, _Traits>&
4067#if __cplusplus >= 201103L
4069 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4070 inline basic_istream<_CharT, _Traits>&
4076 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4077 inline basic_istream<_CharT, _Traits>&
4084 basic_istream<char>&
4085 getline(basic_istream<char>& __in, basic_string<char>& __str,
4088#ifdef _GLIBCXX_USE_WCHAR_T
4090 basic_istream<wchar_t>&
4091 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4095_GLIBCXX_END_NAMESPACE_VERSION
4098#if __cplusplus >= 201103L
4103namespace std _GLIBCXX_VISIBILITY(default)
4105_GLIBCXX_BEGIN_NAMESPACE_VERSION
4106_GLIBCXX_BEGIN_NAMESPACE_CXX11
4108#if _GLIBCXX_USE_C99_STDLIB
4111 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4112 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4116 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4117 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4120 inline unsigned long
4121 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4122 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4126 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4127 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4130 inline unsigned long long
4131 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4132 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4137 stof(
const string& __str,
size_t* __idx = 0)
4138 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4141 stod(
const string& __str,
size_t* __idx = 0)
4142 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4145 stold(
const string& __str,
size_t* __idx = 0)
4146 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4153 to_string(
int __val)
4154#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4158 const bool __neg = __val < 0;
4159 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4160 const auto __len = __detail::__to_chars_len(__uval);
4161 string __str(__neg + __len,
'-');
4162 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4168 to_string(
unsigned __val)
4169#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4173 string __str(__detail::__to_chars_len(__val),
'\0');
4174 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4180 to_string(
long __val)
4181#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4185 const bool __neg = __val < 0;
4186 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4187 const auto __len = __detail::__to_chars_len(__uval);
4188 string __str(__neg + __len,
'-');
4189 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4195 to_string(
unsigned long __val)
4196#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4200 string __str(__detail::__to_chars_len(__val),
'\0');
4201 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4207 to_string(
long long __val)
4209 const bool __neg = __val < 0;
4210 const unsigned long long __uval
4211 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4212 const auto __len = __detail::__to_chars_len(__uval);
4213 string __str(__neg + __len,
'-');
4214 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4220 to_string(
unsigned long long __val)
4222 string __str(__detail::__to_chars_len(__val),
'\0');
4223 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4227#if _GLIBCXX_USE_C99_STDIO
4232 to_string(
float __val)
4235 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4236 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4242 to_string(
double __val)
4245 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4246 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4252 to_string(
long double __val)
4255 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4256 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4261#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4263 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4264 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4268 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4269 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4272 inline unsigned long
4273 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4274 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4278 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4279 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4282 inline unsigned long long
4283 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4284 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4289 stof(
const wstring& __str,
size_t* __idx = 0)
4290 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4293 stod(
const wstring& __str,
size_t* __idx = 0)
4294 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4297 stold(
const wstring& __str,
size_t* __idx = 0)
4298 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4300#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4304 to_wstring(
int __val)
4305 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
4310 to_wstring(
unsigned __val)
4311 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4312 4 *
sizeof(
unsigned),
4317 to_wstring(
long __val)
4318 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
4323 to_wstring(
unsigned long __val)
4324 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4325 4 *
sizeof(
unsigned long),
4330 to_wstring(
long long __val)
4331 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4332 4 *
sizeof(
long long),
4337 to_wstring(
unsigned long long __val)
4338 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4339 4 *
sizeof(
unsigned long long),
4344 to_wstring(
float __val)
4347 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4348 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4354 to_wstring(
double __val)
4357 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4358 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4364 to_wstring(
long double __val)
4367 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4368 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4374_GLIBCXX_END_NAMESPACE_CXX11
4375_GLIBCXX_END_NAMESPACE_VERSION
4380#if __cplusplus >= 201103L
4384namespace std _GLIBCXX_VISIBILITY(default)
4386_GLIBCXX_BEGIN_NAMESPACE_VERSION
4391 template<
typename _CharT,
typename _Alloc,
4392 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4393 struct __str_hash_base
4394 :
public __hash_base<size_t, _StrT>
4398 operator()(
const _StrT& __s)
const noexcept
4399 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4402#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4404 template<
typename _Alloc>
4406 :
public __str_hash_base<char, _Alloc>
4410 template<
typename _Alloc>
4412 :
public __str_hash_base<wchar_t, _Alloc>
4415 template<
typename _Alloc>
4422#ifdef _GLIBCXX_USE_CHAR8_T
4424 template<
typename _Alloc>
4425 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4426 :
public __str_hash_base<char8_t, _Alloc>
4431 template<
typename _Alloc>
4433 :
public __str_hash_base<char16_t, _Alloc>
4437 template<
typename _Alloc>
4439 :
public __str_hash_base<char32_t, _Alloc>
4442#if ! _GLIBCXX_INLINE_VERSION
4448#ifdef _GLIBCXX_USE_CHAR8_T
4449 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4453 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4454 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4459#if __cplusplus >= 201402L
4461#define __cpp_lib_string_udls 201304L
4463 inline namespace literals
4465 inline namespace string_literals
4467#pragma GCC diagnostic push
4468#pragma GCC diagnostic ignored "-Wliteral-suffix"
4470#if __cpp_lib_constexpr_string >= 201907L
4471# define _GLIBCXX_STRING_CONSTEXPR constexpr
4473# define _GLIBCXX_STRING_CONSTEXPR
4476 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4477 inline basic_string<char>
4478 operator""s(
const char* __str,
size_t __len)
4479 {
return basic_string<char>{__str, __len}; }
4481 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4482 inline basic_string<wchar_t>
4483 operator""s(
const wchar_t* __str,
size_t __len)
4484 {
return basic_string<wchar_t>{__str, __len}; }
4486#ifdef _GLIBCXX_USE_CHAR8_T
4487 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4488 inline basic_string<char8_t>
4489 operator""s(
const char8_t* __str,
size_t __len)
4490 {
return basic_string<char8_t>{__str, __len}; }
4493 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4494 inline basic_string<char16_t>
4495 operator""s(
const char16_t* __str,
size_t __len)
4496 {
return basic_string<char16_t>{__str, __len}; }
4498 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4499 inline basic_string<char32_t>
4500 operator""s(
const char32_t* __str,
size_t __len)
4501 {
return basic_string<char32_t>{__str, __len}; }
4503#undef _GLIBCXX_STRING_CONSTEXPR
4504#pragma GCC diagnostic pop
4508#if __cplusplus >= 201703L
4509 namespace __detail::__variant
4511 template<
typename>
struct _Never_valueless_alt;
4515 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4516 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4518 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4519 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4526_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.