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 __glibcxx_to_string >= 202306L
63#if ! _GLIBCXX_USE_CXX11_ABI
67namespace std _GLIBCXX_VISIBILITY(default)
69_GLIBCXX_BEGIN_NAMESPACE_VERSION
70_GLIBCXX_BEGIN_NAMESPACE_CXX11
92 template<
typename _CharT,
typename _Traits,
typename _Alloc>
95#if __cplusplus >= 202002L
96 static_assert(is_trivially_copyable_v<_CharT>
97 && is_trivially_default_constructible_v<_CharT>
98 && is_standard_layout_v<_CharT>);
99 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
100 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
101 using _Char_alloc_type = _Alloc;
104 rebind<_CharT>::other _Char_alloc_type;
111 typedef _Traits traits_type;
112 typedef typename _Traits::char_type value_type;
113 typedef _Char_alloc_type allocator_type;
114 typedef typename _Alloc_traits::size_type size_type;
115 typedef typename _Alloc_traits::difference_type difference_type;
116 typedef typename _Alloc_traits::reference reference;
117 typedef typename _Alloc_traits::const_reference const_reference;
118 typedef typename _Alloc_traits::pointer pointer;
119 typedef typename _Alloc_traits::const_pointer const_pointer;
120 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
121 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
127 static const size_type
npos =
static_cast<size_type
>(-1);
131#if __cplusplus < 201103L
132 typedef iterator __const_iterator;
134 typedef const_iterator __const_iterator;
138 static _GLIBCXX20_CONSTEXPR pointer
139 _S_allocate(_Char_alloc_type& __a, size_type __n)
142#if __glibcxx_constexpr_string >= 201907L
145 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
146 if (std::__is_constant_evaluated())
148 for (size_type __i = 0; __i < __n; ++__i)
149 std::construct_at(__builtin_addressof(__p[__i]));
154#ifdef __glibcxx_string_view
158 template<
typename _Tp,
typename _Res>
160 __and_<is_convertible<const _Tp&, __sv_type>,
161 __not_<is_convertible<const _Tp*, const basic_string*>>,
162 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
168 _S_to_string_view(__sv_type __svt)
noexcept
177 _GLIBCXX20_CONSTEXPR
explicit
178 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
196 struct _Alloc_hider : allocator_type
198#if __cplusplus < 201103L
199 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
200 : allocator_type(__a), _M_p(__dat) { }
203 _Alloc_hider(pointer __dat,
const _Alloc& __a)
204 : allocator_type(__a), _M_p(__dat) { }
207 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
208 : allocator_type(std::
move(__a)), _M_p(__dat) { }
214 _Alloc_hider _M_dataplus;
215 size_type _M_string_length;
217 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
221 _CharT _M_local_buf[_S_local_capacity + 1];
222 size_type _M_allocated_capacity;
228 { _M_dataplus._M_p = __p; }
232 _M_length(size_type __length)
233 { _M_string_length = __length; }
238 {
return _M_dataplus._M_p; }
244#if __cplusplus >= 201103L
245 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
247 return pointer(_M_local_buf);
253 _M_local_data()
const
255#if __cplusplus >= 201103L
256 return std::pointer_traits<const_pointer>::pointer_to(*_M_local_buf);
258 return const_pointer(_M_local_buf);
264 _M_capacity(size_type __capacity)
265 { _M_allocated_capacity = __capacity; }
269 _M_set_length(size_type __n)
271 traits_type::assign(_M_data()[__n], _CharT());
279 if (_M_data() == _M_local_data())
281 if (_M_string_length > _S_local_capacity)
282 __builtin_unreachable();
291 _M_create(size_type&, size_type);
298 _M_destroy(_M_allocated_capacity);
303 _M_destroy(size_type __size)
throw()
306#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
309 template<
typename _InIterator>
311 _M_construct_aux(_InIterator __beg, _InIterator __end,
314 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
315 _M_construct(__beg, __end, _Tag());
320 template<
typename _Integer>
322 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
323 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
326 _M_construct_aux_2(size_type __req, _CharT __c)
327 { _M_construct(__req, __c); }
331 template<
typename _InIterator>
334 _M_construct(_InIterator __beg, _InIterator __end,
335 std::input_iterator_tag);
339 template<
typename _FwdIterator>
342 _M_construct(_FwdIterator __beg, _FwdIterator __end,
343 std::forward_iterator_tag);
347 _M_construct(size_type __req, _CharT __c);
351 template<
bool _Terminated>
354 _M_construct(
const _CharT *__c, size_type __n);
356#if __cplusplus >= 202302L
358 _M_construct(
basic_string&& __str, size_type __pos, size_type __n);
364 {
return _M_dataplus; }
367 const allocator_type&
368 _M_get_allocator()
const
369 {
return _M_dataplus; }
372 __attribute__((__always_inline__))
375 _M_init_local_buf() _GLIBCXX_NOEXCEPT
377#if __glibcxx_is_constant_evaluated
378 if (std::is_constant_evaluated())
379 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
380 _M_local_buf[__i] = _CharT();
384 __attribute__((__always_inline__))
387 _M_use_local_data() _GLIBCXX_NOEXCEPT
389#if __cpp_lib_is_constant_evaluated
392 return _M_local_data();
397#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
400 template<
typename _Tp,
bool _Requires =
401 !__are_same<_Tp, _CharT*>::__value
402 && !__are_same<_Tp, const _CharT*>::__value
403 && !__are_same<_Tp, iterator>::__value
404 && !__are_same<_Tp, const_iterator>::__value>
405 struct __enable_if_not_native_iterator
406 {
typedef basic_string& __type; };
407 template<
typename _Tp>
408 struct __enable_if_not_native_iterator<_Tp, false> { };
413 _M_check(size_type __pos,
const char* __s)
const
415 if (__pos > this->
size())
416 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
417 "this->size() (which is %zu)"),
418 __s, (
size_t)__pos, (
size_t)this->
size());
424 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
427 __throw_length_error(__N(__s));
434 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
436 const bool __testoff = __off < this->
size() - __pos;
437 return __testoff ? __off : this->
size() - __pos;
442 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
444 return (less<const _CharT*>()(__s, _M_data())
445 || less<const _CharT*>()(_M_data() + this->
size(), __s));
452 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
455 traits_type::assign(*__d, *__s);
457 traits_type::copy(__d, __s, __n);
462 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
465 traits_type::assign(*__d, *__s);
467 traits_type::move(__d, __s, __n);
472 _S_assign(_CharT* __d, size_type __n, _CharT __c)
475 traits_type::assign(*__d, __c);
477 traits_type::assign(__d, __n, __c);
480#pragma GCC diagnostic push
481#pragma GCC diagnostic ignored "-Wc++17-extensions"
484 template<
class _Iterator>
487 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
489#if __cplusplus >= 201103L
490 using _IterBase =
decltype(std::__niter_base(__k1));
491 if constexpr (__or_<is_same<_IterBase, _CharT*>,
492 is_same<_IterBase, const _CharT*>>::value)
493 _S_copy(__p, std::__niter_base(__k1), __k2 - __k1);
494#if __cpp_lib_concepts
495 else if constexpr (
requires {
496 requires contiguous_iterator<_Iterator>;
498 -> convertible_to<const _CharT*>;
501 const auto __d = __k2 - __k1;
508 for (; __k1 != __k2; ++__k1, (void)++__p)
509 traits_type::assign(*__p,
static_cast<_CharT
>(*__k1));
511#pragma GCC diagnostic pop
513#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
515 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
516 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
519 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
520 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
523 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
524 { _S_copy(__p, __k1, __k2 - __k1); }
527 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
528 { _S_copy(__p, __k1, __k2 - __k1); }
531#if __glibcxx_containers_ranges
533 template<
typename _Rg>
534 static constexpr void
535 _S_copy_range(pointer __p, _Rg&& __rg, size_type __n)
537 if constexpr (
requires {
538 requires ranges::contiguous_range<_Rg>;
540 -> convertible_to<const _CharT*>;
545 auto __first = ranges::begin(__rg);
546 const auto __last = ranges::end(__rg);
547 for (; __first != __last; ++__first)
548 traits_type::assign(*__p++,
static_cast<_CharT
>(*__first));
555 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
557 const difference_type __d = difference_type(__n1 - __n2);
559 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
560 return __gnu_cxx::__numeric_traits<int>::__max;
561 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
562 return __gnu_cxx::__numeric_traits<int>::__min;
573 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
578 _M_erase(size_type __pos, size_type __n);
591#if __cpp_concepts && __glibcxx_type_trait_variable_templates
592 requires is_default_constructible_v<_Alloc>
594 : _M_dataplus(_M_local_data())
606 : _M_dataplus(_M_local_data(), __a)
618 : _M_dataplus(_M_local_data(),
619 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
621 _M_construct<true>(__str._M_data(), __str.
length());
634 const _Alloc& __a = _Alloc())
635 : _M_dataplus(_M_local_data(), __a)
637 const _CharT* __start = __str._M_data()
638 + __str._M_check(__pos,
"basic_string::basic_string");
639 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
652 : _M_dataplus(_M_local_data())
654 const _CharT* __start = __str._M_data()
655 + __str._M_check(__pos,
"basic_string::basic_string");
656 _M_construct(__start, __start + __str._M_limit(__pos, __n),
669 size_type __n,
const _Alloc& __a)
670 : _M_dataplus(_M_local_data(), __a)
672 const _CharT* __start
673 = __str._M_data() + __str._M_check(__pos,
"string::string");
674 _M_construct(__start, __start + __str._M_limit(__pos, __n),
678#if __cplusplus >= 202302L
681 const _Alloc& __a = _Alloc())
682 : _M_dataplus(_M_local_data(), __a)
684 __pos = __str._M_check(__pos,
"string::string");
690 const _Alloc& __a = _Alloc())
691 : _M_dataplus(_M_local_data(), __a)
693 __pos = __str._M_check(__pos,
"string::string");
694 _M_construct(
std::move(__str), __pos, __str._M_limit(__pos, __n));
709 const _Alloc& __a = _Alloc())
710 : _M_dataplus(_M_local_data(), __a)
713 if (__s == 0 && __n > 0)
714 std::__throw_logic_error(__N(
"basic_string: "
715 "construction from null is not valid"));
724#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
727 template<
typename = _RequireAllocator<_Alloc>>
731 : _M_dataplus(_M_local_data(), __a)
735 std::__throw_logic_error(__N(
"basic_string: "
736 "construction from null is not valid"));
737 const _CharT* __end = __s + traits_type::length(__s);
747#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
750 template<
typename = _RequireAllocator<_Alloc>>
754 : _M_dataplus(_M_local_data(), __a)
755 { _M_construct(__n, __c); }
757#if __cplusplus >= 201103L
767 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
769 if (__str._M_is_local())
772 traits_type::copy(_M_local_buf, __str._M_local_buf,
777 _M_data(__str._M_data());
778 _M_capacity(__str._M_allocated_capacity);
784 _M_length(__str.
length());
785 __str._M_data(__str._M_use_local_data());
786 __str._M_set_length(0);
789#if __glibcxx_containers_ranges
794 template<__detail::__container_compatible_range<_CharT> _Rg>
796 basic_string(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
801 const auto __n =
static_cast<size_type>(ranges::distance(__rg));
808 auto __first = ranges::begin(__rg);
809 const auto __last = ranges::end(__rg);
810 for (; __first != __last; ++__first)
823 : _M_dataplus(_M_local_data(), __a)
828 : _M_dataplus(_M_local_data(), __a)
833 noexcept(_Alloc_traits::_S_always_equal())
834 : _M_dataplus(_M_local_data(), __a)
836 if (__str._M_is_local())
839 traits_type::copy(_M_local_buf, __str._M_local_buf,
841 _M_length(__str.length());
842 __str._M_set_length(0);
844 else if (_Alloc_traits::_S_always_equal()
847 _M_data(__str._M_data());
848 _M_length(__str.length());
849 _M_capacity(__str._M_allocated_capacity);
850 __str._M_data(__str._M_use_local_data());
851 __str._M_set_length(0);
858#if __cplusplus >= 202100L
869#if __cplusplus >= 201103L
870 template<
typename _InputIterator,
871 typename = std::_RequireInputIter<_InputIterator>>
873 template<
typename _InputIterator>
877 const _Alloc& __a = _Alloc())
878 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
880#if __cplusplus >= 201103L
883 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
884 _M_construct_aux(__beg, __end, _Integral());
888#ifdef __glibcxx_string_view
896 template<
typename _Tp,
900 const _Alloc& __a = _Alloc())
908 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
911 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
912 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
930 return this->
assign(__str);
940 {
return this->
assign(__s); }
957#if __cplusplus >= 201103L
970 noexcept(_Alloc_traits::_S_nothrow_move())
972 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
973 || _M_get_allocator() == __str._M_get_allocator();
974 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
978 _M_destroy(_M_allocated_capacity);
979 _M_data(_M_local_data());
983 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
985 if (__str._M_is_local())
993 this->_S_copy(_M_data(), __str._M_data(), __str.
size());
994 _M_set_length(__str.
size());
997 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
1000 pointer __data =
nullptr;
1001 size_type __capacity;
1008 __capacity = _M_allocated_capacity;
1011 _M_destroy(_M_allocated_capacity);
1014 _M_data(__str._M_data());
1015 _M_length(__str.
length());
1016 _M_capacity(__str._M_allocated_capacity);
1019 __str._M_data(__data);
1020 __str._M_capacity(__capacity);
1023 __str._M_data(__str._M_use_local_data());
1035 _GLIBCXX20_CONSTEXPR
1039 this->
assign(__l.begin(), __l.size());
1044#ifdef __glibcxx_string_view
1049 template<
typename _Tp>
1050 _GLIBCXX20_CONSTEXPR
1051 _If_sv<_Tp, basic_string&>
1053 {
return this->
assign(__svt); }
1059 _GLIBCXX20_CONSTEXPR
1060 operator __sv_type() const noexcept
1061 {
return __sv_type(
data(),
size()); }
1069 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1072 {
return iterator(_M_data()); }
1078 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1081 {
return const_iterator(_M_data()); }
1087 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1090 {
return iterator(_M_data() + this->
size()); }
1096 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1099 {
return const_iterator(_M_data() + this->
size()); }
1106 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1109 {
return reverse_iterator(this->
end()); }
1116 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1117 const_reverse_iterator
1119 {
return const_reverse_iterator(this->
end()); }
1126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1129 {
return reverse_iterator(this->
begin()); }
1136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1137 const_reverse_iterator
1139 {
return const_reverse_iterator(this->
begin()); }
1141#if __cplusplus >= 201103L
1146 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1149 {
return const_iterator(this->_M_data()); }
1155 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1158 {
return const_iterator(this->_M_data() + this->
size()); }
1165 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1166 const_reverse_iterator
1168 {
return const_reverse_iterator(this->
end()); }
1175 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1176 const_reverse_iterator
1178 {
return const_reverse_iterator(this->
begin()); }
1185 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1189 size_type __sz = _M_string_length;
1191 __builtin_unreachable();
1197 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1203 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1207 const size_t __diffmax
1208 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1210 return (
std::min)(__diffmax, __allocmax) - 1;
1223 _GLIBCXX20_CONSTEXPR
1237 _GLIBCXX20_CONSTEXPR
1240 { this->
resize(__n, _CharT()); }
1242#if __cplusplus >= 201103L
1243#pragma GCC diagnostic push
1244#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1246 _GLIBCXX20_CONSTEXPR
1250#pragma GCC diagnostic pop
1253#ifdef __glibcxx_string_resize_and_overwrite
1283 template<
typename _Operation>
1285 resize_and_overwrite(
size_type __n, _Operation __op);
1288#if __cplusplus >= 201103L
1290 template<
typename _Operation>
1291 _GLIBCXX20_CONSTEXPR
void
1299 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1303 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1304 : _M_allocated_capacity;
1305 if (__sz < _S_local_capacity || __sz >
max_size ())
1306 __builtin_unreachable();
1327 _GLIBCXX20_CONSTEXPR
1334#if __cplusplus > 201703L
1335 [[deprecated(
"use shrink_to_fit() instead")]]
1337 _GLIBCXX20_CONSTEXPR
1344 _GLIBCXX20_CONSTEXPR
1347 { _M_set_length(0); }
1353 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1356 {
return _M_string_length == 0; }
1369 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1373 __glibcxx_assert(__pos <=
size());
1374 return _M_data()[__pos];
1387 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1393 __glibcxx_assert(__pos <=
size());
1395 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1396 return _M_data()[__pos];
1409 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1413 if (__n >= this->
size())
1414 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1415 "(which is %zu) >= this->size() "
1418 return _M_data()[__n];
1431 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1436 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1437 "(which is %zu) >= this->size() "
1440 return _M_data()[__n];
1443#if __cplusplus >= 201103L
1448 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1452 __glibcxx_assert(!
empty());
1460 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1464 __glibcxx_assert(!
empty());
1472 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1476 __glibcxx_assert(!
empty());
1484 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1488 __glibcxx_assert(!
empty());
1499 _GLIBCXX20_CONSTEXPR
1502 {
return this->
append(__str); }
1509 _GLIBCXX20_CONSTEXPR
1512 {
return this->
append(__s); }
1519 _GLIBCXX20_CONSTEXPR
1527#if __cplusplus >= 201103L
1533 _GLIBCXX20_CONSTEXPR
1536 {
return this->
append(__l.begin(), __l.size()); }
1539#ifdef __glibcxx_string_view
1545 template<
typename _Tp>
1546 _GLIBCXX20_CONSTEXPR
1547 _If_sv<_Tp, basic_string&>
1549 {
return this->
append(__svt); }
1557 _GLIBCXX20_CONSTEXPR
1560 {
return this->
append(__str._M_data(), __str.
size()); }
1575 _GLIBCXX20_CONSTEXPR
1578 {
return this->
append(__str._M_data()
1579 + __str._M_check(__pos,
"basic_string::append"),
1580 __str._M_limit(__pos, __n)); }
1588 _GLIBCXX20_CONSTEXPR
1592 __glibcxx_requires_string_len(__s, __n);
1593 _M_check_length(size_type(0), __n,
"basic_string::append");
1594 return _M_append(__s, __n);
1602 _GLIBCXX20_CONSTEXPR
1606 __glibcxx_requires_string(__s);
1607 const size_type __n = traits_type::length(__s);
1608 _M_check_length(size_type(0), __n,
"basic_string::append");
1609 return _M_append(__s, __n);
1620 _GLIBCXX20_CONSTEXPR
1623 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1625#if __glibcxx_containers_ranges
1633 template<__detail::__container_compatible_range<_CharT> _Rg>
1635 append_range(_Rg&& __rg)
1642 const auto __len =
size_type(ranges::distance(__rg));
1652 _M_check_length(0, __len,
"basic_string::append_range");
1654 __s.reserve(__newlen);
1657 _S_copy(__s._M_data(), _M_data(),
size());
1659 _M_destroy(_M_allocated_capacity);
1660 _M_data(__s._M_data());
1661 _M_capacity(__s._M_allocated_capacity);
1662 __s._M_data(__s._M_local_data());
1665 _M_set_length(__newlen);
1670 _M_get_allocator());
1677#if __cplusplus >= 201103L
1683 _GLIBCXX20_CONSTEXPR
1686 {
return this->
append(__l.begin(), __l.size()); }
1697#if __cplusplus >= 201103L
1698 template<
class _InputIterator,
1699 typename = std::_RequireInputIter<_InputIterator>>
1700 _GLIBCXX20_CONSTEXPR
1702 template<
class _InputIterator>
1705 append(_InputIterator __first, _InputIterator __last)
1708#ifdef __glibcxx_string_view
1714 template<
typename _Tp>
1715 _GLIBCXX20_CONSTEXPR
1716 _If_sv<_Tp, basic_string&>
1719 __sv_type __sv = __svt;
1720 return this->
append(__sv.data(), __sv.size());
1730 template<
typename _Tp>
1731 _GLIBCXX20_CONSTEXPR
1732 _If_sv<_Tp, basic_string&>
1733 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1735 __sv_type __sv = __svt;
1736 return _M_append(__sv.data()
1737 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1738 std::__sv_limit(__sv.size(), __pos, __n));
1746 _GLIBCXX20_CONSTEXPR
1750 const size_type __size = this->
size();
1752 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1753 traits_type::assign(this->_M_data()[__size], __c);
1754 this->_M_set_length(__size + 1);
1762 _GLIBCXX20_CONSTEXPR
1766#if __cplusplus >= 201103L
1767 if (_Alloc_traits::_S_propagate_on_copy_assign())
1769 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1770 && _M_get_allocator() != __str._M_get_allocator())
1774 if (__str.
size() <= _S_local_capacity)
1776 _M_destroy(_M_allocated_capacity);
1777 _M_data(_M_use_local_data());
1782 const auto __len = __str.
size();
1783 auto __alloc = __str._M_get_allocator();
1785 auto __ptr = _S_allocate(__alloc, __len + 1);
1786 _M_destroy(_M_allocated_capacity);
1789 _M_set_length(__len);
1792 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1795 this->_M_assign(__str);
1799#if __cplusplus >= 201103L
1808 _GLIBCXX20_CONSTEXPR
1811 noexcept(_Alloc_traits::_S_nothrow_move())
1832 _GLIBCXX20_CONSTEXPR
1835 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1836 + __str._M_check(__pos,
"basic_string::assign"),
1837 __str._M_limit(__pos, __n)); }
1849 _GLIBCXX20_CONSTEXPR
1853 __glibcxx_requires_string_len(__s, __n);
1854 return _M_replace(size_type(0), this->
size(), __s, __n);
1866 _GLIBCXX20_CONSTEXPR
1870 __glibcxx_requires_string(__s);
1871 return _M_replace(size_type(0), this->
size(), __s,
1872 traits_type::length(__s));
1884 _GLIBCXX20_CONSTEXPR
1887 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1897#if __cplusplus >= 201103L
1898#pragma GCC diagnostic push
1899#pragma GCC diagnostic ignored "-Wc++17-extensions"
1900 template<
class _InputIterator,
1901 typename = std::_RequireInputIter<_InputIterator>>
1902 _GLIBCXX20_CONSTEXPR
1904 assign(_InputIterator __first, _InputIterator __last)
1907 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1908 &&
is_same<
typename _IterTraits::value_type,
1911 __glibcxx_requires_valid_range(__first, __last);
1912 return _M_replace(size_type(0),
size(),
1913 std::__niter_base(__first), __last - __first);
1915#if __cplusplus >= 202002L
1916 else if constexpr (contiguous_iterator<_InputIterator>
1917 && is_same_v<iter_value_t<_InputIterator>,
1920 __glibcxx_requires_valid_range(__first, __last);
1921 return _M_replace(size_type(0),
size(),
1928#pragma GCC diagnostic pop
1930 template<
class _InputIterator>
1932 assign(_InputIterator __first, _InputIterator __last)
1936#if __glibcxx_containers_ranges
1944 template<__detail::__container_compatible_range<_CharT> _Rg>
1946 assign_range(_Rg&& __rg)
1949 _M_get_allocator());
1955#if __cplusplus >= 201103L
1961 _GLIBCXX20_CONSTEXPR
1967 const size_type __n = __l.size();
1973 _S_copy(_M_data(), __l.begin(), __n);
1980#ifdef __glibcxx_string_view
1986 template<
typename _Tp>
1987 _GLIBCXX20_CONSTEXPR
1988 _If_sv<_Tp, basic_string&>
1991 __sv_type __sv = __svt;
1992 return this->
assign(__sv.data(), __sv.size());
2002 template<
typename _Tp>
2003 _GLIBCXX20_CONSTEXPR
2004 _If_sv<_Tp, basic_string&>
2005 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
2007 __sv_type __sv = __svt;
2008 return _M_replace(size_type(0), this->
size(),
2010 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
2011 std::__sv_limit(__sv.size(), __pos, __n));
2015#if __cplusplus >= 201103L
2031 _GLIBCXX20_CONSTEXPR
2033 insert(const_iterator __p, size_type __n, _CharT __c)
2035 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2036 const size_type __pos = __p -
begin();
2037 this->
replace(__p, __p, __n, __c);
2038 return iterator(this->_M_data() + __pos);
2056 { this->
replace(__p, __p, __n, __c); }
2059#if __cplusplus >= 201103L
2074 template<
class _InputIterator,
2075 typename = std::_RequireInputIter<_InputIterator>>
2076 _GLIBCXX20_CONSTEXPR
2078 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
2080 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2081 const size_type __pos = __p -
begin();
2082 this->
replace(__p, __p, __beg, __end);
2083 return iterator(this->_M_data() + __pos);
2098 template<
class _InputIterator>
2101 { this->
replace(__p, __p, __beg, __end); }
2104#if __glibcxx_containers_ranges
2112 template<__detail::__container_compatible_range<_CharT> _Rg>
2114 insert_range(const_iterator __p, _Rg&& __rg)
2116 auto __pos = __p -
cbegin();
2118 if constexpr (ranges::forward_range<_Rg>)
2119 if (ranges::empty(__rg))
2120 return begin() + __pos;
2128 _M_get_allocator());
2131 return begin() + __pos;
2135#if __cplusplus >= 201103L
2142 _GLIBCXX20_CONSTEXPR
2145 {
return this->
insert(__p, __l.begin(), __l.end()); }
2147#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
2152 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2153 this->
insert(__p -
begin(), __l.begin(), __l.size());
2170 _GLIBCXX20_CONSTEXPR
2173 {
return this->
replace(__pos1, size_type(0),
2174 __str._M_data(), __str.
size()); }
2194 _GLIBCXX20_CONSTEXPR
2197 size_type __pos2, size_type __n =
npos)
2198 {
return this->
replace(__pos1, size_type(0), __str._M_data()
2199 + __str._M_check(__pos2,
"basic_string::insert"),
2200 __str._M_limit(__pos2, __n)); }
2218 _GLIBCXX20_CONSTEXPR
2220 insert(size_type __pos,
const _CharT* __s, size_type __n)
2221 {
return this->
replace(__pos, size_type(0), __s, __n); }
2238 _GLIBCXX20_CONSTEXPR
2242 __glibcxx_requires_string(__s);
2243 return this->
replace(__pos, size_type(0), __s,
2244 traits_type::length(__s));
2263 _GLIBCXX20_CONSTEXPR
2265 insert(size_type __pos, size_type __n, _CharT __c)
2266 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2267 size_type(0), __n, __c); }
2282 _GLIBCXX20_CONSTEXPR
2286 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2287 const size_type __pos = __p -
begin();
2288 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2289 return iterator(_M_data() + __pos);
2292#ifdef __glibcxx_string_view
2299 template<
typename _Tp>
2300 _GLIBCXX20_CONSTEXPR
2301 _If_sv<_Tp, basic_string&>
2304 __sv_type __sv = __svt;
2305 return this->
insert(__pos, __sv.data(), __sv.size());
2316 template<
typename _Tp>
2317 _GLIBCXX20_CONSTEXPR
2318 _If_sv<_Tp, basic_string&>
2319 insert(size_type __pos1,
const _Tp& __svt,
2320 size_type __pos2, size_type __n =
npos)
2322 __sv_type __sv = __svt;
2323 return this->
replace(__pos1, size_type(0),
2325 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2326 std::__sv_limit(__sv.size(), __pos2, __n));
2345 _GLIBCXX20_CONSTEXPR
2349 _M_check(__pos,
"basic_string::erase");
2351 this->_M_set_length(__pos);
2353 this->_M_erase(__pos, _M_limit(__pos, __n));
2365 _GLIBCXX20_CONSTEXPR
2369 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2370 && __position <
end());
2371 const size_type __pos = __position -
begin();
2372 this->_M_erase(__pos, size_type(1));
2373 return iterator(_M_data() + __pos);
2385 _GLIBCXX20_CONSTEXPR
2387 erase(__const_iterator __first, __const_iterator __last)
2389 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2390 && __last <=
end());
2391 const size_type __pos = __first -
begin();
2392 if (__last ==
end())
2393 this->_M_set_length(__pos);
2395 this->_M_erase(__pos, __last - __first);
2396 return iterator(this->_M_data() + __pos);
2399#if __cplusplus >= 201103L
2405 _GLIBCXX20_CONSTEXPR
2409 __glibcxx_assert(!
empty());
2410 _M_erase(
size() - 1, 1);
2431 _GLIBCXX20_CONSTEXPR
2434 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
2454 _GLIBCXX20_CONSTEXPR
2457 size_type __pos2, size_type __n2 =
npos)
2458 {
return this->
replace(__pos1, __n1, __str._M_data()
2459 + __str._M_check(__pos2,
"basic_string::replace"),
2460 __str._M_limit(__pos2, __n2)); }
2480 _GLIBCXX20_CONSTEXPR
2482 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2485 __glibcxx_requires_string_len(__s, __n2);
2486 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2487 _M_limit(__pos, __n1), __s, __n2);
2506 _GLIBCXX20_CONSTEXPR
2508 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2510 __glibcxx_requires_string(__s);
2511 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2531 _GLIBCXX20_CONSTEXPR
2533 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2534 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2535 _M_limit(__pos, __n1), __n2, __c); }
2550 _GLIBCXX20_CONSTEXPR
2552 replace(__const_iterator __i1, __const_iterator __i2,
2554 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
2571 _GLIBCXX20_CONSTEXPR
2573 replace(__const_iterator __i1, __const_iterator __i2,
2574 const _CharT* __s, size_type __n)
2576 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2578 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2594 _GLIBCXX20_CONSTEXPR
2596 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2598 __glibcxx_requires_string(__s);
2599 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2616 _GLIBCXX20_CONSTEXPR
2618 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2621 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2623 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2641#if __cplusplus >= 201103L
2642 template<
class _InputIterator,
2643 typename = std::_RequireInputIter<_InputIterator>>
2644 _GLIBCXX20_CONSTEXPR
2647 _InputIterator __k1, _InputIterator __k2)
2649 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2651 __glibcxx_requires_valid_range(__k1, __k2);
2652 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2653 std::__false_type());
2656 template<
class _InputIterator>
2657#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2658 typename __enable_if_not_native_iterator<_InputIterator>::__type
2663 _InputIterator __k1, _InputIterator __k2)
2665 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2667 __glibcxx_requires_valid_range(__k1, __k2);
2668 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2669 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2675 _GLIBCXX20_CONSTEXPR
2677 replace(__const_iterator __i1, __const_iterator __i2,
2678 _CharT* __k1, _CharT* __k2)
2680 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2682 __glibcxx_requires_valid_range(__k1, __k2);
2687 _GLIBCXX20_CONSTEXPR
2689 replace(__const_iterator __i1, __const_iterator __i2,
2690 const _CharT* __k1,
const _CharT* __k2)
2692 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2694 __glibcxx_requires_valid_range(__k1, __k2);
2699 _GLIBCXX20_CONSTEXPR
2701 replace(__const_iterator __i1, __const_iterator __i2,
2702 iterator __k1, iterator __k2)
2704 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2706 __glibcxx_requires_valid_range(__k1, __k2);
2708 __k1.base(), __k2 - __k1);
2711 _GLIBCXX20_CONSTEXPR
2713 replace(__const_iterator __i1, __const_iterator __i2,
2714 const_iterator __k1, const_iterator __k2)
2716 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2718 __glibcxx_requires_valid_range(__k1, __k2);
2720 __k1.base(), __k2 - __k1);
2723#if __glibcxx_containers_ranges
2731 template<__detail::__container_compatible_range<_CharT> _Rg>
2733 replace_with_range(const_iterator __i1, const_iterator __i2, _Rg&& __rg)
2740 _M_get_allocator());
2747#if __cplusplus >= 201103L
2762 _GLIBCXX20_CONSTEXPR
2765 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2768#ifdef __glibcxx_string_view
2776 template<
typename _Tp>
2777 _GLIBCXX20_CONSTEXPR
2778 _If_sv<_Tp, basic_string&>
2781 __sv_type __sv = __svt;
2782 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2794 template<
typename _Tp>
2795 _GLIBCXX20_CONSTEXPR
2796 _If_sv<_Tp, basic_string&>
2797 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2798 size_type __pos2, size_type __n2 =
npos)
2800 __sv_type __sv = __svt;
2801 return this->
replace(__pos1, __n1,
2803 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2804 std::__sv_limit(__sv.size(), __pos2, __n2));
2816 template<
typename _Tp>
2817 _GLIBCXX20_CONSTEXPR
2818 _If_sv<_Tp, basic_string&>
2819 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2821 __sv_type __sv = __svt;
2822 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2827 template<
class _Integer>
2828 _GLIBCXX20_CONSTEXPR
2830 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2831 _Integer __n, _Integer __val, __true_type)
2832 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2834 template<
class _InputIterator>
2835 _GLIBCXX20_CONSTEXPR
2837 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2838 _InputIterator __k1, _InputIterator __k2,
2841 _GLIBCXX20_CONSTEXPR
2843 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2846 __attribute__((__noinline__, __noclone__, __cold__))
void
2847 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2848 const size_type __len2,
const size_type __how_much);
2850 _GLIBCXX20_CONSTEXPR
2852 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2853 const size_type __len2);
2855 _GLIBCXX20_CONSTEXPR
2857 _M_append(
const _CharT* __s, size_type __n);
2873 _GLIBCXX20_CONSTEXPR
2875 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2884 _GLIBCXX20_CONSTEXPR
2895 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2898 {
return _M_data(); }
2908 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2911 {
return _M_data(); }
2913#if __cplusplus >= 201703L
2920 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2923 {
return _M_data(); }
2929 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2932 {
return _M_get_allocator(); }
2946 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2948 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2965 {
return this->
find(__str.
data(), __pos, __str.
size()); }
2967#ifdef __glibcxx_string_view
2974 template<
typename _Tp>
2975 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2976 _If_sv<_Tp, size_type>
2978 noexcept(
is_same<_Tp, __sv_type>::value)
2980 __sv_type __sv = __svt;
2981 return this->
find(__sv.data(), __pos, __sv.size());
2995 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2997 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2999 __glibcxx_requires_string(__s);
3000 return this->
find(__s, __pos, traits_type::length(__s));
3013 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3015 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
3027 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3031 {
return this->
rfind(__str.data(), __pos, __str.size()); }
3033#ifdef __glibcxx_string_view
3040 template<
typename _Tp>
3041 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3042 _If_sv<_Tp, size_type>
3046 __sv_type __sv = __svt;
3047 return this->
rfind(__sv.data(), __pos, __sv.size());
3063 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3065 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
3078 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3082 __glibcxx_requires_string(__s);
3083 return this->
rfind(__s, __pos, traits_type::length(__s));
3096 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3098 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
3111 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3117#ifdef __glibcxx_string_view
3125 template<
typename _Tp>
3126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3127 _If_sv<_Tp, size_type>
3129 noexcept(
is_same<_Tp, __sv_type>::value)
3131 __sv_type __sv = __svt;
3132 return this->
find_first_of(__sv.data(), __pos, __sv.size());
3148 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3163 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3168 __glibcxx_requires_string(__s);
3169 return this->
find_first_of(__s, __pos, traits_type::length(__s));
3184 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3187 {
return this->
find(__c, __pos); }
3200 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3206#ifdef __glibcxx_string_view
3214 template<
typename _Tp>
3215 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3216 _If_sv<_Tp, size_type>
3220 __sv_type __sv = __svt;
3221 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3237 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3252 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3257 __glibcxx_requires_string(__s);
3258 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3273 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3276 {
return this->
rfind(__c, __pos); }
3288 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3294#ifdef __glibcxx_string_view
3302 template<
typename _Tp>
3303 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3304 _If_sv<_Tp, size_type>
3306 noexcept(
is_same<_Tp, __sv_type>::value)
3308 __sv_type __sv = __svt;
3325 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3328 size_type __n)
const _GLIBCXX_NOEXCEPT;
3340 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3345 __glibcxx_requires_string(__s);
3359 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3375 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3381#ifdef __glibcxx_string_view
3389 template<
typename _Tp>
3390 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3391 _If_sv<_Tp, size_type>
3395 __sv_type __sv = __svt;
3412 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3415 size_type __n)
const _GLIBCXX_NOEXCEPT;
3427 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3432 __glibcxx_requires_string(__s);
3446 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3463 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3467 _M_check(__pos,
"basic_string::substr"), __n); }
3469#if __cplusplus >= 202302L
3477 substr(size_type __pos, size_type __n) &&
3481#ifdef __glibcxx_string_subview
3495 constexpr basic_string_view<_CharT, _Traits>
3496 subview(size_type __pos = 0, size_type __n =
npos)
const
3497 {
return __sv_type(*this).subview(__pos, __n); }
3514 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3518 const size_type __size = this->
size();
3519 const size_type __osize = __str.
size();
3520 const size_type __len =
std::min(__size, __osize);
3522 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
3524 __r = _S_compare(__size, __osize);
3528#ifdef __glibcxx_string_view
3534 template<
typename _Tp>
3535 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3537 compare(
const _Tp& __svt)
const
3540 __sv_type __sv = __svt;
3542 const size_type __osize = __sv.size();
3545 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3547 __r = _S_compare(__size, __osize);
3559 template<
typename _Tp>
3560 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3562 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3564 __sv_type __sv = __svt;
3565 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3578 template<
typename _Tp>
3579 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3581 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3582 size_type __pos2, size_type __n2 =
npos)
const
3584 __sv_type __sv = __svt;
3585 return __sv_type(*
this)
3586 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3609 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3613 _M_check(__pos,
"basic_string::compare");
3614 __n = _M_limit(__pos, __n);
3615 const size_type __osize = __str.
size();
3616 const size_type __len =
std::min(__n, __osize);
3617 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
3619 __r = _S_compare(__n, __osize);
3646 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3649 size_type __pos2, size_type __n2 =
npos)
const
3651 _M_check(__pos1,
"basic_string::compare");
3652 __str._M_check(__pos2,
"basic_string::compare");
3653 __n1 = _M_limit(__pos1, __n1);
3654 __n2 = __str._M_limit(__pos2, __n2);
3655 const size_type __len =
std::min(__n1, __n2);
3656 int __r = traits_type::compare(_M_data() + __pos1,
3657 __str.
data() + __pos2, __len);
3659 __r = _S_compare(__n1, __n2);
3677 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3679 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3681 __glibcxx_requires_string(__s);
3682 const size_type __size = this->
size();
3683 const size_type __osize = traits_type::length(__s);
3684 const size_type __len =
std::min(__size, __osize);
3685 int __r = traits_type::compare(_M_data(), __s, __len);
3687 __r = _S_compare(__size, __osize);
3712 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3714 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3716 __glibcxx_requires_string(__s);
3717 _M_check(__pos,
"basic_string::compare");
3718 __n1 = _M_limit(__pos, __n1);
3719 const size_type __osize = traits_type::length(__s);
3720 const size_type __len =
std::min(__n1, __osize);
3721 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3723 __r = _S_compare(__n1, __osize);
3751 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3753 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3754 size_type __n2)
const
3756 __glibcxx_requires_string_len(__s, __n2);
3757 _M_check(__pos,
"basic_string::compare");
3758 __n1 = _M_limit(__pos, __n1);
3759 const size_type __len =
std::min(__n1, __n2);
3760 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3762 __r = _S_compare(__n1, __n2);
3766#if __cplusplus >= 202002L
3770 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3774 starts_with(_CharT __x)
const noexcept
3775 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3777 [[nodiscard, __gnu__::__nonnull__]]
3779 starts_with(
const _CharT* __x)
const noexcept
3780 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3784 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3785 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3789 ends_with(_CharT __x)
const noexcept
3790 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3792 [[nodiscard, __gnu__::__nonnull__]]
3794 ends_with(
const _CharT* __x)
const noexcept
3795 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3798#if __cplusplus > 202002L
3801 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3802 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3806 contains(_CharT __x)
const noexcept
3807 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3809 [[nodiscard, __gnu__::__nonnull__]]
3811 contains(
const _CharT* __x)
const noexcept
3812 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3816 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3818_GLIBCXX_END_NAMESPACE_CXX11
3819_GLIBCXX_END_NAMESPACE_VERSION
3823namespace std _GLIBCXX_VISIBILITY(default)
3825_GLIBCXX_BEGIN_NAMESPACE_VERSION
3827#if __cpp_deduction_guides >= 201606
3828_GLIBCXX_BEGIN_NAMESPACE_CXX11
3829 template<
typename _InputIterator,
typename _CharT
3832 typename = _RequireInputIter<_InputIterator>,
3833 typename = _RequireAllocator<_Allocator>>
3834 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3839 template<
typename _CharT,
typename _Traits,
3841 typename = _RequireAllocator<_Allocator>>
3845 template<
typename _CharT,
typename _Traits,
3847 typename = _RequireAllocator<_Allocator>>
3849 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3850 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3851 const _Allocator& = _Allocator())
3854#if __glibcxx_containers_ranges
3857 basic_string(from_range_t, _Rg&&, _Allocator = _Allocator())
3862_GLIBCXX_END_NAMESPACE_CXX11
3865 template<
typename _Str>
3866 _GLIBCXX20_CONSTEXPR
3868 __str_concat(
typename _Str::value_type
const* __lhs,
3869 typename _Str::size_type __lhs_len,
3870 typename _Str::value_type
const* __rhs,
3871 typename _Str::size_type __rhs_len,
3872 typename _Str::allocator_type
const& __a)
3874 typedef typename _Str::allocator_type allocator_type;
3875 typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
3876 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3877 __str.
reserve(__lhs_len + __rhs_len);
3878 __str.
append(__lhs, __lhs_len);
3879 __str.
append(__rhs, __rhs_len);
3890 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3891 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3897 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3908 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3909 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3910 inline basic_string<_CharT,_Traits,_Alloc>
3914 __glibcxx_requires_string(__lhs);
3916 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3927 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3928 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3929 inline basic_string<_CharT,_Traits,_Alloc>
3933 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3944 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3945 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3946 inline basic_string<_CharT, _Traits, _Alloc>
3948 const _CharT* __rhs)
3950 __glibcxx_requires_string(__rhs);
3952 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3953 __rhs, _Traits::length(__rhs),
3962 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3963 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3964 inline basic_string<_CharT, _Traits, _Alloc>
3968 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3969 __builtin_addressof(__rhs), 1,
3973#if __cplusplus >= 201103L
3974 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3975 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3976 inline basic_string<_CharT, _Traits, _Alloc>
3977 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3978 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3979 {
return std::move(__lhs.append(__rhs)); }
3981 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3982 _GLIBCXX20_CONSTEXPR
3986 {
return std::move(__rhs.insert(0, __lhs)); }
3988 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3989 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3994#pragma GCC diagnostic push
3995#pragma GCC diagnostic ignored "-Wc++17-extensions"
3998 bool __use_rhs =
false;
4001 else if (__lhs.get_allocator() == __rhs.get_allocator())
4005 const auto __size = __lhs.size() + __rhs.size();
4006 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
4007 return std::move(__rhs.insert(0, __lhs));
4010#pragma GCC diagnostic pop
4013 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4014 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4018 {
return std::move(__rhs.insert(0, __lhs)); }
4020 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4021 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4025 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4027 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4028 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4031 const _CharT* __rhs)
4032 {
return std::move(__lhs.append(__rhs)); }
4034 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4035 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4039 {
return std::move(__lhs.append(1, __rhs)); }
4042#if __glibcxx_string_view >= 202403L
4044 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4051 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4052 __rhs.data(), __rhs.size(),
4053 __lhs.get_allocator());
4057 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4074 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4075 __rhs.data(), __rhs.size(),
4076 __rhs.get_allocator());
4080 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4086 return std::move(__rhs.insert(0, __lhs));
4097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4098 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4104 return __lhs.size() == __rhs.size()
4105 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
4114 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4115 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4118 const _CharT* __rhs)
4120 return __lhs.
size() == _Traits::length(__rhs)
4121 && !_Traits::compare(__lhs.
data(), __rhs, __lhs.
size());
4124#if __cpp_lib_three_way_comparison
4132 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4137 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4138 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4151 const _CharT* __rhs)
noexcept
4152 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4153 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4161 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4164 operator==(
const _CharT* __lhs,
4165 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4166 {
return __rhs == __lhs; }
4175 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4181 {
return !(__lhs == __rhs); }
4189 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4192 operator!=(
const _CharT* __lhs,
4194 {
return !(__rhs == __lhs); }
4202 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4206 const _CharT* __rhs)
4207 {
return !(__lhs == __rhs); }
4216 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4222 {
return __lhs.compare(__rhs) < 0; }
4230 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4234 const _CharT* __rhs)
4235 {
return __lhs.compare(__rhs) < 0; }
4243 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4246 operator<(
const _CharT* __lhs,
4248 {
return __rhs.compare(__lhs) > 0; }
4257 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4263 {
return __lhs.compare(__rhs) > 0; }
4271 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4275 const _CharT* __rhs)
4276 {
return __lhs.compare(__rhs) > 0; }
4284 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4287 operator>(
const _CharT* __lhs,
4289 {
return __rhs.compare(__lhs) < 0; }
4298 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4304 {
return __lhs.compare(__rhs) <= 0; }
4312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4316 const _CharT* __rhs)
4317 {
return __lhs.compare(__rhs) <= 0; }
4325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4328 operator<=(
const _CharT* __lhs,
4330 {
return __rhs.compare(__lhs) >= 0; }
4339 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4345 {
return __lhs.compare(__rhs) >= 0; }
4353 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4357 const _CharT* __rhs)
4358 {
return __lhs.compare(__rhs) >= 0; }
4366 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4369 operator>=(
const _CharT* __lhs,
4371 {
return __rhs.compare(__lhs) <= 0; }
4381 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4382 _GLIBCXX20_CONSTEXPR
4386 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4387 { __lhs.swap(__rhs); }
4402 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4403 basic_istream<_CharT, _Traits>&
4404 operator>>(basic_istream<_CharT, _Traits>& __is,
4405 basic_string<_CharT, _Traits, _Alloc>& __str);
4408 basic_istream<char>&
4420 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4427 return __ostream_insert(__os, __str.
data(), __str.
size());
4443 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4444 basic_istream<_CharT, _Traits>&
4445 getline(basic_istream<_CharT, _Traits>& __is,
4446 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4460 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4461 inline basic_istream<_CharT, _Traits>&
4466#if __cplusplus >= 201103L
4468 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4469 inline basic_istream<_CharT, _Traits>&
4475 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4476 inline basic_istream<_CharT, _Traits>&
4483 basic_istream<char>&
4484 getline(basic_istream<char>& __in, basic_string<char>& __str,
4487#ifdef _GLIBCXX_USE_WCHAR_T
4489 basic_istream<wchar_t>&
4490 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4494_GLIBCXX_END_NAMESPACE_VERSION
4497#if __cplusplus >= 201103L
4502namespace std _GLIBCXX_VISIBILITY(default)
4504_GLIBCXX_BEGIN_NAMESPACE_VERSION
4505_GLIBCXX_BEGIN_NAMESPACE_CXX11
4509 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4510 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4514 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4515 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4518 inline unsigned long
4519 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4520 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4523#if _GLIBCXX_USE_C99_STDLIB
4525 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4526 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4529 inline unsigned long long
4530 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4531 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4533#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4535 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4536 {
return std::stol(__str, __idx, __base); }
4538 inline unsigned long long
4539 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4540 {
return std::stoul(__str, __idx, __base); }
4544 stod(
const string& __str,
size_t* __idx = 0)
4545 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4547#if _GLIBCXX_HAVE_STRTOF
4550 stof(
const string& __str,
size_t* __idx = 0)
4551 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4554 stof(
const string& __str,
size_t* __idx = 0)
4556 double __d = std::stod(__str, __idx);
4557 if (__builtin_isfinite(__d) && __d != 0.0)
4559 double __abs_d = __builtin_fabs(__d);
4560 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4563 std::__throw_out_of_range(
"stof");
4570#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4572 stold(
const string& __str,
size_t* __idx = 0)
4573 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4574#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4576 stold(
const string& __str,
size_t* __idx = 0)
4577 {
return std::stod(__str, __idx); }
4585 to_string(
int __val)
4586#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4590 const bool __neg = __val < 0;
4591 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4592 const auto __len = __detail::__to_chars_len(__uval);
4594 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4596 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4604 to_string(
unsigned __val)
4605#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4609 const auto __len = __detail::__to_chars_len(__val);
4611 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4612 __detail::__to_chars_10_impl(__p, __n, __val);
4620 to_string(
long __val)
4621#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4625 const bool __neg = __val < 0;
4626 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4627 const auto __len = __detail::__to_chars_len(__uval);
4629 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4631 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4639 to_string(
unsigned long __val)
4640#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4644 const auto __len = __detail::__to_chars_len(__val);
4646 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4647 __detail::__to_chars_10_impl(__p, __n, __val);
4655 to_string(
long long __val)
4657 const bool __neg = __val < 0;
4658 const unsigned long long __uval
4659 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4660 const auto __len = __detail::__to_chars_len(__uval);
4662 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4664 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4672 to_string(
unsigned long long __val)
4674 const auto __len = __detail::__to_chars_len(__val);
4676 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4677 __detail::__to_chars_10_impl(__p, __n, __val);
4683#if __glibcxx_to_string >= 202306L
4687 to_string(
float __val)
4692 __str.resize_and_overwrite(__len,
4693 [__val, &__len] (
char* __p,
size_t __n) {
4694 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4695 if (__err == errc{}) [[likely]]
4700 }
while (__str.empty());
4706 to_string(
double __val)
4711 __str.resize_and_overwrite(__len,
4712 [__val, &__len] (
char* __p,
size_t __n) {
4713 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4714 if (__err == errc{}) [[likely]]
4719 }
while (__str.empty());
4725 to_string(
long double __val)
4730 __str.resize_and_overwrite(__len,
4731 [__val, &__len] (
char* __p,
size_t __n) {
4732 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4733 if (__err == errc{}) [[likely]]
4738 }
while (__str.empty());
4741#elif _GLIBCXX_USE_C99_STDIO
4742#pragma GCC diagnostic push
4743#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4748 to_string(
float __val)
4751 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4752 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4758 to_string(
double __val)
4761 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4762 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4768 to_string(
long double __val)
4771 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4772 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4775#pragma GCC diagnostic pop
4778#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4780 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4781 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4785 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4786 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4789 inline unsigned long
4790 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4791 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4795 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4796 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4799 inline unsigned long long
4800 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4801 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4806 stof(
const wstring& __str,
size_t* __idx = 0)
4807 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4810 stod(
const wstring& __str,
size_t* __idx = 0)
4811 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4814 stold(
const wstring& __str,
size_t* __idx = 0)
4815 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4818#ifdef _GLIBCXX_USE_WCHAR_T
4819#pragma GCC diagnostic push
4820#pragma GCC diagnostic ignored "-Wc++17-extensions"
4821 _GLIBCXX20_CONSTEXPR
4823 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4827 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4828 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4830 for (
int __i = 0; __i < __len; ++__i)
4831 __wout[__i] = (
wchar_t) __s[__i];
4836 for (
int __i =
'0'; __i <=
'9'; ++__i)
4837 __wc[__i] = L
'0' + __i;
4862 for (
int __i = 0; __i < __len; ++__i)
4863 __wout[__i] = __wc[(
int)__s[__i]];
4867#if __glibcxx_constexpr_string >= 201907L
4871#ifdef __glibcxx_string_view
4872 __to_wstring_numeric(string_view __s)
4874 __to_wstring_numeric(
const string& __s)
4877 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4878 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4879 return wstring(__s.data(), __s.data() + __s.size());
4883 auto __f = __s.data();
4884 __ws.__resize_and_overwrite(__s.size(),
4885 [__f] (
wchar_t* __to,
int __n) {
4886 std::__to_wstring_numeric(__f, __n, __to);
4892#pragma GCC diagnostic pop
4896 to_wstring(
int __val)
4897 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4901 to_wstring(
unsigned __val)
4902 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4906 to_wstring(
long __val)
4907 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4911 to_wstring(
unsigned long __val)
4912 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4916 to_wstring(
long long __val)
4917 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4921 to_wstring(
unsigned long long __val)
4922 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4924#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4927 to_wstring(
float __val)
4928 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4932 to_wstring(
double __val)
4933 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4937 to_wstring(
long double __val)
4938 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4942_GLIBCXX_END_NAMESPACE_CXX11
4943_GLIBCXX_END_NAMESPACE_VERSION
4948#if __cplusplus >= 201103L
4952namespace std _GLIBCXX_VISIBILITY(default)
4954_GLIBCXX_BEGIN_NAMESPACE_VERSION
4959 template<
typename _CharT,
typename _Alloc,
4961 struct __str_hash_base
4962 :
public __hash_base<size_t, _StrT>
4966 operator()(
const _StrT& __s)
const noexcept
4967 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4970#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4972 template<
typename _Alloc>
4974 :
public __str_hash_base<char, _Alloc>
4978 template<
typename _Alloc>
4980 :
public __str_hash_base<wchar_t, _Alloc>
4983 template<
typename _Alloc>
4990#ifdef _GLIBCXX_USE_CHAR8_T
4992 template<
typename _Alloc>
4993 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4994 :
public __str_hash_base<char8_t, _Alloc>
4999 template<
typename _Alloc>
5001 :
public __str_hash_base<char16_t, _Alloc>
5005 template<
typename _Alloc>
5007 :
public __str_hash_base<char32_t, _Alloc>
5010#if ! _GLIBCXX_INLINE_VERSION
5016#ifdef _GLIBCXX_USE_CHAR8_T
5021 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5027#ifdef __glibcxx_string_udls
5030 inline namespace string_literals
5032#pragma GCC diagnostic push
5033#pragma GCC diagnostic ignored "-Wliteral-suffix"
5035#if __glibcxx_constexpr_string >= 201907L
5036# define _GLIBCXX_STRING_CONSTEXPR constexpr
5038# define _GLIBCXX_STRING_CONSTEXPR
5041 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5042 inline basic_string<char>
5043 operator""s(
const char* __str,
size_t __len)
5044 {
return basic_string<char>{__str, __len}; }
5046 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5047 inline basic_string<wchar_t>
5048 operator""s(
const wchar_t* __str,
size_t __len)
5049 {
return basic_string<wchar_t>{__str, __len}; }
5051#ifdef _GLIBCXX_USE_CHAR8_T
5052 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5053 inline basic_string<char8_t>
5054 operator""s(
const char8_t* __str,
size_t __len)
5055 {
return basic_string<char8_t>{__str, __len}; }
5058 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5059 inline basic_string<char16_t>
5060 operator""s(
const char16_t* __str,
size_t __len)
5061 {
return basic_string<char16_t>{__str, __len}; }
5063 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5064 inline basic_string<char32_t>
5065 operator""s(
const char32_t* __str,
size_t __len)
5066 {
return basic_string<char32_t>{__str, __len}; }
5068#undef _GLIBCXX_STRING_CONSTEXPR
5069#pragma GCC diagnostic pop
5074#ifdef __glibcxx_variant
5075 namespace __detail::__variant
5077 template<
typename>
struct _Never_valueless_alt;
5081 template<
typename _Tp,
typename _Traits,
typename _Alloc>
5082 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
5084 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
5085 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
5091_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.