34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
38#pragma GCC system_header
44#if __cplusplus >= 201103L
50#ifdef __glibcxx_string_view
54#if __glibcxx_containers_ranges
59#if __cplusplus > 202302L
64#if ! _GLIBCXX_USE_CXX11_ABI
68namespace std _GLIBCXX_VISIBILITY(default)
70_GLIBCXX_BEGIN_NAMESPACE_VERSION
71_GLIBCXX_BEGIN_NAMESPACE_CXX11
93 template<
typename _CharT,
typename _Traits,
typename _Alloc>
96#if __cplusplus >= 202002L
97 static_assert(is_trivially_copyable_v<_CharT>
98 && is_trivially_default_constructible_v<_CharT>
99 && is_standard_layout_v<_CharT>);
100 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
101 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
102 using _Char_alloc_type = _Alloc;
105 rebind<_CharT>::other _Char_alloc_type;
112 typedef _Traits traits_type;
113 typedef typename _Traits::char_type value_type;
114 typedef _Char_alloc_type allocator_type;
115 typedef typename _Alloc_traits::size_type size_type;
116 typedef typename _Alloc_traits::difference_type difference_type;
117 typedef typename _Alloc_traits::reference reference;
118 typedef typename _Alloc_traits::const_reference const_reference;
119 typedef typename _Alloc_traits::pointer pointer;
120 typedef typename _Alloc_traits::const_pointer const_pointer;
121 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
122 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
128 static const size_type
npos =
static_cast<size_type
>(-1);
132#if __cplusplus < 201103L
133 typedef iterator __const_iterator;
135 typedef const_iterator __const_iterator;
139 static _GLIBCXX20_CONSTEXPR pointer
140 _S_allocate(_Char_alloc_type& __a, size_type __n)
143#if __glibcxx_constexpr_string >= 201907L
146 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
147 if (std::__is_constant_evaluated())
149 for (size_type __i = 0; __i < __n; ++__i)
150 std::construct_at(__builtin_addressof(__p[__i]));
155#ifdef __glibcxx_string_view
159 template<
typename _Tp,
typename _Res>
161 __and_<is_convertible<const _Tp&, __sv_type>,
162 __not_<is_convertible<const _Tp*, const basic_string*>>,
163 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
169 _S_to_string_view(__sv_type __svt)
noexcept
178 _GLIBCXX20_CONSTEXPR
explicit
179 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
197 struct _Alloc_hider : allocator_type
199#if __cplusplus < 201103L
200 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
201 : allocator_type(__a), _M_p(__dat) { }
204 _Alloc_hider(pointer __dat,
const _Alloc& __a)
205 : allocator_type(__a), _M_p(__dat) { }
208 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
209 : allocator_type(std::
move(__a)), _M_p(__dat) { }
215 _Alloc_hider _M_dataplus;
216 size_type _M_string_length;
218 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
222 _CharT _M_local_buf[_S_local_capacity + 1];
223 size_type _M_allocated_capacity;
229 { _M_dataplus._M_p = __p; }
233 _M_length(size_type __length)
234 { _M_string_length = __length; }
239 {
return _M_dataplus._M_p; }
245#if __cplusplus >= 201103L
246 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
248 return pointer(_M_local_buf);
254 _M_local_data()
const
256#if __cplusplus >= 201103L
257 return std::pointer_traits<const_pointer>::pointer_to(*_M_local_buf);
259 return const_pointer(_M_local_buf);
265 _M_capacity(size_type __capacity)
266 { _M_allocated_capacity = __capacity; }
270 _M_set_length(size_type __n)
272 traits_type::assign(_M_data()[__n], _CharT());
280 if (_M_data() == _M_local_data())
282 if (_M_string_length > _S_local_capacity)
283 __builtin_unreachable();
292 _M_create(size_type&, size_type);
299 _M_destroy(_M_allocated_capacity);
304 _M_destroy(size_type __size)
throw()
307#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
310 template<
typename _InIterator>
312 _M_construct_aux(_InIterator __beg, _InIterator __end,
315 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
316 _M_construct(__beg, __end, _Tag());
321 template<
typename _Integer>
323 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
324 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
327 _M_construct_aux_2(size_type __req, _CharT __c)
328 { _M_construct(__req, __c); }
332 template<
typename _InIterator>
335 _M_construct(_InIterator __beg, _InIterator __end,
336 std::input_iterator_tag);
340 template<
typename _FwdIterator>
343 _M_construct(_FwdIterator __beg, _FwdIterator __end,
344 std::forward_iterator_tag);
348 _M_construct(size_type __req, _CharT __c);
352 template<
bool _Terminated>
355 _M_construct(
const _CharT *__c, size_type __n);
357#if __cplusplus >= 202302L
359 _M_construct(
basic_string&& __str, size_type __pos, size_type __n);
365 {
return _M_dataplus; }
368 const allocator_type&
369 _M_get_allocator()
const
370 {
return _M_dataplus; }
373 __attribute__((__always_inline__))
376 _M_init_local_buf() _GLIBCXX_NOEXCEPT
378#if __glibcxx_is_constant_evaluated
379 if (std::is_constant_evaluated())
380 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
381 _M_local_buf[__i] = _CharT();
385 __attribute__((__always_inline__))
388 _M_use_local_data() _GLIBCXX_NOEXCEPT
390#if __cpp_lib_is_constant_evaluated
393 return _M_local_data();
398#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
401 template<
typename _Tp,
bool _Requires =
402 !__are_same<_Tp, _CharT*>::__value
403 && !__are_same<_Tp, const _CharT*>::__value
404 && !__are_same<_Tp, iterator>::__value
405 && !__are_same<_Tp, const_iterator>::__value>
406 struct __enable_if_not_native_iterator
407 {
typedef basic_string& __type; };
408 template<
typename _Tp>
409 struct __enable_if_not_native_iterator<_Tp, false> { };
414 _M_check(size_type __pos,
const char* __s)
const
416 if (__pos > this->
size())
417 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
418 "this->size() (which is %zu)"),
419 __s, (
size_t)__pos, (
size_t)this->
size());
425 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
428 __throw_length_error(__N(__s));
435 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
437 const bool __testoff = __off < this->
size() - __pos;
438 return __testoff ? __off : this->
size() - __pos;
443 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
445 return (less<const _CharT*>()(__s, _M_data())
446 || less<const _CharT*>()(_M_data() + this->
size(), __s));
453 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
456 traits_type::assign(*__d, *__s);
458 traits_type::copy(__d, __s, __n);
463 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
466 traits_type::assign(*__d, *__s);
468 traits_type::move(__d, __s, __n);
473 _S_assign(_CharT* __d, size_type __n, _CharT __c)
476 traits_type::assign(*__d, __c);
478 traits_type::assign(__d, __n, __c);
481#pragma GCC diagnostic push
482#pragma GCC diagnostic ignored "-Wc++17-extensions"
485 template<
class _Iterator>
488 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
490#if __cplusplus >= 201103L
491 using _IterBase =
decltype(std::__niter_base(__k1));
492 if constexpr (__or_<is_same<_IterBase, _CharT*>,
493 is_same<_IterBase, const _CharT*>>::value)
494 _S_copy(__p, std::__niter_base(__k1), __k2 - __k1);
495#if __cpp_lib_concepts
496 else if constexpr (
requires {
497 requires contiguous_iterator<_Iterator>;
499 -> convertible_to<const _CharT*>;
502 const auto __d = __k2 - __k1;
509 for (; __k1 != __k2; ++__k1, (void)++__p)
510 traits_type::assign(*__p,
static_cast<_CharT
>(*__k1));
512#pragma GCC diagnostic pop
514#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
516 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
517 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
520 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
521 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
524 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
525 { _S_copy(__p, __k1, __k2 - __k1); }
528 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
529 { _S_copy(__p, __k1, __k2 - __k1); }
532#if __glibcxx_containers_ranges
534 template<
typename _Rg>
535 static constexpr void
536 _S_copy_range(pointer __p, _Rg&& __rg, size_type __n)
538 if constexpr (
requires {
539 requires ranges::contiguous_range<_Rg>;
541 -> convertible_to<const _CharT*>;
546 auto __first = ranges::begin(__rg);
547 const auto __last = ranges::end(__rg);
548 for (; __first != __last; ++__first)
549 traits_type::assign(*__p++,
static_cast<_CharT
>(*__first));
556 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
558 const difference_type __d = difference_type(__n1 - __n2);
560 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
561 return __gnu_cxx::__numeric_traits<int>::__max;
562 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
563 return __gnu_cxx::__numeric_traits<int>::__min;
574 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
579 _M_erase(size_type __pos, size_type __n);
592#if __cpp_concepts && __glibcxx_type_trait_variable_templates
593 requires is_default_constructible_v<_Alloc>
595 : _M_dataplus(_M_local_data())
607 : _M_dataplus(_M_local_data(), __a)
619 : _M_dataplus(_M_local_data(),
620 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
622 _M_construct<true>(__str._M_data(), __str.
length());
635 const _Alloc& __a = _Alloc())
636 : _M_dataplus(_M_local_data(), __a)
638 const _CharT* __start = __str._M_data()
639 + __str._M_check(__pos,
"basic_string::basic_string");
640 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
653 : _M_dataplus(_M_local_data())
655 const _CharT* __start = __str._M_data()
656 + __str._M_check(__pos,
"basic_string::basic_string");
657 _M_construct(__start, __start + __str._M_limit(__pos, __n),
670 size_type __n,
const _Alloc& __a)
671 : _M_dataplus(_M_local_data(), __a)
673 const _CharT* __start
674 = __str._M_data() + __str._M_check(__pos,
"string::string");
675 _M_construct(__start, __start + __str._M_limit(__pos, __n),
679#if __cplusplus >= 202302L
682 const _Alloc& __a = _Alloc())
683 : _M_dataplus(_M_local_data(), __a)
685 __pos = __str._M_check(__pos,
"string::string");
691 const _Alloc& __a = _Alloc())
692 : _M_dataplus(_M_local_data(), __a)
694 __pos = __str._M_check(__pos,
"string::string");
695 _M_construct(
std::move(__str), __pos, __str._M_limit(__pos, __n));
710 const _Alloc& __a = _Alloc())
711 : _M_dataplus(_M_local_data(), __a)
714 if (__s == 0 && __n > 0)
715 std::__throw_logic_error(__N(
"basic_string: "
716 "construction from null is not valid"));
725#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
728 template<
typename = _RequireAllocator<_Alloc>>
732 : _M_dataplus(_M_local_data(), __a)
736 std::__throw_logic_error(__N(
"basic_string: "
737 "construction from null is not valid"));
738 const _CharT* __end = __s + traits_type::length(__s);
748#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
751 template<
typename = _RequireAllocator<_Alloc>>
755 : _M_dataplus(_M_local_data(), __a)
756 { _M_construct(__n, __c); }
758#if __cplusplus >= 201103L
768 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
770 if (__str._M_is_local())
773 traits_type::copy(_M_local_buf, __str._M_local_buf,
778 _M_data(__str._M_data());
779 _M_capacity(__str._M_allocated_capacity);
785 _M_length(__str.
length());
786 __str._M_data(__str._M_use_local_data());
787 __str._M_set_length(0);
790#if __glibcxx_containers_ranges
795 template<__detail::__container_compatible_range<_CharT> _Rg>
797 basic_string(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
802 const auto __n =
static_cast<size_type>(ranges::distance(__rg));
809 auto __first = ranges::begin(__rg);
810 const auto __last = ranges::end(__rg);
811 for (; __first != __last; ++__first)
824 : _M_dataplus(_M_local_data(), __a)
829 : _M_dataplus(_M_local_data(), __a)
834 noexcept(_Alloc_traits::_S_always_equal())
835 : _M_dataplus(_M_local_data(), __a)
837 if (__str._M_is_local())
840 traits_type::copy(_M_local_buf, __str._M_local_buf,
842 _M_length(__str.length());
843 __str._M_set_length(0);
845 else if (_Alloc_traits::_S_always_equal()
848 _M_data(__str._M_data());
849 _M_length(__str.length());
850 _M_capacity(__str._M_allocated_capacity);
851 __str._M_data(__str._M_use_local_data());
852 __str._M_set_length(0);
859#if __cplusplus >= 202100L
870#if __cplusplus >= 201103L
871 template<
typename _InputIterator,
872 typename = std::_RequireInputIter<_InputIterator>>
874 template<
typename _InputIterator>
878 const _Alloc& __a = _Alloc())
879 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
881#if __cplusplus >= 201103L
884 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
885 _M_construct_aux(__beg, __end, _Integral());
889#ifdef __glibcxx_string_view
897 template<
typename _Tp,
901 const _Alloc& __a = _Alloc())
909 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
912 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
913 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
931 return this->
assign(__str);
941 {
return this->
assign(__s); }
958#if __cplusplus >= 201103L
971 noexcept(_Alloc_traits::_S_nothrow_move())
973 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
974 || _M_get_allocator() == __str._M_get_allocator();
975 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
979 _M_destroy(_M_allocated_capacity);
980 _M_data(_M_local_data());
984 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
986 if (__str._M_is_local())
994 this->_S_copy(_M_data(), __str._M_data(), __str.
size());
995 _M_set_length(__str.
size());
998 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
1001 pointer __data =
nullptr;
1002 size_type __capacity;
1009 __capacity = _M_allocated_capacity;
1012 _M_destroy(_M_allocated_capacity);
1015 _M_data(__str._M_data());
1016 _M_length(__str.
length());
1017 _M_capacity(__str._M_allocated_capacity);
1020 __str._M_data(__data);
1021 __str._M_capacity(__capacity);
1024 __str._M_data(__str._M_use_local_data());
1036 _GLIBCXX20_CONSTEXPR
1040 this->
assign(__l.begin(), __l.size());
1045#ifdef __glibcxx_string_view
1050 template<
typename _Tp>
1051 _GLIBCXX20_CONSTEXPR
1052 _If_sv<_Tp, basic_string&>
1054 {
return this->
assign(__svt); }
1060 _GLIBCXX20_CONSTEXPR
1061 operator __sv_type() const noexcept
1062 {
return __sv_type(
data(),
size()); }
1070 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1073 {
return iterator(_M_data()); }
1079 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1082 {
return const_iterator(_M_data()); }
1088 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1091 {
return iterator(_M_data() + this->
size()); }
1097 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1100 {
return const_iterator(_M_data() + this->
size()); }
1107 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1110 {
return reverse_iterator(this->
end()); }
1117 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1118 const_reverse_iterator
1120 {
return const_reverse_iterator(this->
end()); }
1127 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1130 {
return reverse_iterator(this->
begin()); }
1137 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1138 const_reverse_iterator
1140 {
return const_reverse_iterator(this->
begin()); }
1142#if __cplusplus >= 201103L
1147 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1150 {
return const_iterator(this->_M_data()); }
1156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1159 {
return const_iterator(this->_M_data() + this->
size()); }
1166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1167 const_reverse_iterator
1169 {
return const_reverse_iterator(this->
end()); }
1176 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1177 const_reverse_iterator
1179 {
return const_reverse_iterator(this->
begin()); }
1186 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1190 size_type __sz = _M_string_length;
1192 __builtin_unreachable();
1198 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1204 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1208 const size_t __diffmax
1209 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1211 return (
std::min)(__diffmax, __allocmax) - 1;
1224 _GLIBCXX20_CONSTEXPR
1238 _GLIBCXX20_CONSTEXPR
1241 { this->
resize(__n, _CharT()); }
1243#if __cplusplus >= 201103L
1244#pragma GCC diagnostic push
1245#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1247 _GLIBCXX20_CONSTEXPR
1251#pragma GCC diagnostic pop
1254#ifdef __glibcxx_string_resize_and_overwrite
1284 template<
typename _Operation>
1286 resize_and_overwrite(
size_type __n, _Operation __op);
1289#if __cplusplus >= 201103L
1291 template<
typename _Operation>
1292 _GLIBCXX20_CONSTEXPR
void
1300 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1304 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1305 : _M_allocated_capacity;
1306 if (__sz < _S_local_capacity || __sz >
max_size ())
1307 __builtin_unreachable();
1328 _GLIBCXX20_CONSTEXPR
1335#if __cplusplus > 201703L
1336 [[deprecated(
"use shrink_to_fit() instead")]]
1338 _GLIBCXX20_CONSTEXPR
1345 _GLIBCXX20_CONSTEXPR
1348 { _M_set_length(0); }
1354 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1357 {
return _M_string_length == 0; }
1370 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1374 __glibcxx_assert(__pos <=
size());
1375 return _M_data()[__pos];
1388 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1394 __glibcxx_assert(__pos <=
size());
1396 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1397 return _M_data()[__pos];
1410 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1414 if (__n >= this->
size())
1415 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1416 "(which is %zu) >= this->size() "
1419 return _M_data()[__n];
1432 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1437 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1438 "(which is %zu) >= this->size() "
1441 return _M_data()[__n];
1444#if __cplusplus >= 201103L
1449 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1453 __glibcxx_assert(!
empty());
1461 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1465 __glibcxx_assert(!
empty());
1473 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1477 __glibcxx_assert(!
empty());
1485 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1489 __glibcxx_assert(!
empty());
1500 _GLIBCXX20_CONSTEXPR
1503 {
return this->
append(__str); }
1510 _GLIBCXX20_CONSTEXPR
1513 {
return this->
append(__s); }
1520 _GLIBCXX20_CONSTEXPR
1528#if __cplusplus >= 201103L
1534 _GLIBCXX20_CONSTEXPR
1537 {
return this->
append(__l.begin(), __l.size()); }
1540#ifdef __glibcxx_string_view
1546 template<
typename _Tp>
1547 _GLIBCXX20_CONSTEXPR
1548 _If_sv<_Tp, basic_string&>
1550 {
return this->
append(__svt); }
1558 _GLIBCXX20_CONSTEXPR
1561 {
return this->
append(__str._M_data(), __str.
size()); }
1576 _GLIBCXX20_CONSTEXPR
1579 {
return this->
append(__str._M_data()
1580 + __str._M_check(__pos,
"basic_string::append"),
1581 __str._M_limit(__pos, __n)); }
1589 _GLIBCXX20_CONSTEXPR
1593 __glibcxx_requires_string_len(__s, __n);
1594 _M_check_length(size_type(0), __n,
"basic_string::append");
1595 return _M_append(__s, __n);
1603 _GLIBCXX20_CONSTEXPR
1607 __glibcxx_requires_string(__s);
1608 const size_type __n = traits_type::length(__s);
1609 _M_check_length(size_type(0), __n,
"basic_string::append");
1610 return _M_append(__s, __n);
1621 _GLIBCXX20_CONSTEXPR
1624 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1626#if __glibcxx_containers_ranges
1634 template<__detail::__container_compatible_range<_CharT> _Rg>
1636 append_range(_Rg&& __rg)
1643 const auto __len =
size_type(ranges::distance(__rg));
1653 _M_check_length(0, __len,
"basic_string::append_range");
1655 __s.reserve(__newlen);
1658 _S_copy(__s._M_data(), _M_data(),
size());
1660 _M_destroy(_M_allocated_capacity);
1661 _M_data(__s._M_data());
1662 _M_capacity(__s._M_allocated_capacity);
1663 __s._M_data(__s._M_local_data());
1666 _M_set_length(__newlen);
1671 _M_get_allocator());
1678#if __cplusplus >= 201103L
1684 _GLIBCXX20_CONSTEXPR
1687 {
return this->
append(__l.begin(), __l.size()); }
1698#if __cplusplus >= 201103L
1699 template<
class _InputIterator,
1700 typename = std::_RequireInputIter<_InputIterator>>
1701 _GLIBCXX20_CONSTEXPR
1703 template<
class _InputIterator>
1706 append(_InputIterator __first, _InputIterator __last)
1709#ifdef __glibcxx_string_view
1715 template<
typename _Tp>
1716 _GLIBCXX20_CONSTEXPR
1717 _If_sv<_Tp, basic_string&>
1720 __sv_type __sv = __svt;
1721 return this->
append(__sv.data(), __sv.size());
1731 template<
typename _Tp>
1732 _GLIBCXX20_CONSTEXPR
1733 _If_sv<_Tp, basic_string&>
1734 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1736 __sv_type __sv = __svt;
1737 return _M_append(__sv.data()
1738 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1739 std::__sv_limit(__sv.size(), __pos, __n));
1747 _GLIBCXX20_CONSTEXPR
1751 const size_type __size = this->
size();
1753 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1754 traits_type::assign(this->_M_data()[__size], __c);
1755 this->_M_set_length(__size + 1);
1763 _GLIBCXX20_CONSTEXPR
1767#if __cplusplus >= 201103L
1768 if (_Alloc_traits::_S_propagate_on_copy_assign())
1770 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1771 && _M_get_allocator() != __str._M_get_allocator())
1775 if (__str.
size() <= _S_local_capacity)
1777 _M_destroy(_M_allocated_capacity);
1778 _M_data(_M_use_local_data());
1783 const auto __len = __str.
size();
1784 auto __alloc = __str._M_get_allocator();
1786 auto __ptr = _S_allocate(__alloc, __len + 1);
1787 _M_destroy(_M_allocated_capacity);
1790 _M_set_length(__len);
1793 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1796 this->_M_assign(__str);
1800#if __cplusplus >= 201103L
1809 _GLIBCXX20_CONSTEXPR
1812 noexcept(_Alloc_traits::_S_nothrow_move())
1833 _GLIBCXX20_CONSTEXPR
1836 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1837 + __str._M_check(__pos,
"basic_string::assign"),
1838 __str._M_limit(__pos, __n)); }
1850 _GLIBCXX20_CONSTEXPR
1854 __glibcxx_requires_string_len(__s, __n);
1855 return _M_replace(size_type(0), this->
size(), __s, __n);
1867 _GLIBCXX20_CONSTEXPR
1871 __glibcxx_requires_string(__s);
1872 return _M_replace(size_type(0), this->
size(), __s,
1873 traits_type::length(__s));
1885 _GLIBCXX20_CONSTEXPR
1888 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1898#if __cplusplus >= 201103L
1899#pragma GCC diagnostic push
1900#pragma GCC diagnostic ignored "-Wc++17-extensions"
1901 template<
class _InputIterator,
1902 typename = std::_RequireInputIter<_InputIterator>>
1903 _GLIBCXX20_CONSTEXPR
1905 assign(_InputIterator __first, _InputIterator __last)
1908 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1909 &&
is_same<
typename _IterTraits::value_type,
1912 __glibcxx_requires_valid_range(__first, __last);
1913 return _M_replace(size_type(0),
size(),
1914 std::__niter_base(__first), __last - __first);
1916#if __cplusplus >= 202002L
1917 else if constexpr (contiguous_iterator<_InputIterator>
1918 && is_same_v<iter_value_t<_InputIterator>,
1921 __glibcxx_requires_valid_range(__first, __last);
1922 return _M_replace(size_type(0),
size(),
1929#pragma GCC diagnostic pop
1931 template<
class _InputIterator>
1933 assign(_InputIterator __first, _InputIterator __last)
1937#if __glibcxx_containers_ranges
1945 template<__detail::__container_compatible_range<_CharT> _Rg>
1947 assign_range(_Rg&& __rg)
1950 _M_get_allocator());
1956#if __cplusplus >= 201103L
1962 _GLIBCXX20_CONSTEXPR
1968 const size_type __n = __l.size();
1974 _S_copy(_M_data(), __l.begin(), __n);
1981#ifdef __glibcxx_string_view
1987 template<
typename _Tp>
1988 _GLIBCXX20_CONSTEXPR
1989 _If_sv<_Tp, basic_string&>
1992 __sv_type __sv = __svt;
1993 return this->
assign(__sv.data(), __sv.size());
2003 template<
typename _Tp>
2004 _GLIBCXX20_CONSTEXPR
2005 _If_sv<_Tp, basic_string&>
2006 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
2008 __sv_type __sv = __svt;
2009 return _M_replace(size_type(0), this->
size(),
2011 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
2012 std::__sv_limit(__sv.size(), __pos, __n));
2016#if __cplusplus >= 201103L
2032 _GLIBCXX20_CONSTEXPR
2034 insert(const_iterator __p, size_type __n, _CharT __c)
2036 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2037 const size_type __pos = __p -
begin();
2038 this->
replace(__p, __p, __n, __c);
2039 return iterator(this->_M_data() + __pos);
2057 { this->
replace(__p, __p, __n, __c); }
2060#if __cplusplus >= 201103L
2075 template<
class _InputIterator,
2076 typename = std::_RequireInputIter<_InputIterator>>
2077 _GLIBCXX20_CONSTEXPR
2079 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
2081 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2082 const size_type __pos = __p -
begin();
2083 this->
replace(__p, __p, __beg, __end);
2084 return iterator(this->_M_data() + __pos);
2099 template<
class _InputIterator>
2102 { this->
replace(__p, __p, __beg, __end); }
2105#if __glibcxx_containers_ranges
2113 template<__detail::__container_compatible_range<_CharT> _Rg>
2115 insert_range(const_iterator __p, _Rg&& __rg)
2117 auto __pos = __p -
cbegin();
2119 if constexpr (ranges::forward_range<_Rg>)
2120 if (ranges::empty(__rg))
2121 return begin() + __pos;
2129 _M_get_allocator());
2132 return begin() + __pos;
2136#if __cplusplus >= 201103L
2143 _GLIBCXX20_CONSTEXPR
2146 {
return this->
insert(__p, __l.begin(), __l.end()); }
2148#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
2153 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2154 this->
insert(__p -
begin(), __l.begin(), __l.size());
2171 _GLIBCXX20_CONSTEXPR
2174 {
return this->
replace(__pos1, size_type(0),
2175 __str._M_data(), __str.
size()); }
2195 _GLIBCXX20_CONSTEXPR
2198 size_type __pos2, size_type __n =
npos)
2199 {
return this->
replace(__pos1, size_type(0), __str._M_data()
2200 + __str._M_check(__pos2,
"basic_string::insert"),
2201 __str._M_limit(__pos2, __n)); }
2219 _GLIBCXX20_CONSTEXPR
2221 insert(size_type __pos,
const _CharT* __s, size_type __n)
2222 {
return this->
replace(__pos, size_type(0), __s, __n); }
2239 _GLIBCXX20_CONSTEXPR
2243 __glibcxx_requires_string(__s);
2244 return this->
replace(__pos, size_type(0), __s,
2245 traits_type::length(__s));
2264 _GLIBCXX20_CONSTEXPR
2266 insert(size_type __pos, size_type __n, _CharT __c)
2267 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2268 size_type(0), __n, __c); }
2283 _GLIBCXX20_CONSTEXPR
2287 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2288 const size_type __pos = __p -
begin();
2289 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2290 return iterator(_M_data() + __pos);
2293#ifdef __glibcxx_string_view
2300 template<
typename _Tp>
2301 _GLIBCXX20_CONSTEXPR
2302 _If_sv<_Tp, basic_string&>
2305 __sv_type __sv = __svt;
2306 return this->
insert(__pos, __sv.data(), __sv.size());
2317 template<
typename _Tp>
2318 _GLIBCXX20_CONSTEXPR
2319 _If_sv<_Tp, basic_string&>
2320 insert(size_type __pos1,
const _Tp& __svt,
2321 size_type __pos2, size_type __n =
npos)
2323 __sv_type __sv = __svt;
2324 return this->
replace(__pos1, size_type(0),
2326 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2327 std::__sv_limit(__sv.size(), __pos2, __n));
2346 _GLIBCXX20_CONSTEXPR
2350 _M_check(__pos,
"basic_string::erase");
2352 this->_M_set_length(__pos);
2354 this->_M_erase(__pos, _M_limit(__pos, __n));
2366 _GLIBCXX20_CONSTEXPR
2370 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2371 && __position <
end());
2372 const size_type __pos = __position -
begin();
2373 this->_M_erase(__pos, size_type(1));
2374 return iterator(_M_data() + __pos);
2386 _GLIBCXX20_CONSTEXPR
2388 erase(__const_iterator __first, __const_iterator __last)
2390 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2391 && __last <=
end());
2392 const size_type __pos = __first -
begin();
2393 if (__last ==
end())
2394 this->_M_set_length(__pos);
2396 this->_M_erase(__pos, __last - __first);
2397 return iterator(this->_M_data() + __pos);
2400#if __cplusplus >= 201103L
2406 _GLIBCXX20_CONSTEXPR
2410 __glibcxx_assert(!
empty());
2411 _M_erase(
size() - 1, 1);
2432 _GLIBCXX20_CONSTEXPR
2435 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
2455 _GLIBCXX20_CONSTEXPR
2458 size_type __pos2, size_type __n2 =
npos)
2459 {
return this->
replace(__pos1, __n1, __str._M_data()
2460 + __str._M_check(__pos2,
"basic_string::replace"),
2461 __str._M_limit(__pos2, __n2)); }
2481 _GLIBCXX20_CONSTEXPR
2483 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2486 __glibcxx_requires_string_len(__s, __n2);
2487 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2488 _M_limit(__pos, __n1), __s, __n2);
2507 _GLIBCXX20_CONSTEXPR
2509 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2511 __glibcxx_requires_string(__s);
2512 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2532 _GLIBCXX20_CONSTEXPR
2534 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2535 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2536 _M_limit(__pos, __n1), __n2, __c); }
2551 _GLIBCXX20_CONSTEXPR
2553 replace(__const_iterator __i1, __const_iterator __i2,
2555 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
2572 _GLIBCXX20_CONSTEXPR
2574 replace(__const_iterator __i1, __const_iterator __i2,
2575 const _CharT* __s, size_type __n)
2577 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2579 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2595 _GLIBCXX20_CONSTEXPR
2597 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2599 __glibcxx_requires_string(__s);
2600 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2617 _GLIBCXX20_CONSTEXPR
2619 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2622 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2624 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2642#if __cplusplus >= 201103L
2643 template<
class _InputIterator,
2644 typename = std::_RequireInputIter<_InputIterator>>
2645 _GLIBCXX20_CONSTEXPR
2648 _InputIterator __k1, _InputIterator __k2)
2650 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2652 __glibcxx_requires_valid_range(__k1, __k2);
2653 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2654 std::__false_type());
2657 template<
class _InputIterator>
2658#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2659 typename __enable_if_not_native_iterator<_InputIterator>::__type
2664 _InputIterator __k1, _InputIterator __k2)
2666 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2668 __glibcxx_requires_valid_range(__k1, __k2);
2669 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2670 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2676 _GLIBCXX20_CONSTEXPR
2678 replace(__const_iterator __i1, __const_iterator __i2,
2679 _CharT* __k1, _CharT* __k2)
2681 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2683 __glibcxx_requires_valid_range(__k1, __k2);
2688 _GLIBCXX20_CONSTEXPR
2690 replace(__const_iterator __i1, __const_iterator __i2,
2691 const _CharT* __k1,
const _CharT* __k2)
2693 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2695 __glibcxx_requires_valid_range(__k1, __k2);
2700 _GLIBCXX20_CONSTEXPR
2702 replace(__const_iterator __i1, __const_iterator __i2,
2703 iterator __k1, iterator __k2)
2705 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2707 __glibcxx_requires_valid_range(__k1, __k2);
2709 __k1.base(), __k2 - __k1);
2712 _GLIBCXX20_CONSTEXPR
2714 replace(__const_iterator __i1, __const_iterator __i2,
2715 const_iterator __k1, const_iterator __k2)
2717 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2719 __glibcxx_requires_valid_range(__k1, __k2);
2721 __k1.base(), __k2 - __k1);
2724#if __glibcxx_containers_ranges
2732 template<__detail::__container_compatible_range<_CharT> _Rg>
2734 replace_with_range(const_iterator __i1, const_iterator __i2, _Rg&& __rg)
2741 _M_get_allocator());
2748#if __cplusplus >= 201103L
2763 _GLIBCXX20_CONSTEXPR
2766 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2769#ifdef __glibcxx_string_view
2777 template<
typename _Tp>
2778 _GLIBCXX20_CONSTEXPR
2779 _If_sv<_Tp, basic_string&>
2782 __sv_type __sv = __svt;
2783 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2795 template<
typename _Tp>
2796 _GLIBCXX20_CONSTEXPR
2797 _If_sv<_Tp, basic_string&>
2798 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2799 size_type __pos2, size_type __n2 =
npos)
2801 __sv_type __sv = __svt;
2802 return this->
replace(__pos1, __n1,
2804 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2805 std::__sv_limit(__sv.size(), __pos2, __n2));
2817 template<
typename _Tp>
2818 _GLIBCXX20_CONSTEXPR
2819 _If_sv<_Tp, basic_string&>
2820 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2822 __sv_type __sv = __svt;
2823 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2828 template<
class _Integer>
2829 _GLIBCXX20_CONSTEXPR
2831 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2832 _Integer __n, _Integer __val, __true_type)
2833 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2835 template<
class _InputIterator>
2836 _GLIBCXX20_CONSTEXPR
2838 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2839 _InputIterator __k1, _InputIterator __k2,
2842 _GLIBCXX20_CONSTEXPR
2844 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2847 __attribute__((__noinline__, __noclone__, __cold__))
void
2848 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2849 const size_type __len2,
const size_type __how_much);
2851 _GLIBCXX20_CONSTEXPR
2853 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2854 const size_type __len2);
2856 _GLIBCXX20_CONSTEXPR
2858 _M_append(
const _CharT* __s, size_type __n);
2874 _GLIBCXX20_CONSTEXPR
2876 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2885 _GLIBCXX20_CONSTEXPR
2896 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2899 {
return _M_data(); }
2909 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2912 {
return _M_data(); }
2914#if __cplusplus >= 201703L
2921 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2924 {
return _M_data(); }
2930 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2933 {
return _M_get_allocator(); }
2947 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2949 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2962 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2966 {
return this->
find(__str.
data(), __pos, __str.
size()); }
2968#ifdef __glibcxx_string_view
2975 template<
typename _Tp>
2976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2977 _If_sv<_Tp, size_type>
2979 noexcept(
is_same<_Tp, __sv_type>::value)
2981 __sv_type __sv = __svt;
2982 return this->
find(__sv.data(), __pos, __sv.size());
2996 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2998 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
3000 __glibcxx_requires_string(__s);
3001 return this->
find(__s, __pos, traits_type::length(__s));
3014 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3016 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
3028 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3032 {
return this->
rfind(__str.data(), __pos, __str.size()); }
3034#ifdef __glibcxx_string_view
3041 template<
typename _Tp>
3042 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3043 _If_sv<_Tp, size_type>
3047 __sv_type __sv = __svt;
3048 return this->
rfind(__sv.data(), __pos, __sv.size());
3064 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3066 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
3079 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3083 __glibcxx_requires_string(__s);
3084 return this->
rfind(__s, __pos, traits_type::length(__s));
3097 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3099 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
3112 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3118#ifdef __glibcxx_string_view
3126 template<
typename _Tp>
3127 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3128 _If_sv<_Tp, size_type>
3130 noexcept(
is_same<_Tp, __sv_type>::value)
3132 __sv_type __sv = __svt;
3133 return this->
find_first_of(__sv.data(), __pos, __sv.size());
3149 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3164 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3169 __glibcxx_requires_string(__s);
3170 return this->
find_first_of(__s, __pos, traits_type::length(__s));
3185 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3188 {
return this->
find(__c, __pos); }
3201 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3207#ifdef __glibcxx_string_view
3215 template<
typename _Tp>
3216 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3217 _If_sv<_Tp, size_type>
3221 __sv_type __sv = __svt;
3222 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3238 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3253 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3258 __glibcxx_requires_string(__s);
3259 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3274 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3277 {
return this->
rfind(__c, __pos); }
3289 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3295#ifdef __glibcxx_string_view
3303 template<
typename _Tp>
3304 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3305 _If_sv<_Tp, size_type>
3307 noexcept(
is_same<_Tp, __sv_type>::value)
3309 __sv_type __sv = __svt;
3326 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3329 size_type __n)
const _GLIBCXX_NOEXCEPT;
3341 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3346 __glibcxx_requires_string(__s);
3360 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3376 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3382#ifdef __glibcxx_string_view
3390 template<
typename _Tp>
3391 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3392 _If_sv<_Tp, size_type>
3396 __sv_type __sv = __svt;
3413 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3416 size_type __n)
const _GLIBCXX_NOEXCEPT;
3428 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3433 __glibcxx_requires_string(__s);
3447 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3464 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3468 _M_check(__pos,
"basic_string::substr"), __n); }
3470#if __cplusplus >= 202302L
3478 substr(size_type __pos, size_type __n) &&
3482#ifdef __glibcxx_string_subview
3496 constexpr basic_string_view<_CharT, _Traits>
3497 subview(size_type __pos = 0, size_type __n =
npos)
const
3498 {
return __sv_type(*this).subview(__pos, __n); }
3515 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3519 const size_type __size = this->
size();
3520 const size_type __osize = __str.
size();
3521 const size_type __len =
std::min(__size, __osize);
3523 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
3525 __r = _S_compare(__size, __osize);
3529#ifdef __glibcxx_string_view
3535 template<
typename _Tp>
3536 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3538 compare(
const _Tp& __svt)
const
3541 __sv_type __sv = __svt;
3543 const size_type __osize = __sv.size();
3546 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3548 __r = _S_compare(__size, __osize);
3560 template<
typename _Tp>
3561 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3563 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3565 __sv_type __sv = __svt;
3566 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3579 template<
typename _Tp>
3580 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3582 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3583 size_type __pos2, size_type __n2 =
npos)
const
3585 __sv_type __sv = __svt;
3586 return __sv_type(*
this)
3587 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3610 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3614 _M_check(__pos,
"basic_string::compare");
3615 __n = _M_limit(__pos, __n);
3616 const size_type __osize = __str.
size();
3617 const size_type __len =
std::min(__n, __osize);
3618 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
3620 __r = _S_compare(__n, __osize);
3647 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3650 size_type __pos2, size_type __n2 =
npos)
const
3652 _M_check(__pos1,
"basic_string::compare");
3653 __str._M_check(__pos2,
"basic_string::compare");
3654 __n1 = _M_limit(__pos1, __n1);
3655 __n2 = __str._M_limit(__pos2, __n2);
3656 const size_type __len =
std::min(__n1, __n2);
3657 int __r = traits_type::compare(_M_data() + __pos1,
3658 __str.
data() + __pos2, __len);
3660 __r = _S_compare(__n1, __n2);
3678 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3680 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3682 __glibcxx_requires_string(__s);
3683 const size_type __size = this->
size();
3684 const size_type __osize = traits_type::length(__s);
3685 const size_type __len =
std::min(__size, __osize);
3686 int __r = traits_type::compare(_M_data(), __s, __len);
3688 __r = _S_compare(__size, __osize);
3713 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3715 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3717 __glibcxx_requires_string(__s);
3718 _M_check(__pos,
"basic_string::compare");
3719 __n1 = _M_limit(__pos, __n1);
3720 const size_type __osize = traits_type::length(__s);
3721 const size_type __len =
std::min(__n1, __osize);
3722 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3724 __r = _S_compare(__n1, __osize);
3752 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3754 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3755 size_type __n2)
const
3757 __glibcxx_requires_string_len(__s, __n2);
3758 _M_check(__pos,
"basic_string::compare");
3759 __n1 = _M_limit(__pos, __n1);
3760 const size_type __len =
std::min(__n1, __n2);
3761 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3763 __r = _S_compare(__n1, __n2);
3767#if __cplusplus >= 202002L
3771 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3775 starts_with(_CharT __x)
const noexcept
3776 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3778 [[nodiscard, __gnu__::__nonnull__]]
3780 starts_with(
const _CharT* __x)
const noexcept
3781 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3785 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3786 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3790 ends_with(_CharT __x)
const noexcept
3791 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3793 [[nodiscard, __gnu__::__nonnull__]]
3795 ends_with(
const _CharT* __x)
const noexcept
3796 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3799#if __cplusplus > 202002L
3802 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3803 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3807 contains(_CharT __x)
const noexcept
3808 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3810 [[nodiscard, __gnu__::__nonnull__]]
3812 contains(
const _CharT* __x)
const noexcept
3813 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3817 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3819_GLIBCXX_END_NAMESPACE_CXX11
3820_GLIBCXX_END_NAMESPACE_VERSION
3824namespace std _GLIBCXX_VISIBILITY(default)
3826_GLIBCXX_BEGIN_NAMESPACE_VERSION
3828#if __cpp_deduction_guides >= 201606
3829_GLIBCXX_BEGIN_NAMESPACE_CXX11
3830 template<
typename _InputIterator,
typename _CharT
3833 typename = _RequireInputIter<_InputIterator>,
3834 typename = _RequireAllocator<_Allocator>>
3835 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3840 template<
typename _CharT,
typename _Traits,
3842 typename = _RequireAllocator<_Allocator>>
3846 template<
typename _CharT,
typename _Traits,
3848 typename = _RequireAllocator<_Allocator>>
3850 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3851 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3852 const _Allocator& = _Allocator())
3855#if __glibcxx_containers_ranges
3858 basic_string(from_range_t, _Rg&&, _Allocator = _Allocator())
3863_GLIBCXX_END_NAMESPACE_CXX11
3866 template<
typename _Str>
3867 _GLIBCXX20_CONSTEXPR
3869 __str_concat(
typename _Str::value_type
const* __lhs,
3870 typename _Str::size_type __lhs_len,
3871 typename _Str::value_type
const* __rhs,
3872 typename _Str::size_type __rhs_len,
3873 typename _Str::allocator_type
const& __a)
3875 typedef typename _Str::allocator_type allocator_type;
3876 typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
3877 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3878 __str.
reserve(__lhs_len + __rhs_len);
3879 __str.
append(__lhs, __lhs_len);
3880 __str.
append(__rhs, __rhs_len);
3891 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3892 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3898 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3909 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3910 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3911 inline basic_string<_CharT,_Traits,_Alloc>
3915 __glibcxx_requires_string(__lhs);
3917 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3928 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3929 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3930 inline basic_string<_CharT,_Traits,_Alloc>
3934 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3945 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3946 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3947 inline basic_string<_CharT, _Traits, _Alloc>
3949 const _CharT* __rhs)
3951 __glibcxx_requires_string(__rhs);
3953 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3954 __rhs, _Traits::length(__rhs),
3963 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3964 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3965 inline basic_string<_CharT, _Traits, _Alloc>
3969 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3970 __builtin_addressof(__rhs), 1,
3974#if __cplusplus >= 201103L
3975 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3977 inline basic_string<_CharT, _Traits, _Alloc>
3978 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3979 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3980 {
return std::move(__lhs.append(__rhs)); }
3982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3983 _GLIBCXX20_CONSTEXPR
3987 {
return std::move(__rhs.insert(0, __lhs)); }
3989 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3995#pragma GCC diagnostic push
3996#pragma GCC diagnostic ignored "-Wc++17-extensions"
3999 bool __use_rhs =
false;
4002 else if (__lhs.get_allocator() == __rhs.get_allocator())
4006 const auto __size = __lhs.size() + __rhs.size();
4007 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
4008 return std::move(__rhs.insert(0, __lhs));
4011#pragma GCC diagnostic pop
4014 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4015 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4019 {
return std::move(__rhs.insert(0, __lhs)); }
4021 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4022 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4026 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4028 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4032 const _CharT* __rhs)
4033 {
return std::move(__lhs.append(__rhs)); }
4035 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4036 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4040 {
return std::move(__lhs.append(1, __rhs)); }
4043#if __glibcxx_string_view >= 202403L
4045 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4052 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4053 __rhs.data(), __rhs.size(),
4054 __lhs.get_allocator());
4058 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4068 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4075 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4076 __rhs.data(), __rhs.size(),
4077 __rhs.get_allocator());
4081 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4087 return std::move(__rhs.insert(0, __lhs));
4098 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4105 return __lhs.size() == __rhs.size()
4106 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
4115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4116 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4119 const _CharT* __rhs)
4121 return __lhs.
size() == _Traits::length(__rhs)
4122 && !_Traits::compare(__lhs.
data(), __rhs, __lhs.
size());
4125#if __cpp_lib_three_way_comparison
4133 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4138 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4139 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4152 const _CharT* __rhs)
noexcept
4153 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4154 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4162 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4165 operator==(
const _CharT* __lhs,
4166 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4167 {
return __rhs == __lhs; }
4176 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4182 {
return !(__lhs == __rhs); }
4190 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4193 operator!=(
const _CharT* __lhs,
4195 {
return !(__rhs == __lhs); }
4203 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4207 const _CharT* __rhs)
4208 {
return !(__lhs == __rhs); }
4217 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4223 {
return __lhs.compare(__rhs) < 0; }
4231 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4235 const _CharT* __rhs)
4236 {
return __lhs.compare(__rhs) < 0; }
4244 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4247 operator<(
const _CharT* __lhs,
4249 {
return __rhs.compare(__lhs) > 0; }
4258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4264 {
return __lhs.compare(__rhs) > 0; }
4272 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4276 const _CharT* __rhs)
4277 {
return __lhs.compare(__rhs) > 0; }
4285 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4288 operator>(
const _CharT* __lhs,
4290 {
return __rhs.compare(__lhs) < 0; }
4299 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4305 {
return __lhs.compare(__rhs) <= 0; }
4313 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4317 const _CharT* __rhs)
4318 {
return __lhs.compare(__rhs) <= 0; }
4326 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4329 operator<=(
const _CharT* __lhs,
4331 {
return __rhs.compare(__lhs) >= 0; }
4340 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4346 {
return __lhs.compare(__rhs) >= 0; }
4354 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4358 const _CharT* __rhs)
4359 {
return __lhs.compare(__rhs) >= 0; }
4367 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4370 operator>=(
const _CharT* __lhs,
4372 {
return __rhs.compare(__lhs) <= 0; }
4382 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4383 _GLIBCXX20_CONSTEXPR
4387 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4388 { __lhs.swap(__rhs); }
4403 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4404 basic_istream<_CharT, _Traits>&
4405 operator>>(basic_istream<_CharT, _Traits>& __is,
4406 basic_string<_CharT, _Traits, _Alloc>& __str);
4409 basic_istream<char>&
4421 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4428 return __ostream_insert(__os, __str.
data(), __str.
size());
4444 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4445 basic_istream<_CharT, _Traits>&
4446 getline(basic_istream<_CharT, _Traits>& __is,
4447 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4461 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4462 inline basic_istream<_CharT, _Traits>&
4467#if __cplusplus >= 201103L
4469 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4470 inline basic_istream<_CharT, _Traits>&
4476 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4477 inline basic_istream<_CharT, _Traits>&
4484 basic_istream<char>&
4485 getline(basic_istream<char>& __in, basic_string<char>& __str,
4488#ifdef _GLIBCXX_USE_WCHAR_T
4490 basic_istream<wchar_t>&
4491 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4495_GLIBCXX_END_NAMESPACE_VERSION
4498#if __cplusplus >= 201103L
4503namespace std _GLIBCXX_VISIBILITY(default)
4505_GLIBCXX_BEGIN_NAMESPACE_VERSION
4506_GLIBCXX_BEGIN_NAMESPACE_CXX11
4510 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4511 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4515 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4516 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4519 inline unsigned long
4520 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4521 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4524#if _GLIBCXX_USE_C99_STDLIB
4526 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4527 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4530 inline unsigned long long
4531 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4532 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4534#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4536 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4537 {
return std::stol(__str, __idx, __base); }
4539 inline unsigned long long
4540 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4541 {
return std::stoul(__str, __idx, __base); }
4545 stod(
const string& __str,
size_t* __idx = 0)
4546 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4548#if _GLIBCXX_HAVE_STRTOF
4551 stof(
const string& __str,
size_t* __idx = 0)
4552 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4555 stof(
const string& __str,
size_t* __idx = 0)
4557 double __d = std::stod(__str, __idx);
4558 if (__builtin_isfinite(__d) && __d != 0.0)
4560 double __abs_d = __builtin_fabs(__d);
4561 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4564 std::__throw_out_of_range(
"stof");
4571#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4573 stold(
const string& __str,
size_t* __idx = 0)
4574 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4575#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4577 stold(
const string& __str,
size_t* __idx = 0)
4578 {
return std::stod(__str, __idx); }
4586 to_string(
int __val)
4587#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4591 const bool __neg = __val < 0;
4592 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4593 const auto __len = __detail::__to_chars_len(__uval);
4595 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4597 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4605 to_string(
unsigned __val)
4606#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4610 const auto __len = __detail::__to_chars_len(__val);
4612 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4613 __detail::__to_chars_10_impl(__p, __n, __val);
4621 to_string(
long __val)
4622#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4626 const bool __neg = __val < 0;
4627 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4628 const auto __len = __detail::__to_chars_len(__uval);
4630 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4632 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4640 to_string(
unsigned long __val)
4641#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4645 const auto __len = __detail::__to_chars_len(__val);
4647 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4648 __detail::__to_chars_10_impl(__p, __n, __val);
4656 to_string(
long long __val)
4658 const bool __neg = __val < 0;
4659 const unsigned long long __uval
4660 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4661 const auto __len = __detail::__to_chars_len(__uval);
4663 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4665 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4673 to_string(
unsigned long long __val)
4675 const auto __len = __detail::__to_chars_len(__val);
4677 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4678 __detail::__to_chars_10_impl(__p, __n, __val);
4684#if __glibcxx_to_string >= 202306L
4688 to_string(
float __val)
4693 __str.resize_and_overwrite(__len,
4694 [__val, &__len] (
char* __p,
size_t __n) {
4695 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4696 if (__err == errc{}) [[likely]]
4701 }
while (__str.empty());
4707 to_string(
double __val)
4712 __str.resize_and_overwrite(__len,
4713 [__val, &__len] (
char* __p,
size_t __n) {
4714 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4715 if (__err == errc{}) [[likely]]
4720 }
while (__str.empty());
4726 to_string(
long double __val)
4731 __str.resize_and_overwrite(__len,
4732 [__val, &__len] (
char* __p,
size_t __n) {
4733 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4734 if (__err == errc{}) [[likely]]
4739 }
while (__str.empty());
4742#elif _GLIBCXX_USE_C99_STDIO
4743#pragma GCC diagnostic push
4744#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4749 to_string(
float __val)
4752 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4753 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4759 to_string(
double __val)
4762 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4763 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4769 to_string(
long double __val)
4772 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4773 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4776#pragma GCC diagnostic pop
4779#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4781 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4782 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4786 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4787 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4790 inline unsigned long
4791 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4792 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4796 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4797 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4800 inline unsigned long long
4801 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4802 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4807 stof(
const wstring& __str,
size_t* __idx = 0)
4808 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4811 stod(
const wstring& __str,
size_t* __idx = 0)
4812 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4815 stold(
const wstring& __str,
size_t* __idx = 0)
4816 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4819#ifdef _GLIBCXX_USE_WCHAR_T
4820#pragma GCC diagnostic push
4821#pragma GCC diagnostic ignored "-Wc++17-extensions"
4822 _GLIBCXX20_CONSTEXPR
4824 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4828 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4829 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4831 for (
int __i = 0; __i < __len; ++__i)
4832 __wout[__i] = (
wchar_t) __s[__i];
4837 for (
int __i =
'0'; __i <=
'9'; ++__i)
4838 __wc[__i] = L
'0' + __i;
4863 for (
int __i = 0; __i < __len; ++__i)
4864 __wout[__i] = __wc[(
int)__s[__i]];
4868#if __glibcxx_constexpr_string >= 201907L
4872#ifdef __glibcxx_string_view
4873 __to_wstring_numeric(string_view __s)
4875 __to_wstring_numeric(
const string& __s)
4878 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4879 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4880 return wstring(__s.data(), __s.data() + __s.size());
4884 auto __f = __s.data();
4885 __ws.__resize_and_overwrite(__s.size(),
4886 [__f] (
wchar_t* __to,
int __n) {
4887 std::__to_wstring_numeric(__f, __n, __to);
4893#pragma GCC diagnostic pop
4897 to_wstring(
int __val)
4898 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4902 to_wstring(
unsigned __val)
4903 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4907 to_wstring(
long __val)
4908 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4912 to_wstring(
unsigned long __val)
4913 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4917 to_wstring(
long long __val)
4918 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4922 to_wstring(
unsigned long long __val)
4923 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4925#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4928 to_wstring(
float __val)
4929 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4933 to_wstring(
double __val)
4934 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4938 to_wstring(
long double __val)
4939 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4943_GLIBCXX_END_NAMESPACE_CXX11
4944_GLIBCXX_END_NAMESPACE_VERSION
4949#if __cplusplus >= 201103L
4953namespace std _GLIBCXX_VISIBILITY(default)
4955_GLIBCXX_BEGIN_NAMESPACE_VERSION
4960 template<
typename _CharT,
typename _Alloc,
4962 struct __str_hash_base
4963 :
public __hash_base<size_t, _StrT>
4967 operator()(
const _StrT& __s)
const noexcept
4968 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4971#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4973 template<
typename _Alloc>
4975 :
public __str_hash_base<char, _Alloc>
4979 template<
typename _Alloc>
4981 :
public __str_hash_base<wchar_t, _Alloc>
4984 template<
typename _Alloc>
4991#ifdef _GLIBCXX_USE_CHAR8_T
4993 template<
typename _Alloc>
4994 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4995 :
public __str_hash_base<char8_t, _Alloc>
5000 template<
typename _Alloc>
5002 :
public __str_hash_base<char16_t, _Alloc>
5006 template<
typename _Alloc>
5008 :
public __str_hash_base<char32_t, _Alloc>
5011#if ! _GLIBCXX_INLINE_VERSION
5017#ifdef _GLIBCXX_USE_CHAR8_T
5022 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5028#ifdef __glibcxx_string_udls
5031 inline namespace string_literals
5033#pragma GCC diagnostic push
5034#pragma GCC diagnostic ignored "-Wliteral-suffix"
5036#if __glibcxx_constexpr_string >= 201907L
5037# define _GLIBCXX_STRING_CONSTEXPR constexpr
5039# define _GLIBCXX_STRING_CONSTEXPR
5042 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5043 inline basic_string<char>
5044 operator""s(
const char* __str,
size_t __len)
5045 {
return basic_string<char>{__str, __len}; }
5047 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5048 inline basic_string<wchar_t>
5049 operator""s(
const wchar_t* __str,
size_t __len)
5050 {
return basic_string<wchar_t>{__str, __len}; }
5052#ifdef _GLIBCXX_USE_CHAR8_T
5053 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5054 inline basic_string<char8_t>
5055 operator""s(
const char8_t* __str,
size_t __len)
5056 {
return basic_string<char8_t>{__str, __len}; }
5059 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5060 inline basic_string<char16_t>
5061 operator""s(
const char16_t* __str,
size_t __len)
5062 {
return basic_string<char16_t>{__str, __len}; }
5064 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5065 inline basic_string<char32_t>
5066 operator""s(
const char32_t* __str,
size_t __len)
5067 {
return basic_string<char32_t>{__str, __len}; }
5069#undef _GLIBCXX_STRING_CONSTEXPR
5070#pragma GCC diagnostic pop
5075#ifdef __glibcxx_variant
5076 namespace __detail::__variant
5078 template<
typename>
struct _Never_valueless_alt;
5082 template<
typename _Tp,
typename _Traits,
typename _Alloc>
5083 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
5085 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
5086 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
5092_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
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 _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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< char > string
A string of char.
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.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
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.
ISO C++ inline namespace for literal suffixes.
char_type widen(char __c) const
Widens characters.
Template class basic_istream.
Template class basic_ostream.
A non-owning reference to a string.
Primary class template hash.
is_nothrow_default_constructible
The standard allocator, as per C++03 [20.4.1].
Managing sequences of characters and character-like objects.
constexpr const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
constexpr basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
constexpr basic_string(const _Alloc &__a) noexcept
Construct an empty string using allocator a.
constexpr size_type find_first_not_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a different character.
constexpr basic_string & append(const basic_string &__str, size_type __pos, size_type __n=npos)
Append a substring.
constexpr basic_string() noexcept(/*conditional */)
Default constructor creates an empty string.
constexpr reference at(size_type __n)
Provides access to the data contained in the string.
constexpr basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
constexpr size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const basic_string &__str)
Replace range of characters with string.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
constexpr const_iterator begin() const noexcept
constexpr void clear() noexcept
constexpr size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
constexpr basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
constexpr const_reverse_iterator rend() const noexcept
constexpr void reserve(size_type __res_arg)
Attempt to preallocate enough memory for specified number of characters.
constexpr size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
constexpr basic_string & assign(const _CharT *__s, size_type __n)
Set value to a C substring.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
constexpr const _CharT * data() const noexcept
Return const pointer to contents.
constexpr void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
constexpr size_type find_first_not_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a character not in C substring.
constexpr basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
constexpr size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
constexpr int compare(size_type __pos, size_type __n, const basic_string &__str) const
Compare substring to a string.
constexpr int compare(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos) const
Compare substring to a substring.
constexpr size_type rfind(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
constexpr reference back() noexcept
constexpr size_type find_first_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a character of C substring.
constexpr basic_string(const basic_string &__str, size_type __pos, const _Alloc &__a=_Alloc())
Construct string as copy of a substring.
constexpr basic_string(const basic_string &__str, size_type __pos, size_type __n)
Construct string as copy of a substring.
constexpr basic_string & replace(const_iterator __i1, const_iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
constexpr basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
constexpr size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
constexpr size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
constexpr basic_string & operator+=(const _CharT *__s)
Append a C string.
constexpr basic_string & assign(const basic_string &__str)
Set value to contents of another string.
constexpr basic_string(const basic_string &__str)
Construct string with copy of value of __str.
constexpr basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
constexpr basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
constexpr basic_string & append(size_type __n, _CharT __c)
Append multiple characters.
constexpr size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr const_reverse_iterator crbegin() const noexcept
constexpr basic_string(const basic_string &__str, size_type __pos, size_type __n, const _Alloc &__a)
Construct string as copy of a substring.
constexpr size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
constexpr basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2)
Replace characters with value of a C substring.
constexpr basic_string & assign(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Set value to contents of another string.
constexpr basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
constexpr basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
constexpr const_reverse_iterator rbegin() const noexcept
constexpr size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
constexpr const_iterator end() const noexcept
constexpr basic_string & insert(size_type __pos, const _CharT *__s, size_type __n)
Insert a C substring.
constexpr size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
constexpr const_iterator cbegin() const noexcept
constexpr size_type rfind(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a C substring.
constexpr iterator erase(__const_iterator __first, __const_iterator __last)
Remove a range of characters.
constexpr size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
constexpr const_reference at(size_type __n) const
Provides access to the data contained in the string.
constexpr reference operator[](size_type __pos)
Subscript access to the data contained in the string.
constexpr basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
constexpr reverse_iterator rend() noexcept
constexpr void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
constexpr iterator insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
constexpr size_type find_last_not_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a different character.
constexpr basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
constexpr iterator insert(__const_iterator __p, _CharT __c)
Insert one character.
constexpr ~basic_string()
Destroy the string instance.
constexpr basic_string & operator=(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Move assign the value of str to this string.
constexpr void __resize_and_overwrite(size_type __n, _Operation __op)
Non-standard version of resize_and_overwrite for C++11 and above.
constexpr size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
constexpr basic_string & append(const basic_string &__str)
Append a string to this string.
constexpr basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
constexpr const_reference back() const noexcept
constexpr basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
constexpr size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
constexpr reference front() noexcept
constexpr iterator end() noexcept
constexpr basic_string & append(const _CharT *__s)
Append a C string.
constexpr iterator begin() noexcept
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
constexpr size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
constexpr basic_string & replace(__const_iterator __i1, __const_iterator __i2, const _CharT *__s)
Replace range of characters with C string.
constexpr basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
constexpr void push_back(_CharT __c)
Append a single character.
constexpr reverse_iterator rbegin() noexcept
constexpr basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
constexpr void resize(size_type __n)
Resizes the string to the specified number of characters.
constexpr size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
constexpr basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
constexpr basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
constexpr basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
constexpr iterator insert(const_iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
constexpr size_type find_last_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a character of C substring.
constexpr size_type capacity() const noexcept
constexpr basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
constexpr bool empty() const noexcept
constexpr basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
constexpr int compare(const _CharT *__s) const noexcept
Compare to a C string.
static const size_type npos
constexpr basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
constexpr size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr basic_string & replace(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
constexpr iterator erase(__const_iterator __position)
Remove one character.
constexpr allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
constexpr size_type find(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
constexpr basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
constexpr const_reverse_iterator crend() const noexcept
constexpr basic_string & operator+=(_CharT __c)
Append a character.
constexpr basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
constexpr const_reference front() const noexcept
constexpr int compare(const basic_string &__str) const
Compare to a string.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2) const
Compare substring against a character array.
constexpr size_type find_last_not_of(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find last position of a character not in C substring.
constexpr basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
constexpr _CharT * data() noexcept
Return non-const pointer to contents.
constexpr basic_string & append(const _CharT *__s, size_type __n)
Append a C substring.
constexpr size_type max_size() const noexcept
Returns the size() of the largest possible string.
constexpr void swap(basic_string &__s) noexcept
Swap contents with another string.
constexpr basic_string(basic_string &&__str) noexcept
Move construct string.
constexpr const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
constexpr void pop_back() noexcept
Remove the last character.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s) const
Compare substring to a C string.
constexpr basic_string & operator+=(const basic_string &__str)
Append a string to this string.
constexpr iterator insert(const_iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
constexpr const_iterator cend() const noexcept
constexpr basic_string & operator=(_CharT __c)
Set value to string of length 1.
constexpr size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
Basis for explicit traits specializations.
Traits class for iterators.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Char_alloc_type &__a, size_type __n)
static constexpr void deallocate(_Char_alloc_type &__a, pointer __p, size_type __n)
static constexpr size_type max_size(const _Char_alloc_type &__a) noexcept
[range.sized] The sized_range concept.
A range for which ranges::begin returns an input iterator.
A range for which ranges::begin returns a forward iterator.