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 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
848 && !_Alloc_traits::_S_always_equal()
849 && _M_get_allocator() != __str._M_get_allocator())
852 _M_destroy(_M_allocated_capacity);
853 _M_data(_M_local_data());
857 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
859 if (__str._M_is_local())
867 this->_S_copy(_M_data(), __str._M_data(), __str.size());
868 _M_set_length(__str.size());
871 else if (_Alloc_traits::_S_propagate_on_move_assign()
872 || _Alloc_traits::_S_always_equal()
873 || _M_get_allocator() == __str._M_get_allocator())
876 pointer __data =
nullptr;
877 size_type __capacity;
880 if (_Alloc_traits::_S_always_equal())
884 __capacity = _M_allocated_capacity;
887 _M_destroy(_M_allocated_capacity);
890 _M_data(__str._M_data());
891 _M_length(__str.length());
892 _M_capacity(__str._M_allocated_capacity);
895 __str._M_data(__data);
896 __str._M_capacity(__capacity);
899 __str._M_data(__str._M_local_buf);
915 this->
assign(__l.begin(), __l.size());
920#if __cplusplus >= 201703L
925 template<
typename _Tp>
927 _If_sv<_Tp, basic_string&>
929 {
return this->
assign(__svt); }
936 operator __sv_type() const noexcept
937 {
return __sv_type(
data(),
size()); }
945 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
947 begin() _GLIBCXX_NOEXCEPT
948 {
return iterator(_M_data()); }
954 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
956 begin() const _GLIBCXX_NOEXCEPT
957 {
return const_iterator(_M_data()); }
963 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
965 end() _GLIBCXX_NOEXCEPT
966 {
return iterator(_M_data() + this->
size()); }
972 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
974 end() const _GLIBCXX_NOEXCEPT
975 {
return const_iterator(_M_data() + this->
size()); }
982 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
984 rbegin() _GLIBCXX_NOEXCEPT
985 {
return reverse_iterator(this->
end()); }
992 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
993 const_reverse_iterator
994 rbegin() const _GLIBCXX_NOEXCEPT
995 {
return const_reverse_iterator(this->
end()); }
1002 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1004 rend() _GLIBCXX_NOEXCEPT
1005 {
return reverse_iterator(this->
begin()); }
1012 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1013 const_reverse_iterator
1014 rend() const _GLIBCXX_NOEXCEPT
1015 {
return const_reverse_iterator(this->
begin()); }
1017#if __cplusplus >= 201103L
1022 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1025 {
return const_iterator(this->_M_data()); }
1031 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1033 cend() const noexcept
1034 {
return const_iterator(this->_M_data() + this->
size()); }
1041 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1042 const_reverse_iterator
1044 {
return const_reverse_iterator(this->
end()); }
1051 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1052 const_reverse_iterator
1053 crend() const noexcept
1054 {
return const_reverse_iterator(this->
begin()); }
1061 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1063 size() const _GLIBCXX_NOEXCEPT
1064 {
return _M_string_length; }
1068 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1070 length() const _GLIBCXX_NOEXCEPT
1071 {
return _M_string_length; }
1074 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1077 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1089 _GLIBCXX20_CONSTEXPR
1091 resize(size_type __n, _CharT __c);
1103 _GLIBCXX20_CONSTEXPR
1106 { this->
resize(__n, _CharT()); }
1108#if __cplusplus >= 201103L
1109#pragma GCC diagnostic push
1110#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1112 _GLIBCXX20_CONSTEXPR
1116#pragma GCC diagnostic pop
1119#if __cplusplus > 202002L
1120#define __cpp_lib_string_resize_and_overwrite 202110L
1121 template<
typename _Operation>
1123 resize_and_overwrite(size_type __n, _Operation __op);
1130 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1134 return _M_is_local() ? size_type(_S_local_capacity)
1135 : _M_allocated_capacity;
1155 _GLIBCXX20_CONSTEXPR
1162#if __cplusplus > 201703L
1163 [[deprecated(
"use shrink_to_fit() instead")]]
1165 _GLIBCXX20_CONSTEXPR
1172 _GLIBCXX20_CONSTEXPR
1174 clear() _GLIBCXX_NOEXCEPT
1175 { _M_set_length(0); }
1181 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1183 empty() const _GLIBCXX_NOEXCEPT
1184 {
return this->
size() == 0; }
1197 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1199 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1201 __glibcxx_assert(__pos <=
size());
1202 return _M_data()[__pos];
1215 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1221 __glibcxx_assert(__pos <=
size());
1223 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1224 return _M_data()[__pos];
1237 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1239 at(size_type __n)
const
1241 if (__n >= this->
size())
1242 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1243 "(which is %zu) >= this->size() "
1246 return _M_data()[__n];
1259 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1264 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1265 "(which is %zu) >= this->size() "
1268 return _M_data()[__n];
1271#if __cplusplus >= 201103L
1276 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1280 __glibcxx_assert(!
empty());
1288 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1290 front() const noexcept
1292 __glibcxx_assert(!
empty());
1300 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1304 __glibcxx_assert(!
empty());
1312 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1314 back() const noexcept
1316 __glibcxx_assert(!
empty());
1327 _GLIBCXX20_CONSTEXPR
1330 {
return this->
append(__str); }
1337 _GLIBCXX20_CONSTEXPR
1340 {
return this->
append(__s); }
1347 _GLIBCXX20_CONSTEXPR
1355#if __cplusplus >= 201103L
1361 _GLIBCXX20_CONSTEXPR
1364 {
return this->
append(__l.begin(), __l.size()); }
1367#if __cplusplus >= 201703L
1373 template<
typename _Tp>
1374 _GLIBCXX20_CONSTEXPR
1375 _If_sv<_Tp, basic_string&>
1377 {
return this->
append(__svt); }
1385 _GLIBCXX20_CONSTEXPR
1388 {
return this->
append(__str._M_data(), __str.size()); }
1403 _GLIBCXX20_CONSTEXPR
1406 {
return this->
append(__str._M_data()
1407 + __str._M_check(__pos,
"basic_string::append"),
1408 __str._M_limit(__pos, __n)); }
1416 _GLIBCXX20_CONSTEXPR
1418 append(
const _CharT* __s, size_type __n)
1420 __glibcxx_requires_string_len(__s, __n);
1421 _M_check_length(size_type(0), __n,
"basic_string::append");
1422 return _M_append(__s, __n);
1430 _GLIBCXX20_CONSTEXPR
1432 append(
const _CharT* __s)
1434 __glibcxx_requires_string(__s);
1435 const size_type __n = traits_type::length(__s);
1436 _M_check_length(size_type(0), __n,
"basic_string::append");
1437 return _M_append(__s, __n);
1448 _GLIBCXX20_CONSTEXPR
1450 append(size_type __n, _CharT __c)
1451 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1453#if __cplusplus >= 201103L
1459 _GLIBCXX20_CONSTEXPR
1461 append(initializer_list<_CharT> __l)
1462 {
return this->
append(__l.begin(), __l.size()); }
1473#if __cplusplus >= 201103L
1474 template<
class _InputIterator,
1475 typename = std::_RequireInputIter<_InputIterator>>
1476 _GLIBCXX20_CONSTEXPR
1478 template<
class _InputIterator>
1481 append(_InputIterator __first, _InputIterator __last)
1484#if __cplusplus >= 201703L
1490 template<
typename _Tp>
1491 _GLIBCXX20_CONSTEXPR
1492 _If_sv<_Tp, basic_string&>
1495 __sv_type __sv = __svt;
1496 return this->
append(__sv.data(), __sv.size());
1506 template<
typename _Tp>
1507 _GLIBCXX20_CONSTEXPR
1508 _If_sv<_Tp, basic_string&>
1509 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1511 __sv_type __sv = __svt;
1512 return _M_append(__sv.data()
1513 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1514 std::__sv_limit(__sv.size(), __pos, __n));
1522 _GLIBCXX20_CONSTEXPR
1526 const size_type __size = this->
size();
1528 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1529 traits_type::assign(this->_M_data()[__size], __c);
1530 this->_M_set_length(__size + 1);
1538 _GLIBCXX20_CONSTEXPR
1542#if __cplusplus >= 201103L
1543 if (_Alloc_traits::_S_propagate_on_copy_assign())
1545 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1546 && _M_get_allocator() != __str._M_get_allocator())
1550 if (__str.size() <= _S_local_capacity)
1552 _M_destroy(_M_allocated_capacity);
1553 _M_data(_M_use_local_data());
1558 const auto __len = __str.size();
1559 auto __alloc = __str._M_get_allocator();
1561 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1562 _M_destroy(_M_allocated_capacity);
1565 _M_set_length(__len);
1568 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1571 this->_M_assign(__str);
1575#if __cplusplus >= 201103L
1584 _GLIBCXX20_CONSTEXPR
1587 noexcept(_Alloc_traits::_S_nothrow_move())
1608 _GLIBCXX20_CONSTEXPR
1611 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1612 + __str._M_check(__pos,
"basic_string::assign"),
1613 __str._M_limit(__pos, __n)); }
1625 _GLIBCXX20_CONSTEXPR
1627 assign(
const _CharT* __s, size_type __n)
1629 __glibcxx_requires_string_len(__s, __n);
1630 return _M_replace(size_type(0), this->
size(), __s, __n);
1642 _GLIBCXX20_CONSTEXPR
1644 assign(
const _CharT* __s)
1646 __glibcxx_requires_string(__s);
1647 return _M_replace(size_type(0), this->
size(), __s,
1648 traits_type::length(__s));
1660 _GLIBCXX20_CONSTEXPR
1662 assign(size_type __n, _CharT __c)
1663 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1673#if __cplusplus >= 201103L
1674 template<
class _InputIterator,
1675 typename = std::_RequireInputIter<_InputIterator>>
1676 _GLIBCXX20_CONSTEXPR
1678 template<
class _InputIterator>
1681 assign(_InputIterator __first, _InputIterator __last)
1684#if __cplusplus >= 201103L
1690 _GLIBCXX20_CONSTEXPR
1692 assign(initializer_list<_CharT> __l)
1693 {
return this->
assign(__l.begin(), __l.size()); }
1696#if __cplusplus >= 201703L
1702 template<
typename _Tp>
1703 _GLIBCXX20_CONSTEXPR
1704 _If_sv<_Tp, basic_string&>
1707 __sv_type __sv = __svt;
1708 return this->
assign(__sv.data(), __sv.size());
1718 template<
typename _Tp>
1719 _GLIBCXX20_CONSTEXPR
1720 _If_sv<_Tp, basic_string&>
1721 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1723 __sv_type __sv = __svt;
1724 return _M_replace(size_type(0), this->
size(),
1726 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1727 std::__sv_limit(__sv.size(), __pos, __n));
1731#if __cplusplus >= 201103L
1747 _GLIBCXX20_CONSTEXPR
1749 insert(const_iterator __p, size_type __n, _CharT __c)
1751 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1752 const size_type __pos = __p -
begin();
1753 this->
replace(__p, __p, __n, __c);
1754 return iterator(this->_M_data() + __pos);
1771 insert(iterator __p, size_type __n, _CharT __c)
1772 { this->
replace(__p, __p, __n, __c); }
1775#if __cplusplus >= 201103L
1790 template<
class _InputIterator,
1791 typename = std::_RequireInputIter<_InputIterator>>
1792 _GLIBCXX20_CONSTEXPR
1794 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1796 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1797 const size_type __pos = __p -
begin();
1798 this->
replace(__p, __p, __beg, __end);
1799 return iterator(this->_M_data() + __pos);
1814 template<
class _InputIterator>
1816 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1817 { this->
replace(__p, __p, __beg, __end); }
1820#if __cplusplus >= 201103L
1827 _GLIBCXX20_CONSTEXPR
1829 insert(const_iterator __p, initializer_list<_CharT> __l)
1830 {
return this->
insert(__p, __l.begin(), __l.end()); }
1832#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1835 insert(iterator __p, initializer_list<_CharT> __l)
1837 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1838 this->
insert(__p -
begin(), __l.begin(), __l.size());
1855 _GLIBCXX20_CONSTEXPR
1858 {
return this->
replace(__pos1, size_type(0),
1859 __str._M_data(), __str.size()); }
1879 _GLIBCXX20_CONSTEXPR
1882 size_type __pos2, size_type __n =
npos)
1883 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1884 + __str._M_check(__pos2,
"basic_string::insert"),
1885 __str._M_limit(__pos2, __n)); }
1903 _GLIBCXX20_CONSTEXPR
1905 insert(size_type __pos,
const _CharT* __s, size_type __n)
1906 {
return this->
replace(__pos, size_type(0), __s, __n); }
1923 _GLIBCXX20_CONSTEXPR
1925 insert(size_type __pos,
const _CharT* __s)
1927 __glibcxx_requires_string(__s);
1928 return this->
replace(__pos, size_type(0), __s,
1929 traits_type::length(__s));
1948 _GLIBCXX20_CONSTEXPR
1950 insert(size_type __pos, size_type __n, _CharT __c)
1951 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1952 size_type(0), __n, __c); }
1967 _GLIBCXX20_CONSTEXPR
1969 insert(__const_iterator __p, _CharT __c)
1971 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1972 const size_type __pos = __p -
begin();
1973 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1974 return iterator(_M_data() + __pos);
1977#if __cplusplus >= 201703L
1984 template<
typename _Tp>
1985 _GLIBCXX20_CONSTEXPR
1986 _If_sv<_Tp, basic_string&>
1987 insert(size_type __pos,
const _Tp& __svt)
1989 __sv_type __sv = __svt;
1990 return this->
insert(__pos, __sv.data(), __sv.size());
2001 template<
typename _Tp>
2002 _GLIBCXX20_CONSTEXPR
2003 _If_sv<_Tp, basic_string&>
2004 insert(size_type __pos1,
const _Tp& __svt,
2005 size_type __pos2, size_type __n =
npos)
2007 __sv_type __sv = __svt;
2008 return this->
replace(__pos1, size_type(0),
2010 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2011 std::__sv_limit(__sv.size(), __pos2, __n));
2030 _GLIBCXX20_CONSTEXPR
2032 erase(size_type __pos = 0, size_type __n =
npos)
2034 _M_check(__pos,
"basic_string::erase");
2036 this->_M_set_length(__pos);
2038 this->_M_erase(__pos, _M_limit(__pos, __n));
2050 _GLIBCXX20_CONSTEXPR
2052 erase(__const_iterator __position)
2054 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2055 && __position <
end());
2056 const size_type __pos = __position -
begin();
2057 this->_M_erase(__pos, size_type(1));
2058 return iterator(_M_data() + __pos);
2070 _GLIBCXX20_CONSTEXPR
2072 erase(__const_iterator __first, __const_iterator __last)
2074 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2075 && __last <=
end());
2076 const size_type __pos = __first -
begin();
2077 if (__last ==
end())
2078 this->_M_set_length(__pos);
2080 this->_M_erase(__pos, __last - __first);
2081 return iterator(this->_M_data() + __pos);
2084#if __cplusplus >= 201103L
2090 _GLIBCXX20_CONSTEXPR
2094 __glibcxx_assert(!
empty());
2095 _M_erase(
size() - 1, 1);
2116 _GLIBCXX20_CONSTEXPR
2119 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2139 _GLIBCXX20_CONSTEXPR
2142 size_type __pos2, size_type __n2 =
npos)
2143 {
return this->
replace(__pos1, __n1, __str._M_data()
2144 + __str._M_check(__pos2,
"basic_string::replace"),
2145 __str._M_limit(__pos2, __n2)); }
2165 _GLIBCXX20_CONSTEXPR
2167 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2170 __glibcxx_requires_string_len(__s, __n2);
2171 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2172 _M_limit(__pos, __n1), __s, __n2);
2191 _GLIBCXX20_CONSTEXPR
2193 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2195 __glibcxx_requires_string(__s);
2196 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2216 _GLIBCXX20_CONSTEXPR
2218 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2219 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2220 _M_limit(__pos, __n1), __n2, __c); }
2235 _GLIBCXX20_CONSTEXPR
2237 replace(__const_iterator __i1, __const_iterator __i2,
2239 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2256 _GLIBCXX20_CONSTEXPR
2258 replace(__const_iterator __i1, __const_iterator __i2,
2259 const _CharT* __s, size_type __n)
2261 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2263 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2279 _GLIBCXX20_CONSTEXPR
2281 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2283 __glibcxx_requires_string(__s);
2284 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2301 _GLIBCXX20_CONSTEXPR
2303 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2306 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2308 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2326#if __cplusplus >= 201103L
2327 template<
class _InputIterator,
2328 typename = std::_RequireInputIter<_InputIterator>>
2329 _GLIBCXX20_CONSTEXPR
2331 replace(const_iterator __i1, const_iterator __i2,
2332 _InputIterator __k1, _InputIterator __k2)
2334 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2336 __glibcxx_requires_valid_range(__k1, __k2);
2337 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2338 std::__false_type());
2341 template<
class _InputIterator>
2342#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2343 typename __enable_if_not_native_iterator<_InputIterator>::__type
2347 replace(iterator __i1, iterator __i2,
2348 _InputIterator __k1, _InputIterator __k2)
2350 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2352 __glibcxx_requires_valid_range(__k1, __k2);
2353 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2354 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2360 _GLIBCXX20_CONSTEXPR
2362 replace(__const_iterator __i1, __const_iterator __i2,
2363 _CharT* __k1, _CharT* __k2)
2365 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2367 __glibcxx_requires_valid_range(__k1, __k2);
2372 _GLIBCXX20_CONSTEXPR
2374 replace(__const_iterator __i1, __const_iterator __i2,
2375 const _CharT* __k1,
const _CharT* __k2)
2377 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2379 __glibcxx_requires_valid_range(__k1, __k2);
2384 _GLIBCXX20_CONSTEXPR
2386 replace(__const_iterator __i1, __const_iterator __i2,
2387 iterator __k1, iterator __k2)
2389 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2391 __glibcxx_requires_valid_range(__k1, __k2);
2393 __k1.base(), __k2 - __k1);
2396 _GLIBCXX20_CONSTEXPR
2398 replace(__const_iterator __i1, __const_iterator __i2,
2399 const_iterator __k1, const_iterator __k2)
2401 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2403 __glibcxx_requires_valid_range(__k1, __k2);
2405 __k1.base(), __k2 - __k1);
2408#if __cplusplus >= 201103L
2423 _GLIBCXX20_CONSTEXPR
2425 initializer_list<_CharT> __l)
2426 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2429#if __cplusplus >= 201703L
2437 template<
typename _Tp>
2438 _GLIBCXX20_CONSTEXPR
2439 _If_sv<_Tp, basic_string&>
2440 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2442 __sv_type __sv = __svt;
2443 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2455 template<
typename _Tp>
2456 _GLIBCXX20_CONSTEXPR
2457 _If_sv<_Tp, basic_string&>
2458 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2459 size_type __pos2, size_type __n2 =
npos)
2461 __sv_type __sv = __svt;
2462 return this->
replace(__pos1, __n1,
2464 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2465 std::__sv_limit(__sv.size(), __pos2, __n2));
2477 template<
typename _Tp>
2478 _GLIBCXX20_CONSTEXPR
2479 _If_sv<_Tp, basic_string&>
2480 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2482 __sv_type __sv = __svt;
2483 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2488 template<
class _Integer>
2489 _GLIBCXX20_CONSTEXPR
2491 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2492 _Integer __n, _Integer __val, __true_type)
2493 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2495 template<
class _InputIterator>
2496 _GLIBCXX20_CONSTEXPR
2498 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2499 _InputIterator __k1, _InputIterator __k2,
2502 _GLIBCXX20_CONSTEXPR
2504 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2507 __attribute__((__noinline__, __noclone__, __cold__))
void
2508 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2509 const size_type __len2,
const size_type __how_much);
2511 _GLIBCXX20_CONSTEXPR
2513 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2514 const size_type __len2);
2516 _GLIBCXX20_CONSTEXPR
2518 _M_append(
const _CharT* __s, size_type __n);
2534 _GLIBCXX20_CONSTEXPR
2536 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2545 _GLIBCXX20_CONSTEXPR
2556 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2558 c_str() const _GLIBCXX_NOEXCEPT
2559 {
return _M_data(); }
2569 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2571 data() const _GLIBCXX_NOEXCEPT
2572 {
return _M_data(); }
2574#if __cplusplus >= 201703L
2581 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2584 {
return _M_data(); }
2590 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2593 {
return _M_get_allocator(); }
2607 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2609 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2622 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2626 {
return this->
find(__str.data(), __pos, __str.size()); }
2628#if __cplusplus >= 201703L
2635 template<
typename _Tp>
2636 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2637 _If_sv<_Tp, size_type>
2638 find(
const _Tp& __svt, size_type __pos = 0) const
2639 noexcept(is_same<_Tp, __sv_type>::value)
2641 __sv_type __sv = __svt;
2642 return this->
find(__sv.data(), __pos, __sv.size());
2656 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2658 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2660 __glibcxx_requires_string(__s);
2661 return this->
find(__s, __pos, traits_type::length(__s));
2674 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2676 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2688 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2692 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2694#if __cplusplus >= 201703L
2701 template<
typename _Tp>
2702 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2703 _If_sv<_Tp, size_type>
2704 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2705 noexcept(is_same<_Tp, __sv_type>::value)
2707 __sv_type __sv = __svt;
2708 return this->
rfind(__sv.data(), __pos, __sv.size());
2724 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2726 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2739 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2741 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2743 __glibcxx_requires_string(__s);
2744 return this->
rfind(__s, __pos, traits_type::length(__s));
2757 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2759 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2772 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2776 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2778#if __cplusplus >= 201703L
2786 template<
typename _Tp>
2787 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2788 _If_sv<_Tp, size_type>
2790 noexcept(is_same<_Tp, __sv_type>::value)
2792 __sv_type __sv = __svt;
2793 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2809 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2811 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2824 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2829 __glibcxx_requires_string(__s);
2830 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2845 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2847 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2848 {
return this->
find(__c, __pos); }
2861 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2865 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2867#if __cplusplus >= 201703L
2875 template<
typename _Tp>
2876 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2877 _If_sv<_Tp, size_type>
2879 noexcept(is_same<_Tp, __sv_type>::value)
2881 __sv_type __sv = __svt;
2882 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2898 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2900 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2913 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2918 __glibcxx_requires_string(__s);
2919 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2934 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2937 {
return this->
rfind(__c, __pos); }
2949 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2955#if __cplusplus >= 201703L
2963 template<
typename _Tp>
2964 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2965 _If_sv<_Tp, size_type>
2967 noexcept(is_same<_Tp, __sv_type>::value)
2969 __sv_type __sv = __svt;
2986 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2989 size_type __n)
const _GLIBCXX_NOEXCEPT;
3001 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3006 __glibcxx_requires_string(__s);
3020 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3036 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3042#if __cplusplus >= 201703L
3050 template<
typename _Tp>
3051 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3052 _If_sv<_Tp, size_type>
3054 noexcept(is_same<_Tp, __sv_type>::value)
3056 __sv_type __sv = __svt;
3073 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3076 size_type __n)
const _GLIBCXX_NOEXCEPT;
3088 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3093 __glibcxx_requires_string(__s);
3107 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3124 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3126 substr(size_type __pos = 0, size_type __n =
npos)
const
3128 _M_check(__pos,
"basic_string::substr"), __n); }
3144 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3148 const size_type __size = this->
size();
3149 const size_type __osize = __str.size();
3150 const size_type __len =
std::min(__size, __osize);
3152 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3154 __r = _S_compare(__size, __osize);
3158#if __cplusplus >= 201703L
3164 template<
typename _Tp>
3165 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3167 compare(
const _Tp& __svt)
const
3168 noexcept(is_same<_Tp, __sv_type>::value)
3170 __sv_type __sv = __svt;
3171 const size_type __size = this->
size();
3172 const size_type __osize = __sv.size();
3173 const size_type __len =
std::min(__size, __osize);
3175 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3177 __r = _S_compare(__size, __osize);
3189 template<
typename _Tp>
3190 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3192 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3193 noexcept(is_same<_Tp, __sv_type>::value)
3195 __sv_type __sv = __svt;
3196 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3209 template<
typename _Tp>
3210 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3212 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3213 size_type __pos2, size_type __n2 =
npos)
const
3214 noexcept(is_same<_Tp, __sv_type>::value)
3216 __sv_type __sv = __svt;
3217 return __sv_type(*
this)
3218 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3241 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3245 _M_check(__pos,
"basic_string::compare");
3246 __n = _M_limit(__pos, __n);
3247 const size_type __osize = __str.size();
3248 const size_type __len =
std::min(__n, __osize);
3249 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3251 __r = _S_compare(__n, __osize);
3278 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3281 size_type __pos2, size_type __n2 =
npos)
const
3283 _M_check(__pos1,
"basic_string::compare");
3284 __str._M_check(__pos2,
"basic_string::compare");
3285 __n1 = _M_limit(__pos1, __n1);
3286 __n2 = __str._M_limit(__pos2, __n2);
3287 const size_type __len =
std::min(__n1, __n2);
3288 int __r = traits_type::compare(_M_data() + __pos1,
3289 __str.data() + __pos2, __len);
3291 __r = _S_compare(__n1, __n2);
3309 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3311 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3313 __glibcxx_requires_string(__s);
3314 const size_type __size = this->
size();
3315 const size_type __osize = traits_type::length(__s);
3316 const size_type __len =
std::min(__size, __osize);
3317 int __r = traits_type::compare(_M_data(), __s, __len);
3319 __r = _S_compare(__size, __osize);
3344 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3346 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3348 __glibcxx_requires_string(__s);
3349 _M_check(__pos,
"basic_string::compare");
3350 __n1 = _M_limit(__pos, __n1);
3351 const size_type __osize = traits_type::length(__s);
3352 const size_type __len =
std::min(__n1, __osize);
3353 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3355 __r = _S_compare(__n1, __osize);
3383 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3385 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3386 size_type __n2)
const
3388 __glibcxx_requires_string_len(__s, __n2);
3389 _M_check(__pos,
"basic_string::compare");
3390 __n1 = _M_limit(__pos, __n1);
3391 const size_type __len =
std::min(__n1, __n2);
3392 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3394 __r = _S_compare(__n1, __n2);
3398#if __cplusplus >= 202002L
3401 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3402 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3406 starts_with(_CharT __x)
const noexcept
3407 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3409 [[nodiscard, __gnu__::__nonnull__]]
3411 starts_with(
const _CharT* __x)
const noexcept
3412 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3416 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3417 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3421 ends_with(_CharT __x)
const noexcept
3422 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3424 [[nodiscard, __gnu__::__nonnull__]]
3426 ends_with(
const _CharT* __x)
const noexcept
3427 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3430#if __cplusplus > 202002L
3433 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3434 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3438 contains(_CharT __x)
const noexcept
3439 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3441 [[nodiscard, __gnu__::__nonnull__]]
3443 contains(
const _CharT* __x)
const noexcept
3444 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3448 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3450_GLIBCXX_END_NAMESPACE_CXX11
3451_GLIBCXX_END_NAMESPACE_VERSION
3455namespace std _GLIBCXX_VISIBILITY(default)
3457_GLIBCXX_BEGIN_NAMESPACE_VERSION
3459#if __cpp_deduction_guides >= 201606
3460_GLIBCXX_BEGIN_NAMESPACE_CXX11
3461 template<
typename _InputIterator,
typename _CharT
3462 =
typename iterator_traits<_InputIterator>::value_type,
3463 typename _Allocator = allocator<_CharT>,
3464 typename = _RequireInputIter<_InputIterator>,
3465 typename = _RequireAllocator<_Allocator>>
3466 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3467 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3471 template<
typename _CharT,
typename _Traits,
3472 typename _Allocator = allocator<_CharT>,
3473 typename = _RequireAllocator<_Allocator>>
3474 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3475 -> basic_string<_CharT, _Traits, _Allocator>;
3477 template<
typename _CharT,
typename _Traits,
3478 typename _Allocator = allocator<_CharT>,
3479 typename = _RequireAllocator<_Allocator>>
3480 basic_string(basic_string_view<_CharT, _Traits>,
3481 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3482 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3483 const _Allocator& = _Allocator())
3484 -> basic_string<_CharT, _Traits, _Allocator>;
3485_GLIBCXX_END_NAMESPACE_CXX11
3488 template<
typename _Str>
3489 _GLIBCXX20_CONSTEXPR
3491 __str_concat(
typename _Str::value_type
const* __lhs,
3492 typename _Str::size_type __lhs_len,
3493 typename _Str::value_type
const* __rhs,
3494 typename _Str::size_type __rhs_len,
3495 typename _Str::allocator_type
const& __a)
3497 typedef typename _Str::allocator_type allocator_type;
3499 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3500 __str.reserve(__lhs_len + __rhs_len);
3501 __str.append(__lhs, __lhs_len);
3502 __str.append(__rhs, __rhs_len);
3513 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3514 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3515 inline basic_string<_CharT, _Traits, _Alloc>
3520 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3521 __rhs.c_str(), __rhs.size(),
3522 __lhs.get_allocator());
3531 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3532 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3533 inline basic_string<_CharT,_Traits,_Alloc>
3537 __glibcxx_requires_string(__lhs);
3539 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3540 __rhs.c_str(), __rhs.size(),
3541 __rhs.get_allocator());
3550 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3551 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3552 inline basic_string<_CharT,_Traits,_Alloc>
3556 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3557 __rhs.c_str(), __rhs.size(),
3558 __rhs.get_allocator());
3567 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3568 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3569 inline basic_string<_CharT, _Traits, _Alloc>
3571 const _CharT* __rhs)
3573 __glibcxx_requires_string(__rhs);
3575 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3576 __rhs, _Traits::length(__rhs),
3577 __lhs.get_allocator());
3585 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3586 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3587 inline basic_string<_CharT, _Traits, _Alloc>
3591 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3592 __builtin_addressof(__rhs), 1,
3593 __lhs.get_allocator());
3596#if __cplusplus >= 201103L
3597 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3598 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3599 inline basic_string<_CharT, _Traits, _Alloc>
3600 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3601 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3602 {
return std::move(__lhs.append(__rhs)); }
3604 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3605 _GLIBCXX20_CONSTEXPR
3606 inline basic_string<_CharT, _Traits, _Alloc>
3607 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3608 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3609 {
return std::move(__rhs.insert(0, __lhs)); }
3611 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3612 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3613 inline basic_string<_CharT, _Traits, _Alloc>
3614 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3615 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3617#if _GLIBCXX_USE_CXX11_ABI
3618 using _Alloc_traits = allocator_traits<_Alloc>;
3619 bool __use_rhs =
false;
3620 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3622 else if (__lhs.get_allocator() == __rhs.get_allocator())
3627 const auto __size = __lhs.size() + __rhs.size();
3628 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3629 return std::move(__rhs.insert(0, __lhs));
3634 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3635 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3636 inline basic_string<_CharT, _Traits, _Alloc>
3638 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3639 {
return std::move(__rhs.insert(0, __lhs)); }
3641 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3642 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3643 inline basic_string<_CharT, _Traits, _Alloc>
3645 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3646 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3648 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3649 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3650 inline basic_string<_CharT, _Traits, _Alloc>
3651 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3652 const _CharT* __rhs)
3653 {
return std::move(__lhs.append(__rhs)); }
3655 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3656 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3657 inline basic_string<_CharT, _Traits, _Alloc>
3658 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3660 {
return std::move(__lhs.append(1, __rhs)); }
3670 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3671 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3677 return __lhs.size() == __rhs.size()
3678 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3687 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3688 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3691 const _CharT* __rhs)
3693 return __lhs.size() == _Traits::length(__rhs)
3694 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3697#if __cpp_lib_three_way_comparison
3705 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3708 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3709 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3710 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3711 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3720 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3723 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3724 const _CharT* __rhs)
noexcept
3725 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3726 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3734 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3737 operator==(
const _CharT* __lhs,
3739 {
return __rhs == __lhs; }
3748 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3754 {
return !(__lhs == __rhs); }
3762 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3765 operator!=(
const _CharT* __lhs,
3767 {
return !(__rhs == __lhs); }
3775 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3779 const _CharT* __rhs)
3780 {
return !(__lhs == __rhs); }
3789 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3795 {
return __lhs.compare(__rhs) < 0; }
3803 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3807 const _CharT* __rhs)
3808 {
return __lhs.compare(__rhs) < 0; }
3816 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3819 operator<(
const _CharT* __lhs,
3821 {
return __rhs.compare(__lhs) > 0; }
3830 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3836 {
return __lhs.compare(__rhs) > 0; }
3844 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3848 const _CharT* __rhs)
3849 {
return __lhs.compare(__rhs) > 0; }
3857 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3860 operator>(
const _CharT* __lhs,
3862 {
return __rhs.compare(__lhs) < 0; }
3871 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3877 {
return __lhs.compare(__rhs) <= 0; }
3885 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3889 const _CharT* __rhs)
3890 {
return __lhs.compare(__rhs) <= 0; }
3898 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3901 operator<=(
const _CharT* __lhs,
3903 {
return __rhs.compare(__lhs) >= 0; }
3912 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3918 {
return __lhs.compare(__rhs) >= 0; }
3926 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3930 const _CharT* __rhs)
3931 {
return __lhs.compare(__rhs) >= 0; }
3939 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3942 operator>=(
const _CharT* __lhs,
3944 {
return __rhs.compare(__lhs) <= 0; }
3954 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3955 _GLIBCXX20_CONSTEXPR
3959 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
3960 { __lhs.swap(__rhs); }
3975 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3976 basic_istream<_CharT, _Traits>&
3977 operator>>(basic_istream<_CharT, _Traits>& __is,
3978 basic_string<_CharT, _Traits, _Alloc>& __str);
3981 basic_istream<char>&
3993 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4000 return __ostream_insert(__os, __str.data(), __str.size());
4016 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4017 basic_istream<_CharT, _Traits>&
4018 getline(basic_istream<_CharT, _Traits>& __is,
4019 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4033 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4034 inline basic_istream<_CharT, _Traits>&
4039#if __cplusplus >= 201103L
4041 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4042 inline basic_istream<_CharT, _Traits>&
4048 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4049 inline basic_istream<_CharT, _Traits>&
4056 basic_istream<char>&
4057 getline(basic_istream<char>& __in, basic_string<char>& __str,
4060#ifdef _GLIBCXX_USE_WCHAR_T
4062 basic_istream<wchar_t>&
4063 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4067_GLIBCXX_END_NAMESPACE_VERSION
4070#if __cplusplus >= 201103L
4075namespace std _GLIBCXX_VISIBILITY(default)
4077_GLIBCXX_BEGIN_NAMESPACE_VERSION
4078_GLIBCXX_BEGIN_NAMESPACE_CXX11
4080#if _GLIBCXX_USE_C99_STDLIB
4083 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4084 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4088 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4089 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4092 inline unsigned long
4093 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4094 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4098 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4099 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4102 inline unsigned long long
4103 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4104 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4109 stof(
const string& __str,
size_t* __idx = 0)
4110 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4113 stod(
const string& __str,
size_t* __idx = 0)
4114 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4117 stold(
const string& __str,
size_t* __idx = 0)
4118 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4125 to_string(
int __val)
4126#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4130 const bool __neg = __val < 0;
4131 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4132 const auto __len = __detail::__to_chars_len(__uval);
4133 string __str(__neg + __len,
'-');
4134 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4140 to_string(
unsigned __val)
4141#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4145 string __str(__detail::__to_chars_len(__val),
'\0');
4146 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4152 to_string(
long __val)
4153#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4157 const bool __neg = __val < 0;
4158 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4159 const auto __len = __detail::__to_chars_len(__uval);
4160 string __str(__neg + __len,
'-');
4161 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4167 to_string(
unsigned long __val)
4168#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4172 string __str(__detail::__to_chars_len(__val),
'\0');
4173 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4179 to_string(
long long __val)
4181 const bool __neg = __val < 0;
4182 const unsigned long long __uval
4183 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4184 const auto __len = __detail::__to_chars_len(__uval);
4185 string __str(__neg + __len,
'-');
4186 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4192 to_string(
unsigned long long __val)
4194 string __str(__detail::__to_chars_len(__val),
'\0');
4195 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4199#if _GLIBCXX_USE_C99_STDIO
4204 to_string(
float __val)
4207 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4208 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4214 to_string(
double __val)
4217 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4218 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4224 to_string(
long double __val)
4227 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4228 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4233#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4235 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4236 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4240 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4241 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4244 inline unsigned long
4245 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4246 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4250 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4251 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4254 inline unsigned long long
4255 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4256 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4261 stof(
const wstring& __str,
size_t* __idx = 0)
4262 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4265 stod(
const wstring& __str,
size_t* __idx = 0)
4266 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4269 stold(
const wstring& __str,
size_t* __idx = 0)
4270 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4272#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4276 to_wstring(
int __val)
4277 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
4282 to_wstring(
unsigned __val)
4283 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4284 4 *
sizeof(
unsigned),
4289 to_wstring(
long __val)
4290 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
4295 to_wstring(
unsigned long __val)
4296 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4297 4 *
sizeof(
unsigned long),
4302 to_wstring(
long long __val)
4303 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4304 4 *
sizeof(
long long),
4309 to_wstring(
unsigned long long __val)
4310 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4311 4 *
sizeof(
unsigned long long),
4316 to_wstring(
float __val)
4319 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4320 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4326 to_wstring(
double __val)
4329 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4330 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4336 to_wstring(
long double __val)
4339 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4340 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4346_GLIBCXX_END_NAMESPACE_CXX11
4347_GLIBCXX_END_NAMESPACE_VERSION
4352#if __cplusplus >= 201103L
4356namespace std _GLIBCXX_VISIBILITY(default)
4358_GLIBCXX_BEGIN_NAMESPACE_VERSION
4363 template<
typename _CharT,
typename _Alloc,
4364 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4365 struct __str_hash_base
4366 :
public __hash_base<size_t, _StrT>
4370 operator()(
const _StrT& __s)
const noexcept
4371 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4374#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4376 template<
typename _Alloc>
4378 :
public __str_hash_base<char, _Alloc>
4382 template<
typename _Alloc>
4384 :
public __str_hash_base<wchar_t, _Alloc>
4387 template<
typename _Alloc>
4394#ifdef _GLIBCXX_USE_CHAR8_T
4396 template<
typename _Alloc>
4397 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4398 :
public __str_hash_base<char8_t, _Alloc>
4403 template<
typename _Alloc>
4405 :
public __str_hash_base<char16_t, _Alloc>
4409 template<
typename _Alloc>
4411 :
public __str_hash_base<char32_t, _Alloc>
4414#if ! _GLIBCXX_INLINE_VERSION
4420#ifdef _GLIBCXX_USE_CHAR8_T
4421 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4425 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4426 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4431#if __cplusplus >= 201402L
4433#define __cpp_lib_string_udls 201304L
4435 inline namespace literals
4437 inline namespace string_literals
4439#pragma GCC diagnostic push
4440#pragma GCC diagnostic ignored "-Wliteral-suffix"
4442#if __cpp_lib_constexpr_string >= 201907L
4443# define _GLIBCXX_STRING_CONSTEXPR constexpr
4445# define _GLIBCXX_STRING_CONSTEXPR
4448 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4449 inline basic_string<char>
4450 operator""s(
const char* __str,
size_t __len)
4451 {
return basic_string<char>{__str, __len}; }
4453 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4454 inline basic_string<wchar_t>
4455 operator""s(
const wchar_t* __str,
size_t __len)
4456 {
return basic_string<wchar_t>{__str, __len}; }
4458#ifdef _GLIBCXX_USE_CHAR8_T
4459 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4460 inline basic_string<char8_t>
4461 operator""s(
const char8_t* __str,
size_t __len)
4462 {
return basic_string<char8_t>{__str, __len}; }
4465 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4466 inline basic_string<char16_t>
4467 operator""s(
const char16_t* __str,
size_t __len)
4468 {
return basic_string<char16_t>{__str, __len}; }
4470 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4471 inline basic_string<char32_t>
4472 operator""s(
const char32_t* __str,
size_t __len)
4473 {
return basic_string<char32_t>{__str, __len}; }
4475#undef _GLIBCXX_STRING_CONSTEXPR
4476#pragma GCC diagnostic pop
4480#if __cplusplus >= 201703L
4481 namespace __detail::__variant
4483 template<
typename>
struct _Never_valueless_alt;
4487 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4488 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4490 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4491 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4498_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.