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
53 namespace 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) { }
187 basic_string(__sv_wrapper __svw,
const _Alloc& __a)
188 : basic_string(__svw._M_sv.
data(), __svw._M_sv.
size(), __a) { }
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 _M_local_buf[0] = _CharT();
357 return _M_local_data();
362 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
365 template<
typename _Tp,
bool _Requires =
366 !__are_same<_Tp, _CharT*>::__value
367 && !__are_same<_Tp, const _CharT*>::__value
368 && !__are_same<_Tp, iterator>::__value
369 && !__are_same<_Tp, const_iterator>::__value>
370 struct __enable_if_not_native_iterator
371 {
typedef basic_string& __type; };
372 template<
typename _Tp>
373 struct __enable_if_not_native_iterator<_Tp, false> { };
378 _M_check(size_type __pos,
const char* __s)
const
380 if (__pos > this->
size())
381 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
382 "this->size() (which is %zu)"),
383 __s, __pos, this->
size());
389 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
391 if (this->max_size() - (this->
size() - __n1) < __n2)
392 __throw_length_error(__N(__s));
399 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
401 const bool __testoff = __off < this->
size() - __pos;
402 return __testoff ? __off : this->
size() - __pos;
407 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
409 return (less<const _CharT*>()(__s, _M_data())
410 || less<const _CharT*>()(_M_data() + this->
size(), __s));
417 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
420 traits_type::assign(*__d, *__s);
422 traits_type::copy(__d, __s, __n);
427 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
430 traits_type::assign(*__d, *__s);
432 traits_type::move(__d, __s, __n);
437 _S_assign(_CharT* __d, size_type __n, _CharT __c)
440 traits_type::assign(*__d, __c);
442 traits_type::assign(__d, __n, __c);
447 template<
class _Iterator>
450 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
452 for (; __k1 != __k2; ++__k1, (void)++__p)
453 traits_type::assign(*__p, *__k1);
458 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
459 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
463 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
465 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
469 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
470 { _S_copy(__p, __k1, __k2 - __k1); }
474 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
476 { _S_copy(__p, __k1, __k2 - __k1); }
480 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
482 const difference_type __d = difference_type(__n1 - __n2);
484 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
485 return __gnu_cxx::__numeric_traits<int>::__max;
486 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
487 return __gnu_cxx::__numeric_traits<int>::__min;
494 _M_assign(
const basic_string&);
498 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
503 _M_erase(size_type __pos, size_type __n);
515 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
516 : _M_dataplus(_M_local_data())
527 basic_string(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
528 : _M_dataplus(_M_local_data(), __a)
539 basic_string(
const basic_string& __str)
540 : _M_dataplus(_M_local_data(),
541 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
543 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
556 basic_string(
const basic_string& __str, size_type __pos,
557 const _Alloc& __a = _Alloc())
558 : _M_dataplus(_M_local_data(), __a)
560 const _CharT* __start = __str._M_data()
561 + __str._M_check(__pos,
"basic_string::basic_string");
562 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
573 basic_string(
const basic_string& __str, size_type __pos,
575 : _M_dataplus(_M_local_data())
577 const _CharT* __start = __str._M_data()
578 + __str._M_check(__pos,
"basic_string::basic_string");
579 _M_construct(__start, __start + __str._M_limit(__pos, __n),
591 basic_string(
const basic_string& __str, size_type __pos,
592 size_type __n,
const _Alloc& __a)
593 : _M_dataplus(_M_local_data(), __a)
595 const _CharT* __start
596 = __str._M_data() + __str._M_check(__pos,
"string::string");
597 _M_construct(__start, __start + __str._M_limit(__pos, __n),
611 basic_string(
const _CharT* __s, size_type __n,
612 const _Alloc& __a = _Alloc())
613 : _M_dataplus(_M_local_data(), __a)
616 if (__s == 0 && __n > 0)
617 std::__throw_logic_error(__N(
"basic_string: "
618 "construction from null is not valid"));
627 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
630 template<
typename = _RequireAllocator<_Alloc>>
633 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
634 : _M_dataplus(_M_local_data(), __a)
638 std::__throw_logic_error(__N(
"basic_string: "
639 "construction from null is not valid"));
640 const _CharT* __end = __s + traits_type::length(__s);
641 _M_construct(__s, __end, forward_iterator_tag());
650 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
653 template<
typename = _RequireAllocator<_Alloc>>
656 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
657 : _M_dataplus(_M_local_data(), __a)
658 { _M_construct(__n, __c); }
660 #if __cplusplus >= 201103L
669 basic_string(basic_string&& __str)
noexcept
670 : _M_dataplus(_M_local_data(), std::
move(__str._M_get_allocator()))
672 if (__str._M_is_local())
674 traits_type::copy(_M_local_buf, __str._M_local_buf,
679 _M_data(__str._M_data());
680 _M_capacity(__str._M_allocated_capacity);
686 _M_length(__str.length());
687 __str._M_data(__str._M_local_data());
688 __str._M_set_length(0);
697 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
698 : _M_dataplus(_M_local_data(), __a)
702 basic_string(
const basic_string& __str,
const _Alloc& __a)
703 : _M_dataplus(_M_local_data(), __a)
707 basic_string(basic_string&& __str,
const _Alloc& __a)
708 noexcept(_Alloc_traits::_S_always_equal())
709 : _M_dataplus(_M_local_data(), __a)
711 if (__str._M_is_local())
713 traits_type::copy(_M_local_buf, __str._M_local_buf,
715 _M_length(__str.length());
716 __str._M_set_length(0);
718 else if (_Alloc_traits::_S_always_equal()
719 || __str.get_allocator() == __a)
721 _M_data(__str._M_data());
722 _M_length(__str.length());
723 _M_capacity(__str._M_allocated_capacity);
724 __str._M_data(__str._M_local_buf);
725 __str._M_set_length(0);
732 #if __cplusplus >= 202100L
733 basic_string(nullptr_t) =
delete;
734 basic_string& operator=(nullptr_t) =
delete;
743 #if __cplusplus >= 201103L
744 template<
typename _InputIterator,
745 typename = std::_RequireInputIter<_InputIterator>>
747 template<
typename _InputIterator>
750 basic_string(_InputIterator __beg, _InputIterator __end,
751 const _Alloc& __a = _Alloc())
752 : _M_dataplus(_M_local_data(), __a)
754 #if __cplusplus >= 201103L
757 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
758 _M_construct_aux(__beg, __end, _Integral());
762 #if __cplusplus >= 201703L
770 template<
typename _Tp,
771 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
773 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
774 const _Alloc& __a = _Alloc())
775 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
782 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
785 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
786 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
802 operator=(
const basic_string& __str)
804 return this->
assign(__str);
813 operator=(
const _CharT* __s)
814 {
return this->
assign(__s); }
825 operator=(_CharT __c)
831 #if __cplusplus >= 201103L
843 operator=(basic_string&& __str)
844 noexcept(_Alloc_traits::_S_nothrow_move())
846 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
847 && !_Alloc_traits::_S_always_equal()
848 && _M_get_allocator() != __str._M_get_allocator())
851 _M_destroy(_M_allocated_capacity);
852 _M_data(_M_local_data());
856 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
858 if (__str._M_is_local())
866 this->_S_copy(_M_data(), __str._M_data(), __str.size());
867 _M_set_length(__str.size());
870 else if (_Alloc_traits::_S_propagate_on_move_assign()
871 || _Alloc_traits::_S_always_equal()
872 || _M_get_allocator() == __str._M_get_allocator())
875 pointer __data =
nullptr;
876 size_type __capacity;
879 if (_Alloc_traits::_S_always_equal())
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);
912 operator=(initializer_list<_CharT> __l)
914 this->
assign(__l.begin(), __l.size());
919 #if __cplusplus >= 201703L
924 template<
typename _Tp>
926 _If_sv<_Tp, basic_string&>
927 operator=(
const _Tp& __svt)
928 {
return this->
assign(__svt); }
935 operator __sv_type() const noexcept
936 {
return __sv_type(
data(),
size()); }
946 begin() _GLIBCXX_NOEXCEPT
947 {
return iterator(_M_data()); }
955 begin() const _GLIBCXX_NOEXCEPT
956 {
return const_iterator(_M_data()); }
964 end() _GLIBCXX_NOEXCEPT
965 {
return iterator(_M_data() + this->
size()); }
973 end() const _GLIBCXX_NOEXCEPT
974 {
return const_iterator(_M_data() + this->
size()); }
983 rbegin() _GLIBCXX_NOEXCEPT
984 {
return reverse_iterator(this->
end()); }
992 const_reverse_iterator
993 rbegin() const _GLIBCXX_NOEXCEPT
994 {
return const_reverse_iterator(this->
end()); }
1001 _GLIBCXX20_CONSTEXPR
1003 rend() _GLIBCXX_NOEXCEPT
1004 {
return reverse_iterator(this->
begin()); }
1011 _GLIBCXX20_CONSTEXPR
1012 const_reverse_iterator
1013 rend() const _GLIBCXX_NOEXCEPT
1014 {
return const_reverse_iterator(this->
begin()); }
1016 #if __cplusplus >= 201103L
1021 _GLIBCXX20_CONSTEXPR
1024 {
return const_iterator(this->_M_data()); }
1030 _GLIBCXX20_CONSTEXPR
1032 cend() const noexcept
1033 {
return const_iterator(this->_M_data() + this->
size()); }
1040 _GLIBCXX20_CONSTEXPR
1041 const_reverse_iterator
1043 {
return const_reverse_iterator(this->
end()); }
1050 _GLIBCXX20_CONSTEXPR
1051 const_reverse_iterator
1052 crend() const noexcept
1053 {
return const_reverse_iterator(this->
begin()); }
1060 _GLIBCXX20_CONSTEXPR
1062 size() const _GLIBCXX_NOEXCEPT
1063 {
return _M_string_length; }
1067 _GLIBCXX20_CONSTEXPR
1069 length() const _GLIBCXX_NOEXCEPT
1070 {
return _M_string_length; }
1073 _GLIBCXX20_CONSTEXPR
1075 max_size() const _GLIBCXX_NOEXCEPT
1076 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1088 _GLIBCXX20_CONSTEXPR
1090 resize(size_type __n, _CharT __c);
1102 _GLIBCXX20_CONSTEXPR
1105 { this->
resize(__n, _CharT()); }
1107 #if __cplusplus >= 201103L
1108 #pragma GCC diagnostic push
1109 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1111 _GLIBCXX20_CONSTEXPR
1115 #pragma GCC diagnostic pop
1118 #if __cplusplus > 202002L
1119 #define __cpp_lib_string_resize_and_overwrite 202110L
1120 template<
typename _Operation>
1122 resize_and_overwrite(size_type __n, _Operation __op);
1129 _GLIBCXX20_CONSTEXPR
1133 return _M_is_local() ? size_type(_S_local_capacity)
1134 : _M_allocated_capacity;
1154 _GLIBCXX20_CONSTEXPR
1161 #if __cplusplus > 201703L
1162 [[deprecated(
"use shrink_to_fit() instead")]]
1164 _GLIBCXX20_CONSTEXPR
1171 _GLIBCXX20_CONSTEXPR
1173 clear() _GLIBCXX_NOEXCEPT
1174 { _M_set_length(0); }
1180 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1182 empty() const _GLIBCXX_NOEXCEPT
1183 {
return this->
size() == 0; }
1196 _GLIBCXX20_CONSTEXPR
1198 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1200 __glibcxx_assert(__pos <=
size());
1201 return _M_data()[__pos];
1214 _GLIBCXX20_CONSTEXPR
1220 __glibcxx_assert(__pos <=
size());
1222 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1223 return _M_data()[__pos];
1236 _GLIBCXX20_CONSTEXPR
1238 at(size_type __n)
const
1240 if (__n >= this->
size())
1241 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1242 "(which is %zu) >= this->size() "
1245 return _M_data()[__n];
1258 _GLIBCXX20_CONSTEXPR
1263 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1264 "(which is %zu) >= this->size() "
1267 return _M_data()[__n];
1270 #if __cplusplus >= 201103L
1275 _GLIBCXX20_CONSTEXPR
1279 __glibcxx_assert(!
empty());
1287 _GLIBCXX20_CONSTEXPR
1289 front() const noexcept
1291 __glibcxx_assert(!
empty());
1299 _GLIBCXX20_CONSTEXPR
1303 __glibcxx_assert(!
empty());
1311 _GLIBCXX20_CONSTEXPR
1313 back() const noexcept
1315 __glibcxx_assert(!
empty());
1326 _GLIBCXX20_CONSTEXPR
1329 {
return this->
append(__str); }
1336 _GLIBCXX20_CONSTEXPR
1339 {
return this->
append(__s); }
1346 _GLIBCXX20_CONSTEXPR
1354 #if __cplusplus >= 201103L
1360 _GLIBCXX20_CONSTEXPR
1363 {
return this->
append(__l.begin(), __l.size()); }
1366 #if __cplusplus >= 201703L
1372 template<
typename _Tp>
1373 _GLIBCXX20_CONSTEXPR
1374 _If_sv<_Tp, basic_string&>
1376 {
return this->
append(__svt); }
1384 _GLIBCXX20_CONSTEXPR
1386 append(
const basic_string& __str)
1387 {
return this->
append(__str._M_data(), __str.size()); }
1402 _GLIBCXX20_CONSTEXPR
1404 append(
const basic_string& __str, size_type __pos, size_type __n =
npos)
1405 {
return this->
append(__str._M_data()
1406 + __str._M_check(__pos,
"basic_string::append"),
1407 __str._M_limit(__pos, __n)); }
1415 _GLIBCXX20_CONSTEXPR
1417 append(
const _CharT* __s, size_type __n)
1419 __glibcxx_requires_string_len(__s, __n);
1420 _M_check_length(size_type(0), __n,
"basic_string::append");
1421 return _M_append(__s, __n);
1429 _GLIBCXX20_CONSTEXPR
1431 append(
const _CharT* __s)
1433 __glibcxx_requires_string(__s);
1434 const size_type __n = traits_type::length(__s);
1435 _M_check_length(size_type(0), __n,
"basic_string::append");
1436 return _M_append(__s, __n);
1447 _GLIBCXX20_CONSTEXPR
1449 append(size_type __n, _CharT __c)
1450 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1452 #if __cplusplus >= 201103L
1458 _GLIBCXX20_CONSTEXPR
1460 append(initializer_list<_CharT> __l)
1461 {
return this->
append(__l.begin(), __l.size()); }
1472 #if __cplusplus >= 201103L
1473 template<
class _InputIterator,
1474 typename = std::_RequireInputIter<_InputIterator>>
1475 _GLIBCXX20_CONSTEXPR
1477 template<
class _InputIterator>
1480 append(_InputIterator __first, _InputIterator __last)
1483 #if __cplusplus >= 201703L
1489 template<
typename _Tp>
1490 _GLIBCXX20_CONSTEXPR
1491 _If_sv<_Tp, basic_string&>
1494 __sv_type __sv = __svt;
1495 return this->
append(__sv.data(), __sv.size());
1505 template<
typename _Tp>
1506 _GLIBCXX20_CONSTEXPR
1507 _If_sv<_Tp, basic_string&>
1508 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1510 __sv_type __sv = __svt;
1511 return _M_append(__sv.data()
1512 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1513 std::__sv_limit(__sv.size(), __pos, __n));
1521 _GLIBCXX20_CONSTEXPR
1525 const size_type __size = this->
size();
1527 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1528 traits_type::assign(this->_M_data()[__size], __c);
1529 this->_M_set_length(__size + 1);
1537 _GLIBCXX20_CONSTEXPR
1539 assign(
const basic_string& __str)
1541 #if __cplusplus >= 201103L
1542 if (_Alloc_traits::_S_propagate_on_copy_assign())
1544 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1545 && _M_get_allocator() != __str._M_get_allocator())
1549 if (__str.size() <= _S_local_capacity)
1551 _M_destroy(_M_allocated_capacity);
1552 _M_data(_M_use_local_data());
1557 const auto __len = __str.size();
1558 auto __alloc = __str._M_get_allocator();
1560 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1561 _M_destroy(_M_allocated_capacity);
1564 _M_set_length(__len);
1567 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1570 this->_M_assign(__str);
1574 #if __cplusplus >= 201103L
1583 _GLIBCXX20_CONSTEXPR
1585 assign(basic_string&& __str)
1586 noexcept(_Alloc_traits::_S_nothrow_move())
1607 _GLIBCXX20_CONSTEXPR
1609 assign(
const basic_string& __str, size_type __pos, size_type __n =
npos)
1610 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1611 + __str._M_check(__pos,
"basic_string::assign"),
1612 __str._M_limit(__pos, __n)); }
1624 _GLIBCXX20_CONSTEXPR
1626 assign(
const _CharT* __s, size_type __n)
1628 __glibcxx_requires_string_len(__s, __n);
1629 return _M_replace(size_type(0), this->
size(), __s, __n);
1641 _GLIBCXX20_CONSTEXPR
1643 assign(
const _CharT* __s)
1645 __glibcxx_requires_string(__s);
1646 return _M_replace(size_type(0), this->
size(), __s,
1647 traits_type::length(__s));
1659 _GLIBCXX20_CONSTEXPR
1661 assign(size_type __n, _CharT __c)
1662 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1672 #if __cplusplus >= 201103L
1673 template<
class _InputIterator,
1674 typename = std::_RequireInputIter<_InputIterator>>
1675 _GLIBCXX20_CONSTEXPR
1677 template<
class _InputIterator>
1680 assign(_InputIterator __first, _InputIterator __last)
1683 #if __cplusplus >= 201103L
1689 _GLIBCXX20_CONSTEXPR
1691 assign(initializer_list<_CharT> __l)
1692 {
return this->
assign(__l.begin(), __l.size()); }
1695 #if __cplusplus >= 201703L
1701 template<
typename _Tp>
1702 _GLIBCXX20_CONSTEXPR
1703 _If_sv<_Tp, basic_string&>
1706 __sv_type __sv = __svt;
1707 return this->
assign(__sv.data(), __sv.size());
1717 template<
typename _Tp>
1718 _GLIBCXX20_CONSTEXPR
1719 _If_sv<_Tp, basic_string&>
1720 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1722 __sv_type __sv = __svt;
1723 return _M_replace(size_type(0), this->
size(),
1725 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1726 std::__sv_limit(__sv.size(), __pos, __n));
1730 #if __cplusplus >= 201103L
1746 _GLIBCXX20_CONSTEXPR
1748 insert(const_iterator __p, size_type __n, _CharT __c)
1750 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1751 const size_type __pos = __p -
begin();
1752 this->
replace(__p, __p, __n, __c);
1753 return iterator(this->_M_data() + __pos);
1770 insert(iterator __p, size_type __n, _CharT __c)
1771 { this->
replace(__p, __p, __n, __c); }
1774 #if __cplusplus >= 201103L
1789 template<
class _InputIterator,
1790 typename = std::_RequireInputIter<_InputIterator>>
1791 _GLIBCXX20_CONSTEXPR
1793 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1795 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1796 const size_type __pos = __p -
begin();
1797 this->
replace(__p, __p, __beg, __end);
1798 return iterator(this->_M_data() + __pos);
1813 template<
class _InputIterator>
1815 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1816 { this->
replace(__p, __p, __beg, __end); }
1819 #if __cplusplus >= 201103L
1826 _GLIBCXX20_CONSTEXPR
1828 insert(const_iterator __p, initializer_list<_CharT> __l)
1829 {
return this->
insert(__p, __l.begin(), __l.end()); }
1831 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1834 insert(iterator __p, initializer_list<_CharT> __l)
1836 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1837 this->
insert(__p -
begin(), __l.begin(), __l.size());
1854 _GLIBCXX20_CONSTEXPR
1856 insert(size_type __pos1,
const basic_string& __str)
1857 {
return this->
replace(__pos1, size_type(0),
1858 __str._M_data(), __str.size()); }
1878 _GLIBCXX20_CONSTEXPR
1880 insert(size_type __pos1,
const basic_string& __str,
1881 size_type __pos2, size_type __n =
npos)
1882 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1883 + __str._M_check(__pos2,
"basic_string::insert"),
1884 __str._M_limit(__pos2, __n)); }
1902 _GLIBCXX20_CONSTEXPR
1904 insert(size_type __pos,
const _CharT* __s, size_type __n)
1905 {
return this->
replace(__pos, size_type(0), __s, __n); }
1922 _GLIBCXX20_CONSTEXPR
1924 insert(size_type __pos,
const _CharT* __s)
1926 __glibcxx_requires_string(__s);
1927 return this->
replace(__pos, size_type(0), __s,
1928 traits_type::length(__s));
1947 _GLIBCXX20_CONSTEXPR
1949 insert(size_type __pos, size_type __n, _CharT __c)
1950 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1951 size_type(0), __n, __c); }
1966 _GLIBCXX20_CONSTEXPR
1968 insert(__const_iterator __p, _CharT __c)
1970 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1971 const size_type __pos = __p -
begin();
1972 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1973 return iterator(_M_data() + __pos);
1976 #if __cplusplus >= 201703L
1983 template<
typename _Tp>
1984 _GLIBCXX20_CONSTEXPR
1985 _If_sv<_Tp, basic_string&>
1986 insert(size_type __pos,
const _Tp& __svt)
1988 __sv_type __sv = __svt;
1989 return this->
insert(__pos, __sv.data(), __sv.size());
2000 template<
typename _Tp>
2001 _GLIBCXX20_CONSTEXPR
2002 _If_sv<_Tp, basic_string&>
2003 insert(size_type __pos1,
const _Tp& __svt,
2004 size_type __pos2, size_type __n =
npos)
2006 __sv_type __sv = __svt;
2007 return this->
replace(__pos1, size_type(0),
2009 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2010 std::__sv_limit(__sv.size(), __pos2, __n));
2029 _GLIBCXX20_CONSTEXPR
2031 erase(size_type __pos = 0, size_type __n =
npos)
2033 _M_check(__pos,
"basic_string::erase");
2035 this->_M_set_length(__pos);
2037 this->_M_erase(__pos, _M_limit(__pos, __n));
2049 _GLIBCXX20_CONSTEXPR
2051 erase(__const_iterator __position)
2053 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2054 && __position <
end());
2055 const size_type __pos = __position -
begin();
2056 this->_M_erase(__pos, size_type(1));
2057 return iterator(_M_data() + __pos);
2069 _GLIBCXX20_CONSTEXPR
2071 erase(__const_iterator __first, __const_iterator __last)
2073 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2074 && __last <=
end());
2075 const size_type __pos = __first -
begin();
2076 if (__last ==
end())
2077 this->_M_set_length(__pos);
2079 this->_M_erase(__pos, __last - __first);
2080 return iterator(this->_M_data() + __pos);
2083 #if __cplusplus >= 201103L
2089 _GLIBCXX20_CONSTEXPR
2093 __glibcxx_assert(!
empty());
2094 _M_erase(
size() - 1, 1);
2115 _GLIBCXX20_CONSTEXPR
2117 replace(size_type __pos, size_type __n,
const basic_string& __str)
2118 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2138 _GLIBCXX20_CONSTEXPR
2140 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
2141 size_type __pos2, size_type __n2 =
npos)
2142 {
return this->
replace(__pos1, __n1, __str._M_data()
2143 + __str._M_check(__pos2,
"basic_string::replace"),
2144 __str._M_limit(__pos2, __n2)); }
2164 _GLIBCXX20_CONSTEXPR
2166 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2169 __glibcxx_requires_string_len(__s, __n2);
2170 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2171 _M_limit(__pos, __n1), __s, __n2);
2190 _GLIBCXX20_CONSTEXPR
2192 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2194 __glibcxx_requires_string(__s);
2195 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2215 _GLIBCXX20_CONSTEXPR
2217 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2218 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2219 _M_limit(__pos, __n1), __n2, __c); }
2234 _GLIBCXX20_CONSTEXPR
2236 replace(__const_iterator __i1, __const_iterator __i2,
2237 const basic_string& __str)
2238 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2255 _GLIBCXX20_CONSTEXPR
2257 replace(__const_iterator __i1, __const_iterator __i2,
2258 const _CharT* __s, size_type __n)
2260 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2262 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2278 _GLIBCXX20_CONSTEXPR
2280 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2282 __glibcxx_requires_string(__s);
2283 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2300 _GLIBCXX20_CONSTEXPR
2302 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2305 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2307 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2325 #if __cplusplus >= 201103L
2326 template<
class _InputIterator,
2327 typename = std::_RequireInputIter<_InputIterator>>
2328 _GLIBCXX20_CONSTEXPR
2330 replace(const_iterator __i1, const_iterator __i2,
2331 _InputIterator __k1, _InputIterator __k2)
2333 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2335 __glibcxx_requires_valid_range(__k1, __k2);
2336 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2337 std::__false_type());
2340 template<
class _InputIterator>
2341 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2342 typename __enable_if_not_native_iterator<_InputIterator>::__type
2346 replace(iterator __i1, iterator __i2,
2347 _InputIterator __k1, _InputIterator __k2)
2349 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2351 __glibcxx_requires_valid_range(__k1, __k2);
2352 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2353 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2359 _GLIBCXX20_CONSTEXPR
2361 replace(__const_iterator __i1, __const_iterator __i2,
2362 _CharT* __k1, _CharT* __k2)
2364 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2366 __glibcxx_requires_valid_range(__k1, __k2);
2371 _GLIBCXX20_CONSTEXPR
2373 replace(__const_iterator __i1, __const_iterator __i2,
2374 const _CharT* __k1,
const _CharT* __k2)
2376 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2378 __glibcxx_requires_valid_range(__k1, __k2);
2383 _GLIBCXX20_CONSTEXPR
2385 replace(__const_iterator __i1, __const_iterator __i2,
2386 iterator __k1, iterator __k2)
2388 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2390 __glibcxx_requires_valid_range(__k1, __k2);
2392 __k1.base(), __k2 - __k1);
2395 _GLIBCXX20_CONSTEXPR
2397 replace(__const_iterator __i1, __const_iterator __i2,
2398 const_iterator __k1, const_iterator __k2)
2400 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2402 __glibcxx_requires_valid_range(__k1, __k2);
2404 __k1.base(), __k2 - __k1);
2407 #if __cplusplus >= 201103L
2422 _GLIBCXX20_CONSTEXPR
2423 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2424 initializer_list<_CharT> __l)
2425 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2428 #if __cplusplus >= 201703L
2436 template<
typename _Tp>
2437 _GLIBCXX20_CONSTEXPR
2438 _If_sv<_Tp, basic_string&>
2439 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2441 __sv_type __sv = __svt;
2442 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2454 template<
typename _Tp>
2455 _GLIBCXX20_CONSTEXPR
2456 _If_sv<_Tp, basic_string&>
2457 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2458 size_type __pos2, size_type __n2 =
npos)
2460 __sv_type __sv = __svt;
2461 return this->
replace(__pos1, __n1,
2463 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2464 std::__sv_limit(__sv.size(), __pos2, __n2));
2476 template<
typename _Tp>
2477 _GLIBCXX20_CONSTEXPR
2478 _If_sv<_Tp, basic_string&>
2479 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2481 __sv_type __sv = __svt;
2482 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2487 template<
class _Integer>
2488 _GLIBCXX20_CONSTEXPR
2490 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2491 _Integer __n, _Integer __val, __true_type)
2492 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2494 template<
class _InputIterator>
2495 _GLIBCXX20_CONSTEXPR
2497 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2498 _InputIterator __k1, _InputIterator __k2,
2501 _GLIBCXX20_CONSTEXPR
2503 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2506 _GLIBCXX20_CONSTEXPR
2508 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2509 const size_type __len2);
2511 _GLIBCXX20_CONSTEXPR
2513 _M_append(
const _CharT* __s, size_type __n);
2529 _GLIBCXX20_CONSTEXPR
2531 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2540 _GLIBCXX20_CONSTEXPR
2542 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2551 _GLIBCXX20_CONSTEXPR
2553 c_str() const _GLIBCXX_NOEXCEPT
2554 {
return _M_data(); }
2564 _GLIBCXX20_CONSTEXPR
2566 data() const _GLIBCXX_NOEXCEPT
2567 {
return _M_data(); }
2569 #if __cplusplus >= 201703L
2576 _GLIBCXX20_CONSTEXPR
2579 {
return _M_data(); }
2585 _GLIBCXX20_CONSTEXPR
2588 {
return _M_get_allocator(); }
2602 _GLIBCXX20_CONSTEXPR
2604 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2617 _GLIBCXX20_CONSTEXPR
2619 find(
const basic_string& __str, size_type __pos = 0) const
2621 {
return this->
find(__str.data(), __pos, __str.size()); }
2623 #if __cplusplus >= 201703L
2630 template<
typename _Tp>
2631 _GLIBCXX20_CONSTEXPR
2632 _If_sv<_Tp, size_type>
2633 find(
const _Tp& __svt, size_type __pos = 0) const
2634 noexcept(is_same<_Tp, __sv_type>::value)
2636 __sv_type __sv = __svt;
2637 return this->
find(__sv.data(), __pos, __sv.size());
2651 _GLIBCXX20_CONSTEXPR
2653 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2655 __glibcxx_requires_string(__s);
2656 return this->
find(__s, __pos, traits_type::length(__s));
2669 _GLIBCXX20_CONSTEXPR
2671 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2683 _GLIBCXX20_CONSTEXPR
2685 rfind(const basic_string& __str, size_type __pos =
npos) const
2687 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2689 #if __cplusplus >= 201703L
2696 template<
typename _Tp>
2697 _GLIBCXX20_CONSTEXPR
2698 _If_sv<_Tp, size_type>
2699 rfind(
const _Tp& __svt, size_type __pos =
npos) const
2700 noexcept(is_same<_Tp, __sv_type>::value)
2702 __sv_type __sv = __svt;
2703 return this->
rfind(__sv.data(), __pos, __sv.size());
2719 _GLIBCXX20_CONSTEXPR
2721 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2734 _GLIBCXX20_CONSTEXPR
2736 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2738 __glibcxx_requires_string(__s);
2739 return this->
rfind(__s, __pos, traits_type::length(__s));
2752 _GLIBCXX20_CONSTEXPR
2754 rfind(_CharT __c, size_type __pos =
npos) const _GLIBCXX_NOEXCEPT;
2767 _GLIBCXX20_CONSTEXPR
2769 find_first_of(const basic_string& __str, size_type __pos = 0) const
2771 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2773 #if __cplusplus >= 201703L
2781 template<
typename _Tp>
2782 _GLIBCXX20_CONSTEXPR
2783 _If_sv<_Tp, size_type>
2785 noexcept(is_same<_Tp, __sv_type>::value)
2787 __sv_type __sv = __svt;
2788 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2804 _GLIBCXX20_CONSTEXPR
2806 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2819 _GLIBCXX20_CONSTEXPR
2824 __glibcxx_requires_string(__s);
2825 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2840 _GLIBCXX20_CONSTEXPR
2842 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2843 {
return this->
find(__c, __pos); }
2856 _GLIBCXX20_CONSTEXPR
2860 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2862 #if __cplusplus >= 201703L
2870 template<
typename _Tp>
2871 _GLIBCXX20_CONSTEXPR
2872 _If_sv<_Tp, size_type>
2874 noexcept(is_same<_Tp, __sv_type>::value)
2876 __sv_type __sv = __svt;
2877 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2893 _GLIBCXX20_CONSTEXPR
2895 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2908 _GLIBCXX20_CONSTEXPR
2913 __glibcxx_requires_string(__s);
2914 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2929 _GLIBCXX20_CONSTEXPR
2932 {
return this->
rfind(__c, __pos); }
2944 _GLIBCXX20_CONSTEXPR
2950 #if __cplusplus >= 201703L
2958 template<
typename _Tp>
2959 _If_sv<_Tp, size_type>
2960 _GLIBCXX20_CONSTEXPR
2962 noexcept(is_same<_Tp, __sv_type>::value)
2964 __sv_type __sv = __svt;
2981 _GLIBCXX20_CONSTEXPR
2984 size_type __n)
const _GLIBCXX_NOEXCEPT;
2996 _GLIBCXX20_CONSTEXPR
3001 __glibcxx_requires_string(__s);
3015 _GLIBCXX20_CONSTEXPR
3031 _GLIBCXX20_CONSTEXPR
3037 #if __cplusplus >= 201703L
3045 template<
typename _Tp>
3046 _GLIBCXX20_CONSTEXPR
3047 _If_sv<_Tp, size_type>
3049 noexcept(is_same<_Tp, __sv_type>::value)
3051 __sv_type __sv = __svt;
3068 _GLIBCXX20_CONSTEXPR
3071 size_type __n)
const _GLIBCXX_NOEXCEPT;
3083 _GLIBCXX20_CONSTEXPR
3088 __glibcxx_requires_string(__s);
3102 _GLIBCXX20_CONSTEXPR
3119 _GLIBCXX20_CONSTEXPR
3121 substr(size_type __pos = 0, size_type __n =
npos)
const
3122 {
return basic_string(*
this,
3123 _M_check(__pos,
"basic_string::substr"), __n); }
3139 _GLIBCXX20_CONSTEXPR
3141 compare(
const basic_string& __str)
const
3143 const size_type __size = this->
size();
3144 const size_type __osize = __str.size();
3145 const size_type __len =
std::min(__size, __osize);
3147 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3149 __r = _S_compare(__size, __osize);
3153 #if __cplusplus >= 201703L
3159 template<
typename _Tp>
3160 _GLIBCXX20_CONSTEXPR
3162 compare(
const _Tp& __svt)
const
3163 noexcept(is_same<_Tp, __sv_type>::value)
3165 __sv_type __sv = __svt;
3166 const size_type __size = this->
size();
3167 const size_type __osize = __sv.size();
3168 const size_type __len =
std::min(__size, __osize);
3170 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3172 __r = _S_compare(__size, __osize);
3184 template<
typename _Tp>
3185 _GLIBCXX20_CONSTEXPR
3187 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3188 noexcept(is_same<_Tp, __sv_type>::value)
3190 __sv_type __sv = __svt;
3191 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3204 template<
typename _Tp>
3205 _GLIBCXX20_CONSTEXPR
3207 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3208 size_type __pos2, size_type __n2 = npos) const
3209 noexcept(is_same<_Tp, __sv_type>::value)
3211 __sv_type __sv = __svt;
3212 return __sv_type(*
this)
3213 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3236 _GLIBCXX20_CONSTEXPR
3238 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
3263 _GLIBCXX20_CONSTEXPR
3265 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
3266 size_type __pos2, size_type __n2 = npos)
const;
3282 _GLIBCXX20_CONSTEXPR
3284 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3307 _GLIBCXX20_CONSTEXPR
3309 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3335 _GLIBCXX20_CONSTEXPR
3337 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3338 size_type __n2)
const;
3340 #if __cplusplus >= 202002L
3342 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3343 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3346 starts_with(_CharT __x)
const noexcept
3347 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3350 starts_with(
const _CharT* __x)
const noexcept
3351 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3354 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3355 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3358 ends_with(_CharT __x)
const noexcept
3359 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3362 ends_with(
const _CharT* __x)
const noexcept
3363 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3366 #if __cplusplus > 202002L
3368 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3369 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3372 contains(_CharT __x)
const noexcept
3373 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3376 contains(
const _CharT* __x)
const noexcept
3377 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3381 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3383 _GLIBCXX_END_NAMESPACE_CXX11
3384 _GLIBCXX_END_NAMESPACE_VERSION
3386 #endif // _GLIBCXX_USE_CXX11_ABI
3388 namespace std _GLIBCXX_VISIBILITY(default)
3390 _GLIBCXX_BEGIN_NAMESPACE_VERSION
3392 #if __cpp_deduction_guides >= 201606
3393 _GLIBCXX_BEGIN_NAMESPACE_CXX11
3394 template<
typename _InputIterator,
typename _CharT
3395 =
typename iterator_traits<_InputIterator>::value_type,
3396 typename _Allocator = allocator<_CharT>,
3397 typename = _RequireInputIter<_InputIterator>,
3398 typename = _RequireAllocator<_Allocator>>
3399 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3400 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3404 template<
typename _CharT,
typename _Traits,
3405 typename _Allocator = allocator<_CharT>,
3406 typename = _RequireAllocator<_Allocator>>
3407 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3408 -> basic_string<_CharT, _Traits, _Allocator>;
3410 template<
typename _CharT,
typename _Traits,
3411 typename _Allocator = allocator<_CharT>,
3412 typename = _RequireAllocator<_Allocator>>
3413 basic_string(basic_string_view<_CharT, _Traits>,
3414 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3415 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3416 const _Allocator& = _Allocator())
3417 -> basic_string<_CharT, _Traits, _Allocator>;
3418 _GLIBCXX_END_NAMESPACE_CXX11
3428 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3429 _GLIBCXX20_CONSTEXPR
3430 basic_string<_CharT, _Traits, _Alloc>
3435 __str.append(__rhs);
3445 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3446 _GLIBCXX20_CONSTEXPR
3447 basic_string<_CharT,_Traits,_Alloc>
3449 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
3457 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3458 _GLIBCXX20_CONSTEXPR
3459 basic_string<_CharT,_Traits,_Alloc>
3460 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
3468 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3469 _GLIBCXX20_CONSTEXPR
3470 inline basic_string<_CharT, _Traits, _Alloc>
3472 const _CharT* __rhs)
3475 __str.append(__rhs);
3485 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3486 _GLIBCXX20_CONSTEXPR
3487 inline basic_string<_CharT, _Traits, _Alloc>
3491 typedef typename __string_type::size_type __size_type;
3492 __string_type __str(__lhs);
3493 __str.append(__size_type(1), __rhs);
3497 #if __cplusplus >= 201103L
3498 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3499 _GLIBCXX20_CONSTEXPR
3500 inline basic_string<_CharT, _Traits, _Alloc>
3501 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3502 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3503 {
return std::move(__lhs.append(__rhs)); }
3505 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3506 _GLIBCXX20_CONSTEXPR
3507 inline basic_string<_CharT, _Traits, _Alloc>
3508 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3509 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3510 {
return std::move(__rhs.insert(0, __lhs)); }
3512 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3513 _GLIBCXX20_CONSTEXPR
3514 inline basic_string<_CharT, _Traits, _Alloc>
3515 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3516 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3518 #if _GLIBCXX_USE_CXX11_ABI
3519 using _Alloc_traits = allocator_traits<_Alloc>;
3520 bool __use_rhs =
false;
3521 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3523 else if (__lhs.get_allocator() == __rhs.get_allocator())
3528 const auto __size = __lhs.size() + __rhs.size();
3529 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3530 return std::move(__rhs.insert(0, __lhs));
3535 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3536 _GLIBCXX20_CONSTEXPR
3537 inline basic_string<_CharT, _Traits, _Alloc>
3539 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3540 {
return std::move(__rhs.insert(0, __lhs)); }
3542 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3543 _GLIBCXX20_CONSTEXPR
3544 inline basic_string<_CharT, _Traits, _Alloc>
3546 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3547 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3549 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3550 _GLIBCXX20_CONSTEXPR
3551 inline basic_string<_CharT, _Traits, _Alloc>
3552 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3553 const _CharT* __rhs)
3554 {
return std::move(__lhs.append(__rhs)); }
3556 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3557 _GLIBCXX20_CONSTEXPR
3558 inline basic_string<_CharT, _Traits, _Alloc>
3559 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3561 {
return std::move(__lhs.append(1, __rhs)); }
3571 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3572 _GLIBCXX20_CONSTEXPR
3577 {
return __lhs.compare(__rhs) == 0; }
3579 template<
typename _CharT>
3580 _GLIBCXX20_CONSTEXPR
3582 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
3583 operator==(
const basic_string<_CharT>& __lhs,
3584 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
3585 {
return (__lhs.size() == __rhs.size()
3595 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3596 _GLIBCXX20_CONSTEXPR
3599 const _CharT* __rhs)
3600 {
return __lhs.compare(__rhs) == 0; }
3602 #if __cpp_lib_three_way_comparison
3610 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3612 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3613 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
3614 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3615 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3624 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3626 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3627 const _CharT* __rhs) noexcept
3628 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3629 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3637 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3639 operator==(
const _CharT* __lhs,
3641 {
return __rhs.compare(__lhs) == 0; }
3650 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3655 {
return !(__lhs == __rhs); }
3663 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3665 operator!=(
const _CharT* __lhs,
3667 {
return !(__lhs == __rhs); }
3675 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3678 const _CharT* __rhs)
3679 {
return !(__lhs == __rhs); }
3688 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3690 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3693 {
return __lhs.
compare(__rhs) < 0; }
3701 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3703 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3704 const _CharT* __rhs)
3705 {
return __lhs.compare(__rhs) < 0; }
3713 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3715 operator<(
const _CharT* __lhs,
3717 {
return __rhs.compare(__lhs) > 0; }
3726 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3731 {
return __lhs.compare(__rhs) > 0; }
3739 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3742 const _CharT* __rhs)
3743 {
return __lhs.compare(__rhs) > 0; }
3751 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3753 operator>(
const _CharT* __lhs,
3755 {
return __rhs.compare(__lhs) < 0; }
3764 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3766 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3769 {
return __lhs.
compare(__rhs) <= 0; }
3777 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3779 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3780 const _CharT* __rhs)
3781 {
return __lhs.compare(__rhs) <= 0; }
3789 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3791 operator<=(
const _CharT* __lhs,
3793 {
return __rhs.compare(__lhs) >= 0; }
3802 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3807 {
return __lhs.compare(__rhs) >= 0; }
3815 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3818 const _CharT* __rhs)
3819 {
return __lhs.compare(__rhs) >= 0; }
3827 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3829 operator>=(
const _CharT* __lhs,
3831 {
return __rhs.compare(__lhs) <= 0; }
3832 #endif // three-way comparison
3841 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3842 _GLIBCXX20_CONSTEXPR
3846 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
3847 { __lhs.swap(__rhs); }
3862 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3863 basic_istream<_CharT, _Traits>&
3864 operator>>(basic_istream<_CharT, _Traits>& __is,
3865 basic_string<_CharT, _Traits, _Alloc>& __str);
3868 basic_istream<char>&
3869 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
3880 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3881 inline basic_ostream<_CharT, _Traits>&
3882 operator<<(basic_ostream<_CharT, _Traits>& __os,
3887 return __ostream_insert(__os, __str.data(), __str.size());
3903 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3904 basic_istream<_CharT, _Traits>&
3905 getline(basic_istream<_CharT, _Traits>& __is,
3906 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
3920 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3921 inline basic_istream<_CharT, _Traits>&
3926 #if __cplusplus >= 201103L
3928 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3929 inline basic_istream<_CharT, _Traits>&
3935 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3936 inline basic_istream<_CharT, _Traits>&
3943 basic_istream<char>&
3944 getline(basic_istream<char>& __in, basic_string<char>& __str,
3947 #ifdef _GLIBCXX_USE_WCHAR_T
3949 basic_istream<wchar_t>&
3950 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
3954 _GLIBCXX_END_NAMESPACE_VERSION
3957 #if __cplusplus >= 201103L
3962 namespace std _GLIBCXX_VISIBILITY(default)
3964 _GLIBCXX_BEGIN_NAMESPACE_VERSION
3965 _GLIBCXX_BEGIN_NAMESPACE_CXX11
3967 #if _GLIBCXX_USE_C99_STDLIB
3970 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
3971 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
3975 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
3976 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
3979 inline unsigned long
3980 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
3981 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
3985 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
3986 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
3989 inline unsigned long long
3990 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
3991 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
3996 stof(
const string& __str,
size_t* __idx = 0)
3997 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4000 stod(
const string& __str,
size_t* __idx = 0)
4001 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4004 stold(
const string& __str,
size_t* __idx = 0)
4005 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4006 #endif // _GLIBCXX_USE_C99_STDLIB
4011 to_string(
int __val)
4012 #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4016 const bool __neg = __val < 0;
4017 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4018 const auto __len = __detail::__to_chars_len(__uval);
4019 string __str(__neg + __len,
'-');
4020 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4025 to_string(
unsigned __val)
4026 #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4030 string __str(__detail::__to_chars_len(__val),
'\0');
4031 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4036 to_string(
long __val)
4037 #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4041 const bool __neg = __val < 0;
4042 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4043 const auto __len = __detail::__to_chars_len(__uval);
4044 string __str(__neg + __len,
'-');
4045 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4050 to_string(
unsigned long __val)
4051 #if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4055 string __str(__detail::__to_chars_len(__val),
'\0');
4056 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4061 to_string(
long long __val)
4063 const bool __neg = __val < 0;
4064 const unsigned long long __uval
4065 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4066 const auto __len = __detail::__to_chars_len(__uval);
4067 string __str(__neg + __len,
'-');
4068 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4073 to_string(
unsigned long long __val)
4075 string __str(__detail::__to_chars_len(__val),
'\0');
4076 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4080 #if _GLIBCXX_USE_C99_STDIO
4084 to_string(
float __val)
4087 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4088 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4093 to_string(
double __val)
4096 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4097 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4102 to_string(
long double __val)
4105 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4106 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4109 #endif // _GLIBCXX_USE_C99_STDIO
4111 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4113 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4114 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4118 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4119 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4122 inline unsigned long
4123 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4124 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4128 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4129 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4132 inline unsigned long long
4133 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4134 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4139 stof(
const wstring& __str,
size_t* __idx = 0)
4140 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4143 stod(
const wstring& __str,
size_t* __idx = 0)
4144 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4147 stold(
const wstring& __str,
size_t* __idx = 0)
4148 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4150 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4153 to_wstring(
int __val)
4154 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
4158 to_wstring(
unsigned __val)
4159 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4160 4 *
sizeof(unsigned),
4164 to_wstring(
long __val)
4165 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
4169 to_wstring(
unsigned long __val)
4170 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4171 4 *
sizeof(
unsigned long),
4175 to_wstring(
long long __val)
4176 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4177 4 *
sizeof(
long long),
4181 to_wstring(
unsigned long long __val)
4182 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
4183 4 *
sizeof(
unsigned long long),
4187 to_wstring(
float __val)
4190 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4191 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4196 to_wstring(
double __val)
4199 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4200 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4205 to_wstring(
long double __val)
4208 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4209 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
4212 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4213 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
4215 _GLIBCXX_END_NAMESPACE_CXX11
4216 _GLIBCXX_END_NAMESPACE_VERSION
4221 #if __cplusplus >= 201103L
4225 namespace std _GLIBCXX_VISIBILITY(default)
4227 _GLIBCXX_BEGIN_NAMESPACE_VERSION
4231 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4235 :
public __hash_base<size_t, string>
4238 operator()(
const string& __s)
const noexcept
4239 {
return std::_Hash_impl::hash(__s.
data(), __s.length()); }
4249 :
public __hash_base<size_t, wstring>
4252 operator()(
const wstring& __s)
const noexcept
4253 {
return std::_Hash_impl::hash(__s.
data(),
4254 __s.length() *
sizeof(wchar_t)); }
4262 #ifdef _GLIBCXX_USE_CHAR8_T
4265 struct hash<u8string>
4266 :
public __hash_base<size_t, u8string>
4269 operator()(
const u8string& __s)
const noexcept
4270 {
return std::_Hash_impl::hash(__s.data(),
4271 __s.length() *
sizeof(char8_t)); }
4282 :
public __hash_base<size_t, u16string>
4285 operator()(
const u16string& __s)
const noexcept
4286 {
return std::_Hash_impl::hash(__s.
data(),
4287 __s.length() *
sizeof(char16_t)); }
4297 :
public __hash_base<size_t, u32string>
4300 operator()(
const u32string& __s)
const noexcept
4301 {
return std::_Hash_impl::hash(__s.
data(),
4302 __s.length() *
sizeof(char32_t)); }
4309 #if __cplusplus >= 201402L
4311 #define __cpp_lib_string_udls 201304L
4313 inline namespace literals
4315 inline namespace string_literals
4317 #pragma GCC diagnostic push
4318 #pragma GCC diagnostic ignored "-Wliteral-suffix"
4320 #if __cpp_lib_constexpr_string >= 201907L
4321 # define _GLIBCXX_STRING_CONSTEXPR constexpr
4323 # define _GLIBCXX_STRING_CONSTEXPR
4326 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4327 inline basic_string<char>
4328 operator""s(
const char* __str,
size_t __len)
4329 {
return basic_string<char>{__str, __len}; }
4331 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4332 inline basic_string<wchar_t>
4333 operator""s(
const wchar_t* __str,
size_t __len)
4334 {
return basic_string<wchar_t>{__str, __len}; }
4336 #ifdef _GLIBCXX_USE_CHAR8_T
4337 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4338 inline basic_string<char8_t>
4339 operator""s(
const char8_t* __str,
size_t __len)
4340 {
return basic_string<char8_t>{__str, __len}; }
4343 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4344 inline basic_string<char16_t>
4345 operator""s(
const char16_t* __str,
size_t __len)
4346 {
return basic_string<char16_t>{__str, __len}; }
4348 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4349 inline basic_string<char32_t>
4350 operator""s(
const char32_t* __str,
size_t __len)
4351 {
return basic_string<char32_t>{__str, __len}; }
4353 #undef _GLIBCXX_STRING_CONSTEXPR
4354 #pragma GCC diagnostic pop
4358 #if __cplusplus >= 201703L
4359 namespace __detail::__variant
4361 template<
typename>
struct _Never_valueless_alt;
4365 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4366 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
4368 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4369 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4376 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & append(const basic_string &__str)
Append a string to this string.
void noexcept()
Swap contents with another string.
constexpr auto rbegin(_Container &__cont) -> decltype(__cont.rbegin())
Return a reverse iterator pointing to the last element of the container.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string< wchar_t > wstring
A string of wchar_t.
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.
constexpr bool is_constant_evaluated() noexcept
Returns true only when called during constant evaluation.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
size_type capacity() const noexcept
void reserve()
Equivalent to shrink_to_fit().
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
const _CharT * data() const noexcept
Return const pointer to contents.
Managing sequences of characters and character-like objects.
void pop_back()
Remove the last character.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
bool empty() const noexcept
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.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
Uniform interface to C++98 and C++11 allocators.
Uniform interface to all pointer-like types.
static const size_type npos
Value returned by various member functions when they fail.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
Template class basic_istream.
char_type widen(char __c) const
Widens characters.
constexpr _Iterator __base(_Iterator __it)
Forward iterators support a superset of input iterator operations.
int compare(const basic_string &__str) const
Compare to a string.
Primary class template hash.
constexpr auto crbegin(const _Container &__cont) -> decltype(std::rbegin(__cont))
Return a reverse iterator pointing to the last element of the const container.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
Return an iterator pointing to one past the last element of the const container.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
Basis for explicit traits specializations.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr auto rend(_Container &__cont) -> decltype(__cont.rend())
Return a reverse iterator pointing one past the first element of the container.
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.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
constexpr auto crend(const _Container &__cont) -> decltype(std::rend(__cont))
Return a reverse iterator pointing one past the first element of the const container.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
void push_back(_CharT __c)
Append a single character.