34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
37#pragma GCC system_header
42#if __cplusplus >= 201103L
46#if __cplusplus >= 201703L
50#if ! _GLIBCXX_USE_CXX11_ABI
53namespace std _GLIBCXX_VISIBILITY(default)
55_GLIBCXX_BEGIN_NAMESPACE_VERSION
56_GLIBCXX_BEGIN_NAMESPACE_CXX11
58#ifdef __cpp_lib_is_constant_evaluated
60# define __cpp_lib_constexpr_string 201907L
61#elif __cplusplus >= 201703L && _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
63# define __cpp_lib_constexpr_string 201611L
86 template<
typename _CharT,
typename _Traits,
typename _Alloc>
90 rebind<_CharT>::other _Char_alloc_type;
96 typedef _Traits traits_type;
97 typedef typename _Traits::char_type value_type;
98 typedef _Char_alloc_type allocator_type;
99 typedef typename _Alloc_traits::size_type size_type;
100 typedef typename _Alloc_traits::difference_type difference_type;
101 typedef typename _Alloc_traits::reference reference;
102 typedef typename _Alloc_traits::const_reference const_reference;
103 typedef typename _Alloc_traits::pointer pointer;
104 typedef typename _Alloc_traits::const_pointer const_pointer;
105 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
106 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
112 static const size_type
npos =
static_cast<size_type
>(-1);
116#if __cplusplus < 201103L
117 typedef iterator __const_iterator;
119 typedef const_iterator __const_iterator;
123 static _GLIBCXX20_CONSTEXPR pointer
124 _S_allocate(_Char_alloc_type& __a, size_type __n)
126 pointer __p = _Alloc_traits::allocate(__a, __n);
127#if __cpp_lib_constexpr_string >= 201907L
130 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
131 if (std::__is_constant_evaluated())
133 for (size_type __i = 0; __i < __n; ++__i)
134 std::construct_at(__builtin_addressof(__p[__i]));
139#if __cplusplus >= 201703L
141 typedef basic_string_view<_CharT, _Traits> __sv_type;
143 template<
typename _Tp,
typename _Res>
145 __and_<is_convertible<const _Tp&, __sv_type>,
146 __not_<is_convertible<const _Tp*, const basic_string*>>,
147 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
153 _S_to_string_view(__sv_type __svt)
noexcept
162 _GLIBCXX20_CONSTEXPR
explicit
163 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
181 struct _Alloc_hider : allocator_type
183#if __cplusplus < 201103L
184 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
185 : allocator_type(__a), _M_p(__dat) { }
188 _Alloc_hider(pointer __dat,
const _Alloc& __a)
189 : allocator_type(__a), _M_p(__dat) { }
192 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
193 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
199 _Alloc_hider _M_dataplus;
200 size_type _M_string_length;
202 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
206 _CharT _M_local_buf[_S_local_capacity + 1];
207 size_type _M_allocated_capacity;
213 { _M_dataplus._M_p = __p; }
217 _M_length(size_type __length)
218 { _M_string_length = __length; }
223 {
return _M_dataplus._M_p; }
229#if __cplusplus >= 201103L
232 return pointer(_M_local_buf);
238 _M_local_data()
const
240#if __cplusplus >= 201103L
243 return const_pointer(_M_local_buf);
249 _M_capacity(size_type __capacity)
250 { _M_allocated_capacity = __capacity; }
254 _M_set_length(size_type __n)
257 traits_type::assign(_M_data()[__n], _CharT());
264 if (_M_data() == _M_local_data())
266 if (_M_string_length > _S_local_capacity)
267 __builtin_unreachable();
276 _M_create(size_type&, size_type);
283 _M_destroy(_M_allocated_capacity);
288 _M_destroy(size_type __size)
throw()
289 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
291#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
294 template<
typename _InIterator>
296 _M_construct_aux(_InIterator __beg, _InIterator __end,
299 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
300 _M_construct(__beg, __end, _Tag());
305 template<
typename _Integer>
307 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
308 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
311 _M_construct_aux_2(size_type __req, _CharT __c)
312 { _M_construct(__req, __c); }
316 template<
typename _InIterator>
319 _M_construct(_InIterator __beg, _InIterator __end,
324 template<
typename _FwdIterator>
327 _M_construct(_FwdIterator __beg, _FwdIterator __end,
332 _M_construct(size_type __req, _CharT __c);
337 {
return _M_dataplus; }
340 const allocator_type&
341 _M_get_allocator()
const
342 {
return _M_dataplus; }
345 __attribute__((__always_inline__))
348 _M_use_local_data() _GLIBCXX_NOEXCEPT
350#if __cpp_lib_is_constant_evaluated
352 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
353 _M_local_buf[__i] = _CharT();
355 return _M_local_data();
360#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
363 template<
typename _Tp,
bool _Requires =
364 !__are_same<_Tp, _CharT*>::__value
365 && !__are_same<_Tp, const _CharT*>::__value
366 && !__are_same<_Tp, iterator>::__value
367 && !__are_same<_Tp, const_iterator>::__value>
368 struct __enable_if_not_native_iterator
369 {
typedef basic_string& __type; };
370 template<
typename _Tp>
371 struct __enable_if_not_native_iterator<_Tp, false> { };
376 _M_check(size_type __pos,
const char* __s)
const
378 if (__pos > this->
size())
379 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
380 "this->size() (which is %zu)"),
381 __s, __pos, this->
size());
387 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
390 __throw_length_error(__N(__s));
397 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
399 const bool __testoff = __off < this->
size() - __pos;
400 return __testoff ? __off : this->
size() - __pos;
405 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
407 return (less<const _CharT*>()(__s, _M_data())
408 || less<const _CharT*>()(_M_data() + this->
size(), __s));
415 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
418 traits_type::assign(*__d, *__s);
420 traits_type::copy(__d, __s, __n);
425 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
428 traits_type::assign(*__d, *__s);
430 traits_type::move(__d, __s, __n);
435 _S_assign(_CharT* __d, size_type __n, _CharT __c)
438 traits_type::assign(*__d, __c);
440 traits_type::assign(__d, __n, __c);
445 template<
class _Iterator>
448 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
450 for (; __k1 != __k2; ++__k1, (void)++__p)
451 traits_type::assign(*__p, *__k1);
456 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
457 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
461 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
463 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
467 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
468 { _S_copy(__p, __k1, __k2 - __k1); }
472 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
474 { _S_copy(__p, __k1, __k2 - __k1); }
478 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
480 const difference_type __d = difference_type(__n1 - __n2);
482 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
483 return __gnu_cxx::__numeric_traits<int>::__max;
484 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
485 return __gnu_cxx::__numeric_traits<int>::__min;
496 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
501 _M_erase(size_type __pos, size_type __n);
513 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
514 : _M_dataplus(_M_local_data())
526 : _M_dataplus(_M_local_data(), __a)
538 : _M_dataplus(_M_local_data(),
539 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
541 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
555 const _Alloc& __a = _Alloc())
556 : _M_dataplus(_M_local_data(), __a)
558 const _CharT* __start = __str._M_data()
559 + __str._M_check(__pos,
"basic_string::basic_string");
560 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
573 : _M_dataplus(_M_local_data())
575 const _CharT* __start = __str._M_data()
576 + __str._M_check(__pos,
"basic_string::basic_string");
577 _M_construct(__start, __start + __str._M_limit(__pos, __n),
590 size_type __n,
const _Alloc& __a)
591 : _M_dataplus(_M_local_data(), __a)
593 const _CharT* __start
594 = __str._M_data() + __str._M_check(__pos,
"string::string");
595 _M_construct(__start, __start + __str._M_limit(__pos, __n),
610 const _Alloc& __a = _Alloc())
611 : _M_dataplus(_M_local_data(), __a)
614 if (__s == 0 && __n > 0)
615 std::__throw_logic_error(__N(
"basic_string: "
616 "construction from null is not valid"));
625#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
628 template<
typename = _RequireAllocator<_Alloc>>
631 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
632 : _M_dataplus(_M_local_data(), __a)
636 std::__throw_logic_error(__N(
"basic_string: "
637 "construction from null is not valid"));
638 const _CharT* __end = __s + traits_type::length(__s);
639 _M_construct(__s, __end, forward_iterator_tag());
648#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
651 template<
typename = _RequireAllocator<_Alloc>>
654 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
655 : _M_dataplus(_M_local_data(), __a)
656 { _M_construct(__n, __c); }
658#if __cplusplus >= 201103L
668 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
670 if (__str._M_is_local())
672 (void)_M_use_local_data();
673 traits_type::copy(_M_local_buf, __str._M_local_buf,
678 _M_data(__str._M_data());
679 _M_capacity(__str._M_allocated_capacity);
685 _M_length(__str.length());
686 __str._M_data(__str._M_use_local_data());
687 __str._M_set_length(0);
696 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
697 : _M_dataplus(_M_local_data(), __a)
702 : _M_dataplus(_M_local_data(), __a)
707 noexcept(_Alloc_traits::_S_always_equal())
708 : _M_dataplus(_M_local_data(), __a)
710 if (__str._M_is_local())
712 (void)_M_use_local_data();
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_use_local_data());
725 __str._M_set_length(0);
732#if __cplusplus >= 202100L
743#if __cplusplus >= 201103L
744 template<
typename _InputIterator,
747 template<
typename _InputIterator>
750 basic_string(_InputIterator __beg, _InputIterator __end,
751 const _Alloc& __a = _Alloc())
752 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
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())
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) { }
804 return this->
assign(__str);
814 {
return this->
assign(__s); }
831#if __cplusplus >= 201103L
844 noexcept(_Alloc_traits::_S_nothrow_move())
846 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
847 || _M_get_allocator() == __str._M_get_allocator();
848 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
852 _M_destroy(_M_allocated_capacity);
853 _M_data(_M_local_data());
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() || __equal_allocs)
874 pointer __data =
nullptr;
875 size_type __capacity;
882 __capacity = _M_allocated_capacity;
885 _M_destroy(_M_allocated_capacity);
888 _M_data(__str._M_data());
889 _M_length(__str.length());
890 _M_capacity(__str._M_allocated_capacity);
893 __str._M_data(__data);
894 __str._M_capacity(__capacity);
897 __str._M_data(__str._M_local_buf);
913 this->
assign(__l.begin(), __l.size());
918#if __cplusplus >= 201703L
923 template<
typename _Tp>
925 _If_sv<_Tp, basic_string&>
927 {
return this->
assign(__svt); }
934 operator __sv_type() const noexcept
935 {
return __sv_type(
data(),
size()); }
943 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
945 begin() _GLIBCXX_NOEXCEPT
946 {
return iterator(_M_data()); }
952 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
954 begin() const _GLIBCXX_NOEXCEPT
955 {
return const_iterator(_M_data()); }
961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
963 end() _GLIBCXX_NOEXCEPT
964 {
return iterator(_M_data() + this->
size()); }
970 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
972 end() const _GLIBCXX_NOEXCEPT
973 {
return const_iterator(_M_data() + this->
size()); }
980 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
982 rbegin() _GLIBCXX_NOEXCEPT
983 {
return reverse_iterator(this->
end()); }
990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
991 const_reverse_iterator
992 rbegin() const _GLIBCXX_NOEXCEPT
993 {
return const_reverse_iterator(this->
end()); }
1000 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1002 rend() _GLIBCXX_NOEXCEPT
1003 {
return reverse_iterator(this->
begin()); }
1010 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1011 const_reverse_iterator
1012 rend() const _GLIBCXX_NOEXCEPT
1013 {
return const_reverse_iterator(this->
begin()); }
1015#if __cplusplus >= 201103L
1020 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1023 {
return const_iterator(this->_M_data()); }
1029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1031 cend() const noexcept
1032 {
return const_iterator(this->_M_data() + this->
size()); }
1039 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1040 const_reverse_iterator
1042 {
return const_reverse_iterator(this->
end()); }
1049 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1050 const_reverse_iterator
1051 crend() const noexcept
1052 {
return const_reverse_iterator(this->
begin()); }
1059 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1061 size() const _GLIBCXX_NOEXCEPT
1062 {
return _M_string_length; }
1066 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1068 length() const _GLIBCXX_NOEXCEPT
1069 {
return _M_string_length; }
1072 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1075 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1087 _GLIBCXX20_CONSTEXPR
1089 resize(size_type __n, _CharT __c);
1101 _GLIBCXX20_CONSTEXPR
1104 { this->
resize(__n, _CharT()); }
1106#if __cplusplus >= 201103L
1107#pragma GCC diagnostic push
1108#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1110 _GLIBCXX20_CONSTEXPR
1114#pragma GCC diagnostic pop
1117#if __cplusplus > 202002L
1118#define __cpp_lib_string_resize_and_overwrite 202110L
1148 template<
typename _Operation>
1150 resize_and_overwrite(size_type __n, _Operation __op);
1157 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1161 return _M_is_local() ? size_type(_S_local_capacity)
1162 : _M_allocated_capacity;
1182 _GLIBCXX20_CONSTEXPR
1189#if __cplusplus > 201703L
1190 [[deprecated(
"use shrink_to_fit() instead")]]
1192 _GLIBCXX20_CONSTEXPR
1199 _GLIBCXX20_CONSTEXPR
1201 clear() _GLIBCXX_NOEXCEPT
1202 { _M_set_length(0); }
1208 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1210 empty() const _GLIBCXX_NOEXCEPT
1211 {
return this->
size() == 0; }
1224 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1226 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1228 __glibcxx_assert(__pos <=
size());
1229 return _M_data()[__pos];
1242 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1248 __glibcxx_assert(__pos <=
size());
1250 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1251 return _M_data()[__pos];
1264 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1266 at(size_type __n)
const
1268 if (__n >= this->
size())
1269 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1270 "(which is %zu) >= this->size() "
1273 return _M_data()[__n];
1286 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1291 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1292 "(which is %zu) >= this->size() "
1295 return _M_data()[__n];
1298#if __cplusplus >= 201103L
1303 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1307 __glibcxx_assert(!
empty());
1315 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1317 front() const noexcept
1319 __glibcxx_assert(!
empty());
1327 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1331 __glibcxx_assert(!
empty());
1339 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1341 back() const noexcept
1343 __glibcxx_assert(!
empty());
1354 _GLIBCXX20_CONSTEXPR
1357 {
return this->
append(__str); }
1364 _GLIBCXX20_CONSTEXPR
1367 {
return this->
append(__s); }
1374 _GLIBCXX20_CONSTEXPR
1382#if __cplusplus >= 201103L
1388 _GLIBCXX20_CONSTEXPR
1391 {
return this->
append(__l.begin(), __l.size()); }
1394#if __cplusplus >= 201703L
1400 template<
typename _Tp>
1401 _GLIBCXX20_CONSTEXPR
1402 _If_sv<_Tp, basic_string&>
1404 {
return this->
append(__svt); }
1412 _GLIBCXX20_CONSTEXPR
1415 {
return this->
append(__str._M_data(), __str.size()); }
1430 _GLIBCXX20_CONSTEXPR
1433 {
return this->
append(__str._M_data()
1434 + __str._M_check(__pos,
"basic_string::append"),
1435 __str._M_limit(__pos, __n)); }
1443 _GLIBCXX20_CONSTEXPR
1445 append(
const _CharT* __s, size_type __n)
1447 __glibcxx_requires_string_len(__s, __n);
1448 _M_check_length(size_type(0), __n,
"basic_string::append");
1449 return _M_append(__s, __n);
1457 _GLIBCXX20_CONSTEXPR
1459 append(
const _CharT* __s)
1461 __glibcxx_requires_string(__s);
1462 const size_type __n = traits_type::length(__s);
1463 _M_check_length(size_type(0), __n,
"basic_string::append");
1464 return _M_append(__s, __n);
1475 _GLIBCXX20_CONSTEXPR
1477 append(size_type __n, _CharT __c)
1478 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1480#if __cplusplus >= 201103L
1486 _GLIBCXX20_CONSTEXPR
1488 append(initializer_list<_CharT> __l)
1489 {
return this->
append(__l.begin(), __l.size()); }
1500#if __cplusplus >= 201103L
1501 template<
class _InputIterator,
1503 _GLIBCXX20_CONSTEXPR
1505 template<
class _InputIterator>
1508 append(_InputIterator __first, _InputIterator __last)
1511#if __cplusplus >= 201703L
1517 template<
typename _Tp>
1518 _GLIBCXX20_CONSTEXPR
1519 _If_sv<_Tp, basic_string&>
1522 __sv_type __sv = __svt;
1523 return this->
append(__sv.data(), __sv.size());
1533 template<
typename _Tp>
1534 _GLIBCXX20_CONSTEXPR
1535 _If_sv<_Tp, basic_string&>
1536 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1538 __sv_type __sv = __svt;
1539 return _M_append(__sv.data()
1540 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1541 std::__sv_limit(__sv.size(), __pos, __n));
1549 _GLIBCXX20_CONSTEXPR
1553 const size_type __size = this->
size();
1555 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1556 traits_type::assign(this->_M_data()[__size], __c);
1557 this->_M_set_length(__size + 1);
1565 _GLIBCXX20_CONSTEXPR
1569#if __cplusplus >= 201103L
1570 if (_Alloc_traits::_S_propagate_on_copy_assign())
1572 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1573 && _M_get_allocator() != __str._M_get_allocator())
1577 if (__str.size() <= _S_local_capacity)
1579 _M_destroy(_M_allocated_capacity);
1580 _M_data(_M_use_local_data());
1585 const auto __len = __str.size();
1586 auto __alloc = __str._M_get_allocator();
1588 auto __ptr = _S_allocate(__alloc, __len + 1);
1589 _M_destroy(_M_allocated_capacity);
1592 _M_set_length(__len);
1598 this->_M_assign(__str);
1602#if __cplusplus >= 201103L
1611 _GLIBCXX20_CONSTEXPR
1614 noexcept(_Alloc_traits::_S_nothrow_move())
1635 _GLIBCXX20_CONSTEXPR
1638 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1639 + __str._M_check(__pos,
"basic_string::assign"),
1640 __str._M_limit(__pos, __n)); }
1652 _GLIBCXX20_CONSTEXPR
1654 assign(
const _CharT* __s, size_type __n)
1656 __glibcxx_requires_string_len(__s, __n);
1657 return _M_replace(size_type(0), this->
size(), __s, __n);
1669 _GLIBCXX20_CONSTEXPR
1671 assign(
const _CharT* __s)
1673 __glibcxx_requires_string(__s);
1674 return _M_replace(size_type(0), this->
size(), __s,
1675 traits_type::length(__s));
1687 _GLIBCXX20_CONSTEXPR
1689 assign(size_type __n, _CharT __c)
1690 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1700#if __cplusplus >= 201103L
1701 template<
class _InputIterator,
1703 _GLIBCXX20_CONSTEXPR
1705 template<
class _InputIterator>
1708 assign(_InputIterator __first, _InputIterator __last)
1711#if __cplusplus >= 201103L
1717 _GLIBCXX20_CONSTEXPR
1719 assign(initializer_list<_CharT> __l)
1720 {
return this->
assign(__l.begin(), __l.size()); }
1723#if __cplusplus >= 201703L
1729 template<
typename _Tp>
1730 _GLIBCXX20_CONSTEXPR
1731 _If_sv<_Tp, basic_string&>
1734 __sv_type __sv = __svt;
1735 return this->
assign(__sv.data(), __sv.size());
1745 template<
typename _Tp>
1746 _GLIBCXX20_CONSTEXPR
1747 _If_sv<_Tp, basic_string&>
1748 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1750 __sv_type __sv = __svt;
1751 return _M_replace(size_type(0), this->
size(),
1753 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1754 std::__sv_limit(__sv.size(), __pos, __n));
1758#if __cplusplus >= 201103L
1774 _GLIBCXX20_CONSTEXPR
1776 insert(const_iterator __p, size_type __n, _CharT __c)
1778 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1779 const size_type __pos = __p -
begin();
1780 this->
replace(__p, __p, __n, __c);
1781 return iterator(this->_M_data() + __pos);
1798 insert(iterator __p, size_type __n, _CharT __c)
1799 { this->
replace(__p, __p, __n, __c); }
1802#if __cplusplus >= 201103L
1817 template<
class _InputIterator,
1819 _GLIBCXX20_CONSTEXPR
1821 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1823 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1824 const size_type __pos = __p -
begin();
1825 this->
replace(__p, __p, __beg, __end);
1826 return iterator(this->_M_data() + __pos);
1841 template<
class _InputIterator>
1843 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1844 { this->
replace(__p, __p, __beg, __end); }
1847#if __cplusplus >= 201103L
1854 _GLIBCXX20_CONSTEXPR
1856 insert(const_iterator __p, initializer_list<_CharT> __l)
1857 {
return this->
insert(__p, __l.begin(), __l.end()); }
1859#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1862 insert(iterator __p, initializer_list<_CharT> __l)
1864 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1865 this->
insert(__p -
begin(), __l.begin(), __l.size());
1882 _GLIBCXX20_CONSTEXPR
1885 {
return this->
replace(__pos1, size_type(0),
1886 __str._M_data(), __str.size()); }
1906 _GLIBCXX20_CONSTEXPR
1909 size_type __pos2, size_type __n =
npos)
1910 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1911 + __str._M_check(__pos2,
"basic_string::insert"),
1912 __str._M_limit(__pos2, __n)); }
1930 _GLIBCXX20_CONSTEXPR
1932 insert(size_type __pos,
const _CharT* __s, size_type __n)
1933 {
return this->
replace(__pos, size_type(0), __s, __n); }
1950 _GLIBCXX20_CONSTEXPR
1952 insert(size_type __pos,
const _CharT* __s)
1954 __glibcxx_requires_string(__s);
1955 return this->
replace(__pos, size_type(0), __s,
1956 traits_type::length(__s));
1975 _GLIBCXX20_CONSTEXPR
1977 insert(size_type __pos, size_type __n, _CharT __c)
1978 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1979 size_type(0), __n, __c); }
1994 _GLIBCXX20_CONSTEXPR
1996 insert(__const_iterator __p, _CharT __c)
1998 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1999 const size_type __pos = __p -
begin();
2000 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2001 return iterator(_M_data() + __pos);
2004#if __cplusplus >= 201703L
2011 template<
typename _Tp>
2012 _GLIBCXX20_CONSTEXPR
2013 _If_sv<_Tp, basic_string&>
2014 insert(size_type __pos,
const _Tp& __svt)
2016 __sv_type __sv = __svt;
2017 return this->
insert(__pos, __sv.data(), __sv.size());
2028 template<
typename _Tp>
2029 _GLIBCXX20_CONSTEXPR
2030 _If_sv<_Tp, basic_string&>
2031 insert(size_type __pos1,
const _Tp& __svt,
2032 size_type __pos2, size_type __n =
npos)
2034 __sv_type __sv = __svt;
2035 return this->
replace(__pos1, size_type(0),
2037 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2038 std::__sv_limit(__sv.size(), __pos2, __n));
2057 _GLIBCXX20_CONSTEXPR
2059 erase(size_type __pos = 0, size_type __n =
npos)
2061 _M_check(__pos,
"basic_string::erase");
2063 this->_M_set_length(__pos);
2065 this->_M_erase(__pos, _M_limit(__pos, __n));
2077 _GLIBCXX20_CONSTEXPR
2079 erase(__const_iterator __position)
2081 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2082 && __position <
end());
2083 const size_type __pos = __position -
begin();
2084 this->_M_erase(__pos, size_type(1));
2085 return iterator(_M_data() + __pos);
2097 _GLIBCXX20_CONSTEXPR
2099 erase(__const_iterator __first, __const_iterator __last)
2101 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2102 && __last <=
end());
2103 const size_type __pos = __first -
begin();
2104 if (__last ==
end())
2105 this->_M_set_length(__pos);
2107 this->_M_erase(__pos, __last - __first);
2108 return iterator(this->_M_data() + __pos);
2111#if __cplusplus >= 201103L
2117 _GLIBCXX20_CONSTEXPR
2121 __glibcxx_assert(!
empty());
2122 _M_erase(
size() - 1, 1);
2143 _GLIBCXX20_CONSTEXPR
2146 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2166 _GLIBCXX20_CONSTEXPR
2169 size_type __pos2, size_type __n2 =
npos)
2170 {
return this->
replace(__pos1, __n1, __str._M_data()
2171 + __str._M_check(__pos2,
"basic_string::replace"),
2172 __str._M_limit(__pos2, __n2)); }
2192 _GLIBCXX20_CONSTEXPR
2194 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2197 __glibcxx_requires_string_len(__s, __n2);
2198 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2199 _M_limit(__pos, __n1), __s, __n2);
2218 _GLIBCXX20_CONSTEXPR
2220 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2222 __glibcxx_requires_string(__s);
2223 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2243 _GLIBCXX20_CONSTEXPR
2245 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2246 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2247 _M_limit(__pos, __n1), __n2, __c); }
2262 _GLIBCXX20_CONSTEXPR
2264 replace(__const_iterator __i1, __const_iterator __i2,
2266 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2283 _GLIBCXX20_CONSTEXPR
2285 replace(__const_iterator __i1, __const_iterator __i2,
2286 const _CharT* __s, size_type __n)
2288 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2290 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2306 _GLIBCXX20_CONSTEXPR
2308 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2310 __glibcxx_requires_string(__s);
2311 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2328 _GLIBCXX20_CONSTEXPR
2330 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2333 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2335 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2353#if __cplusplus >= 201103L
2354 template<
class _InputIterator,
2356 _GLIBCXX20_CONSTEXPR
2358 replace(const_iterator __i1, const_iterator __i2,
2359 _InputIterator __k1, _InputIterator __k2)
2361 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2363 __glibcxx_requires_valid_range(__k1, __k2);
2364 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2365 std::__false_type());
2368 template<
class _InputIterator>
2369#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2370 typename __enable_if_not_native_iterator<_InputIterator>::__type
2374 replace(iterator __i1, iterator __i2,
2375 _InputIterator __k1, _InputIterator __k2)
2377 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2379 __glibcxx_requires_valid_range(__k1, __k2);
2380 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2381 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2387 _GLIBCXX20_CONSTEXPR
2389 replace(__const_iterator __i1, __const_iterator __i2,
2390 _CharT* __k1, _CharT* __k2)
2392 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2394 __glibcxx_requires_valid_range(__k1, __k2);
2399 _GLIBCXX20_CONSTEXPR
2401 replace(__const_iterator __i1, __const_iterator __i2,
2402 const _CharT* __k1,
const _CharT* __k2)
2404 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2406 __glibcxx_requires_valid_range(__k1, __k2);
2411 _GLIBCXX20_CONSTEXPR
2413 replace(__const_iterator __i1, __const_iterator __i2,
2414 iterator __k1, iterator __k2)
2416 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2418 __glibcxx_requires_valid_range(__k1, __k2);
2420 __k1.base(), __k2 - __k1);
2423 _GLIBCXX20_CONSTEXPR
2425 replace(__const_iterator __i1, __const_iterator __i2,
2426 const_iterator __k1, const_iterator __k2)
2428 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2430 __glibcxx_requires_valid_range(__k1, __k2);
2432 __k1.base(), __k2 - __k1);
2435#if __cplusplus >= 201103L
2450 _GLIBCXX20_CONSTEXPR
2452 initializer_list<_CharT> __l)
2453 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2456#if __cplusplus >= 201703L
2464 template<
typename _Tp>
2465 _GLIBCXX20_CONSTEXPR
2466 _If_sv<_Tp, basic_string&>
2467 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2469 __sv_type __sv = __svt;
2470 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2482 template<
typename _Tp>
2483 _GLIBCXX20_CONSTEXPR
2484 _If_sv<_Tp, basic_string&>
2485 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2486 size_type __pos2, size_type __n2 =
npos)
2488 __sv_type __sv = __svt;
2489 return this->
replace(__pos1, __n1,
2491 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2492 std::__sv_limit(__sv.size(), __pos2, __n2));
2504 template<
typename _Tp>
2505 _GLIBCXX20_CONSTEXPR
2506 _If_sv<_Tp, basic_string&>
2507 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2509 __sv_type __sv = __svt;
2510 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2515 template<
class _Integer>
2516 _GLIBCXX20_CONSTEXPR
2518 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2519 _Integer __n, _Integer __val, __true_type)
2520 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2522 template<
class _InputIterator>
2523 _GLIBCXX20_CONSTEXPR
2525 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2526 _InputIterator __k1, _InputIterator __k2,
2529 _GLIBCXX20_CONSTEXPR
2531 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2534 __attribute__((__noinline__, __noclone__, __cold__))
void
2535 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2536 const size_type __len2,
const size_type __how_much);
2538 _GLIBCXX20_CONSTEXPR
2540 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2541 const size_type __len2);
2543 _GLIBCXX20_CONSTEXPR
2545 _M_append(
const _CharT* __s, size_type __n);
2561 _GLIBCXX20_CONSTEXPR
2563 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2572 _GLIBCXX20_CONSTEXPR
2583 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2585 c_str() const _GLIBCXX_NOEXCEPT
2586 {
return _M_data(); }
2596 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2598 data() const _GLIBCXX_NOEXCEPT
2599 {
return _M_data(); }
2601#if __cplusplus >= 201703L
2608 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2611 {
return _M_data(); }
2617 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2620 {
return _M_get_allocator(); }
2634 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2636 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2649 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2653 {
return this->
find(__str.data(), __pos, __str.size()); }
2655#if __cplusplus >= 201703L
2662 template<
typename _Tp>
2663 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2664 _If_sv<_Tp, size_type>
2665 find(
const _Tp& __svt, size_type __pos = 0) const
2666 noexcept(is_same<_Tp, __sv_type>::value)
2668 __sv_type __sv = __svt;
2669 return this->
find(__sv.data(), __pos, __sv.size());
2683 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2685 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2687 __glibcxx_requires_string(__s);
2688 return this->
find(__s, __pos, traits_type::length(__s));
2701 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2703 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2715 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2719 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2721#if __cplusplus >= 201703L
2728 template<
typename _Tp>
2729 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2730 _If_sv<_Tp, size_type>
2731 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2732 noexcept(is_same<_Tp, __sv_type>::value)
2734 __sv_type __sv = __svt;
2735 return this->
rfind(__sv.data(), __pos, __sv.size());
2751 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2753 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2766 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2768 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2770 __glibcxx_requires_string(__s);
2771 return this->
rfind(__s, __pos, traits_type::length(__s));
2784 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2786 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2799 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2803 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2805#if __cplusplus >= 201703L
2813 template<
typename _Tp>
2814 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2815 _If_sv<_Tp, size_type>
2817 noexcept(is_same<_Tp, __sv_type>::value)
2819 __sv_type __sv = __svt;
2820 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2836 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2838 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2851 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2856 __glibcxx_requires_string(__s);
2857 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2872 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2874 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2875 {
return this->
find(__c, __pos); }
2888 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2892 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2894#if __cplusplus >= 201703L
2902 template<
typename _Tp>
2903 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2904 _If_sv<_Tp, size_type>
2906 noexcept(is_same<_Tp, __sv_type>::value)
2908 __sv_type __sv = __svt;
2909 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2925 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2927 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2940 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2945 __glibcxx_requires_string(__s);
2946 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2964 {
return this->
rfind(__c, __pos); }
2976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2982#if __cplusplus >= 201703L
2990 template<
typename _Tp>
2991 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2992 _If_sv<_Tp, size_type>
2994 noexcept(is_same<_Tp, __sv_type>::value)
2996 __sv_type __sv = __svt;
3013 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3016 size_type __n)
const _GLIBCXX_NOEXCEPT;
3028 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3033 __glibcxx_requires_string(__s);
3047 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3063 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3069#if __cplusplus >= 201703L
3077 template<
typename _Tp>
3078 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3079 _If_sv<_Tp, size_type>
3081 noexcept(is_same<_Tp, __sv_type>::value)
3083 __sv_type __sv = __svt;
3100 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3103 size_type __n)
const _GLIBCXX_NOEXCEPT;
3115 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3120 __glibcxx_requires_string(__s);
3134 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3151 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3153 substr(size_type __pos = 0, size_type __n =
npos)
const
3155 _M_check(__pos,
"basic_string::substr"), __n); }
3171 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3175 const size_type __size = this->
size();
3176 const size_type __osize = __str.size();
3177 const size_type __len =
std::min(__size, __osize);
3179 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3181 __r = _S_compare(__size, __osize);
3185#if __cplusplus >= 201703L
3191 template<
typename _Tp>
3192 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3194 compare(
const _Tp& __svt)
const
3195 noexcept(is_same<_Tp, __sv_type>::value)
3197 __sv_type __sv = __svt;
3198 const size_type __size = this->
size();
3199 const size_type __osize = __sv.size();
3200 const size_type __len =
std::min(__size, __osize);
3202 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3204 __r = _S_compare(__size, __osize);
3216 template<
typename _Tp>
3217 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3219 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3220 noexcept(is_same<_Tp, __sv_type>::value)
3222 __sv_type __sv = __svt;
3223 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3236 template<
typename _Tp>
3237 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3239 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3240 size_type __pos2, size_type __n2 =
npos)
const
3241 noexcept(is_same<_Tp, __sv_type>::value)
3243 __sv_type __sv = __svt;
3244 return __sv_type(*
this)
3245 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3268 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3272 _M_check(__pos,
"basic_string::compare");
3273 __n = _M_limit(__pos, __n);
3274 const size_type __osize = __str.size();
3275 const size_type __len =
std::min(__n, __osize);
3276 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3278 __r = _S_compare(__n, __osize);
3305 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3308 size_type __pos2, size_type __n2 =
npos)
const
3310 _M_check(__pos1,
"basic_string::compare");
3311 __str._M_check(__pos2,
"basic_string::compare");
3312 __n1 = _M_limit(__pos1, __n1);
3313 __n2 = __str._M_limit(__pos2, __n2);
3314 const size_type __len =
std::min(__n1, __n2);
3315 int __r = traits_type::compare(_M_data() + __pos1,
3316 __str.data() + __pos2, __len);
3318 __r = _S_compare(__n1, __n2);
3336 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3338 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3340 __glibcxx_requires_string(__s);
3341 const size_type __size = this->
size();
3342 const size_type __osize = traits_type::length(__s);
3343 const size_type __len =
std::min(__size, __osize);
3344 int __r = traits_type::compare(_M_data(), __s, __len);
3346 __r = _S_compare(__size, __osize);
3371 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3373 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3375 __glibcxx_requires_string(__s);
3376 _M_check(__pos,
"basic_string::compare");
3377 __n1 = _M_limit(__pos, __n1);
3378 const size_type __osize = traits_type::length(__s);
3379 const size_type __len =
std::min(__n1, __osize);
3380 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3382 __r = _S_compare(__n1, __osize);
3410 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3412 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3413 size_type __n2)
const
3415 __glibcxx_requires_string_len(__s, __n2);
3416 _M_check(__pos,
"basic_string::compare");
3417 __n1 = _M_limit(__pos, __n1);
3418 const size_type __len =
std::min(__n1, __n2);
3419 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3421 __r = _S_compare(__n1, __n2);
3425#if __cplusplus >= 202002L
3428 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3429 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3433 starts_with(_CharT __x)
const noexcept
3434 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3436 [[nodiscard, __gnu__::__nonnull__]]
3438 starts_with(
const _CharT* __x)
const noexcept
3439 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3443 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3444 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3448 ends_with(_CharT __x)
const noexcept
3449 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3451 [[nodiscard, __gnu__::__nonnull__]]
3453 ends_with(
const _CharT* __x)
const noexcept
3454 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3457#if __cplusplus > 202002L
3460 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3461 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3465 contains(_CharT __x)
const noexcept
3466 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3468 [[nodiscard, __gnu__::__nonnull__]]
3470 contains(
const _CharT* __x)
const noexcept
3471 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3475 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3477_GLIBCXX_END_NAMESPACE_CXX11
3478_GLIBCXX_END_NAMESPACE_VERSION
3482namespace std _GLIBCXX_VISIBILITY(default)
3484_GLIBCXX_BEGIN_NAMESPACE_VERSION
3486#if __cpp_deduction_guides >= 201606
3487_GLIBCXX_BEGIN_NAMESPACE_CXX11
3488 template<
typename _InputIterator,
typename _CharT
3489 =
typename iterator_traits<_InputIterator>::value_type,
3490 typename _Allocator = allocator<_CharT>,
3491 typename = _RequireInputIter<_InputIterator>,
3492 typename = _RequireAllocator<_Allocator>>
3493 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3494 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3498 template<
typename _CharT,
typename _Traits,
3499 typename _Allocator = allocator<_CharT>,
3500 typename = _RequireAllocator<_Allocator>>
3501 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3502 -> basic_string<_CharT, _Traits, _Allocator>;
3504 template<
typename _CharT,
typename _Traits,
3505 typename _Allocator = allocator<_CharT>,
3506 typename = _RequireAllocator<_Allocator>>
3507 basic_string(basic_string_view<_CharT, _Traits>,
3508 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3509 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3510 const _Allocator& = _Allocator())
3511 -> basic_string<_CharT, _Traits, _Allocator>;
3512_GLIBCXX_END_NAMESPACE_CXX11
3515 template<
typename _Str>
3516 _GLIBCXX20_CONSTEXPR
3518 __str_concat(
typename _Str::value_type
const* __lhs,
3519 typename _Str::size_type __lhs_len,
3520 typename _Str::value_type
const* __rhs,
3521 typename _Str::size_type __rhs_len,
3522 typename _Str::allocator_type
const& __a)
3524 typedef typename _Str::allocator_type allocator_type;
3526 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3527 __str.reserve(__lhs_len + __rhs_len);
3528 __str.append(__lhs, __lhs_len);
3529 __str.append(__rhs, __rhs_len);
3540 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3541 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3542 inline basic_string<_CharT, _Traits, _Alloc>
3549 __lhs.get_allocator());
3558 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3559 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3560 inline basic_string<_CharT,_Traits,_Alloc>
3564 __glibcxx_requires_string(
__lhs);
3568 __rhs.get_allocator());
3577 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3578 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3579 inline basic_string<_CharT,_Traits,_Alloc>
3585 __rhs.get_allocator());
3594 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3595 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3596 inline basic_string<_CharT, _Traits, _Alloc>
3598 const _CharT*
__rhs)
3600 __glibcxx_requires_string(
__rhs);
3604 __lhs.get_allocator());
3612 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3613 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3614 inline basic_string<_CharT, _Traits, _Alloc>
3620 __lhs.get_allocator());
3623#if __cplusplus >= 201103L
3624 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3625 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3626 inline basic_string<_CharT, _Traits, _Alloc>
3627 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3628 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3629 {
return std::move(__lhs.append(__rhs)); }
3631 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3632 _GLIBCXX20_CONSTEXPR
3633 inline basic_string<_CharT, _Traits, _Alloc>
3634 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3635 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3636 {
return std::move(__rhs.insert(0, __lhs)); }
3638 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3639 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3640 inline basic_string<_CharT, _Traits, _Alloc>
3641 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3642 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3644#if _GLIBCXX_USE_CXX11_ABI
3645 using _Alloc_traits = allocator_traits<_Alloc>;
3646 bool __use_rhs =
false;
3647 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3649 else if (__lhs.get_allocator() == __rhs.get_allocator())
3654 const auto __size = __lhs.size() + __rhs.size();
3655 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3656 return std::move(__rhs.insert(0, __lhs));
3661 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3662 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3663 inline basic_string<_CharT, _Traits, _Alloc>
3665 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3666 {
return std::move(__rhs.insert(0, __lhs)); }
3668 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3669 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3670 inline basic_string<_CharT, _Traits, _Alloc>
3672 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3673 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3675 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3676 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3677 inline basic_string<_CharT, _Traits, _Alloc>
3678 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3679 const _CharT* __rhs)
3680 {
return std::move(__lhs.append(__rhs)); }
3682 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3683 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3684 inline basic_string<_CharT, _Traits, _Alloc>
3685 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3687 {
return std::move(__lhs.append(1, __rhs)); }
3697 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3698 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3714 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3715 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3718 const _CharT*
__rhs)
3720 return __lhs.size() == _Traits::length(
__rhs)
3724#if __cpp_lib_three_way_comparison
3732 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3735 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3736 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
3737 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3738 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3747 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3750 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3751 const _CharT* __rhs)
noexcept
3752 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3753 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3761 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3775 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3789 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3802 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3806 const _CharT*
__rhs)
3816 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3830 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3834 const _CharT*
__rhs)
3843 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3846 operator<(
const _CharT*
__lhs,
3857 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3871 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3875 const _CharT*
__rhs)
3884 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3898 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3912 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3916 const _CharT*
__rhs)
3925 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3928 operator<=(
const _CharT*
__lhs,
3939 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3953 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3957 const _CharT*
__rhs)
3966 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3981 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3982 _GLIBCXX20_CONSTEXPR
4002 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4003 basic_istream<_CharT, _Traits>&
4004 operator>>(basic_istream<_CharT, _Traits>& __is,
4005 basic_string<_CharT, _Traits, _Alloc>& __str);
4008 basic_istream<char>&
4020 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4043 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4044 basic_istream<_CharT, _Traits>&
4045 getline(basic_istream<_CharT, _Traits>& __is,
4046 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4060 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4061 inline basic_istream<_CharT, _Traits>&
4066#if __cplusplus >= 201103L
4068 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4069 inline basic_istream<_CharT, _Traits>&
4075 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4076 inline basic_istream<_CharT, _Traits>&
4083 basic_istream<char>&
4084 getline(basic_istream<char>& __in, basic_string<char>& __str,
4087#ifdef _GLIBCXX_USE_WCHAR_T
4089 basic_istream<wchar_t>&
4090 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4094_GLIBCXX_END_NAMESPACE_VERSION
4097#if __cplusplus >= 201103L
4102namespace std _GLIBCXX_VISIBILITY(default)
4104_GLIBCXX_BEGIN_NAMESPACE_VERSION
4105_GLIBCXX_BEGIN_NAMESPACE_CXX11
4107#if _GLIBCXX_USE_C99_STDLIB
4110 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4111 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4115 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4116 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4119 inline unsigned long
4120 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4121 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4125 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4126 {
return __gnu_cxx::__stoa(&
std::strtoll,
"stoll", __str.c_str(),
4129 inline unsigned long long
4130 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4131 {
return __gnu_cxx::__stoa(&
std::strtoull,
"stoull", __str.c_str(),
4136 stof(
const string& __str,
size_t* __idx = 0)
4137 {
return __gnu_cxx::__stoa(&
std::strtof,
"stof", __str.c_str(), __idx); }
4140 stod(
const string& __str,
size_t* __idx = 0)
4141 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4144 stold(
const string& __str,
size_t* __idx = 0)
4145 {
return __gnu_cxx::__stoa(&
std::strtold,
"stold", __str.c_str(), __idx); }
4152 to_string(
int __val)
4153#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4157 const bool __neg = __val < 0;
4158 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __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 __val)
4168#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 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 __val)
4180#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4184 const bool __neg = __val < 0;
4185 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4186 const auto __len = __detail::__to_chars_len(__uval);
4187 string __str(__neg + __len,
'-');
4188 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4194 to_string(
unsigned long __val)
4195#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4199 string __str(__detail::__to_chars_len(__val),
'\0');
4200 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4206 to_string(
long long __val)
4208 const bool __neg = __val < 0;
4209 const unsigned long long __uval
4210 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4211 const auto __len = __detail::__to_chars_len(__uval);
4212 string __str(__neg + __len,
'-');
4213 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
4219 to_string(
unsigned long long __val)
4221 string __str(__detail::__to_chars_len(__val),
'\0');
4222 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
4226#if _GLIBCXX_USE_C99_STDIO
4231 to_string(
float __val)
4234 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4241 to_string(
double __val)
4244 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4251 to_string(
long double __val)
4254 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4260#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4262 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4263 {
return __gnu_cxx::__stoa<long, int>(&
std::wcstol,
"stoi", __str.c_str(),
4267 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4268 {
return __gnu_cxx::__stoa(&
std::wcstol,
"stol", __str.c_str(),
4271 inline unsigned long
4272 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4273 {
return __gnu_cxx::__stoa(&
std::wcstoul,
"stoul", __str.c_str(),
4277 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4278 {
return __gnu_cxx::__stoa(&
std::wcstoll,
"stoll", __str.c_str(),
4281 inline unsigned long long
4282 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4283 {
return __gnu_cxx::__stoa(&
std::wcstoull,
"stoull", __str.c_str(),
4288 stof(
const wstring& __str,
size_t* __idx = 0)
4289 {
return __gnu_cxx::__stoa(&
std::wcstof,
"stof", __str.c_str(), __idx); }
4292 stod(
const wstring& __str,
size_t* __idx = 0)
4293 {
return __gnu_cxx::__stoa(&
std::wcstod,
"stod", __str.c_str(), __idx); }
4296 stold(
const wstring& __str,
size_t* __idx = 0)
4297 {
return __gnu_cxx::__stoa(&
std::wcstold,
"stold", __str.c_str(), __idx); }
4299#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
4303 to_wstring(
int __val)
4304 {
return __gnu_cxx::__to_xstring<wstring>(&
std::vswprintf, 4 *
sizeof(
int),
4309 to_wstring(
unsigned __val)
4311 4 *
sizeof(
unsigned),
4316 to_wstring(
long __val)
4317 {
return __gnu_cxx::__to_xstring<wstring>(&
std::vswprintf, 4 *
sizeof(
long),
4322 to_wstring(
unsigned long __val)
4324 4 *
sizeof(
unsigned long),
4329 to_wstring(
long long __val)
4331 4 *
sizeof(
long long),
4336 to_wstring(
unsigned long long __val)
4338 4 *
sizeof(
unsigned long long),
4343 to_wstring(
float __val)
4346 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4353 to_wstring(
double __val)
4356 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4363 to_wstring(
long double __val)
4366 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4373_GLIBCXX_END_NAMESPACE_CXX11
4374_GLIBCXX_END_NAMESPACE_VERSION
4379#if __cplusplus >= 201103L
4383namespace std _GLIBCXX_VISIBILITY(default)
4385_GLIBCXX_BEGIN_NAMESPACE_VERSION
4390 template<
typename _CharT,
typename _Alloc,
4391 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4392 struct __str_hash_base
4393 :
public __hash_base<size_t, _StrT>
4397 operator()(
const _StrT& __s)
const noexcept
4398 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4401#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4403 template<
typename _Alloc>
4405 :
public __str_hash_base<char, _Alloc>
4409 template<
typename _Alloc>
4411 :
public __str_hash_base<wchar_t, _Alloc>
4414 template<
typename _Alloc>
4421#ifdef _GLIBCXX_USE_CHAR8_T
4423 template<
typename _Alloc>
4424 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4425 :
public __str_hash_base<char8_t, _Alloc>
4430 template<
typename _Alloc>
4432 :
public __str_hash_base<char16_t, _Alloc>
4436 template<
typename _Alloc>
4438 :
public __str_hash_base<char32_t, _Alloc>
4441#if ! _GLIBCXX_INLINE_VERSION
4447#ifdef _GLIBCXX_USE_CHAR8_T
4448 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4452 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4453 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4458#if __cplusplus >= 201402L
4460#define __cpp_lib_string_udls 201304L
4462 inline namespace literals
4464 inline namespace string_literals
4466#pragma GCC diagnostic push
4467#pragma GCC diagnostic ignored "-Wliteral-suffix"
4469#if __cpp_lib_constexpr_string >= 201907L
4470# define _GLIBCXX_STRING_CONSTEXPR constexpr
4472# define _GLIBCXX_STRING_CONSTEXPR
4475 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4476 inline basic_string<char>
4477 operator""s(
const char* __str,
size_t __len)
4478 {
return basic_string<char>{__str, __len}; }
4480 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4481 inline basic_string<wchar_t>
4482 operator""s(
const wchar_t* __str,
size_t __len)
4483 {
return basic_string<wchar_t>{__str, __len}; }
4485#ifdef _GLIBCXX_USE_CHAR8_T
4486 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4487 inline basic_string<char8_t>
4488 operator""s(
const char8_t* __str,
size_t __len)
4489 {
return basic_string<char8_t>{__str, __len}; }
4492 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4493 inline basic_string<char16_t>
4494 operator""s(
const char16_t* __str,
size_t __len)
4495 {
return basic_string<char16_t>{__str, __len}; }
4497 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4498 inline basic_string<char32_t>
4499 operator""s(
const char32_t* __str,
size_t __len)
4500 {
return basic_string<char32_t>{__str, __len}; }
4502#undef _GLIBCXX_STRING_CONSTEXPR
4503#pragma GCC diagnostic pop
4507#if __cplusplus >= 201703L
4508 namespace __detail::__variant
4510 template<
typename>
struct _Never_valueless_alt;
4514 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4515 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4517 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4518 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4525_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.
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.