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;
139 static _GLIBCXX20_CONSTEXPR pointer
140 _S_allocate(_Char_alloc_type& __a, size_type __n)
143 struct _Alloc_result { pointer __ptr;
size_type __count; };
145 static _GLIBCXX20_CONSTEXPR _Alloc_result
146 _S_allocate_at_least(_Char_alloc_type& __a, size_type __n)
149#ifdef __glibcxx_allocate_at_least
152 __r.__count = __count;
157#if __glibcxx_constexpr_string >= 201907L
160 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
161 if (std::__is_constant_evaluated())
163 for (size_type __i = 0; __i < __r.__count; ++__i)
164 std::construct_at(__builtin_addressof(__r.__ptr[__i]));
169#ifdef __glibcxx_string_view
171 typedef basic_string_view<_CharT, _Traits> __sv_type;
173 template<
typename _Tp,
typename _Res>
175 __and_<is_convertible<const _Tp&, __sv_type>,
176 __not_<is_convertible<const _Tp*, const basic_string*>>,
177 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
183 _S_to_string_view(__sv_type __svt)
noexcept
192 _GLIBCXX20_CONSTEXPR
explicit
193 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
211 struct _Alloc_hider : allocator_type
213#if __cplusplus < 201103L
214 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
215 : allocator_type(__a), _M_p(__dat) { }
218 _Alloc_hider(pointer __dat,
const _Alloc& __a)
219 : allocator_type(__a), _M_p(__dat) { }
222 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
223 : allocator_type(std::
move(__a)), _M_p(__dat) { }
229 _Alloc_hider _M_dataplus;
230 size_type _M_string_length;
232 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
236 _CharT _M_local_buf[_S_local_capacity + 1];
237 size_type _M_allocated_capacity;
243 { _M_dataplus._M_p = __p; }
247 _M_length(size_type __length)
248 { _M_string_length = __length; }
253 {
return _M_dataplus._M_p; }
259#if __cplusplus >= 201103L
260 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
262 return pointer(_M_local_buf);
268 _M_local_data()
const
270#if __cplusplus >= 201103L
271 return std::pointer_traits<const_pointer>::pointer_to(*_M_local_buf);
273 return const_pointer(_M_local_buf);
279 _M_capacity(size_type __capacity)
280 { _M_allocated_capacity = __capacity; }
284 _M_set_length(size_type __n)
286 traits_type::assign(_M_data()[__n], _CharT());
294 if (_M_data() == _M_local_data())
296 if (_M_string_length > _S_local_capacity)
297 __builtin_unreachable();
306 _M_create_plus(size_type __new_capacity, size_type __old_capacity);
308 __attribute__((__always_inline__))
311 _M_create_and_place(size_type __new_capacity, size_type __old_capacity)
313 _Alloc_result __r = _M_create_plus(__new_capacity, __old_capacity);
315 _M_capacity(__r.__count - 1);
321 _M_create(size_type&, size_type);
328 _M_destroy(_M_allocated_capacity);
333 _M_destroy(size_type __size)
throw()
336#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
339 template<
typename _InIterator>
341 _M_construct_aux(_InIterator __beg, _InIterator __end,
344 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
345 _M_construct(__beg, __end, _Tag());
350 template<
typename _Integer>
352 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
353 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
356 _M_construct_aux_2(size_type __req, _CharT __c)
357 { _M_construct(__req, __c); }
361 template<
typename _InIterator>
364 _M_construct(_InIterator __beg, _InIterator __end,
365 std::input_iterator_tag);
369 template<
typename _FwdIterator>
372 _M_construct(_FwdIterator __beg, _FwdIterator __end,
373 std::forward_iterator_tag);
377 _M_construct(size_type __req, _CharT __c);
381 template<
bool _Terminated>
384 _M_construct(
const _CharT *__c, size_type __n);
386#if __cplusplus >= 202302L
388 _M_construct(
basic_string&& __str, size_type __pos, size_type __n);
394 {
return _M_dataplus; }
397 const allocator_type&
398 _M_get_allocator()
const
399 {
return _M_dataplus; }
402 __attribute__((__always_inline__))
405 _M_init_local_buf() _GLIBCXX_NOEXCEPT
407#if __glibcxx_is_constant_evaluated
408 if (std::is_constant_evaluated())
409 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
410 _M_local_buf[__i] = _CharT();
414 __attribute__((__always_inline__))
417 _M_use_local_data() _GLIBCXX_NOEXCEPT
419#if __cpp_lib_is_constant_evaluated
422 return _M_local_data();
427#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
430 template<
typename _Tp,
bool _Requires =
431 !__are_same<_Tp, _CharT*>::__value
432 && !__are_same<_Tp, const _CharT*>::__value
433 && !__are_same<_Tp, iterator>::__value
434 && !__are_same<_Tp, const_iterator>::__value>
435 struct __enable_if_not_native_iterator
436 {
typedef basic_string& __type; };
437 template<
typename _Tp>
438 struct __enable_if_not_native_iterator<_Tp, false> { };
443 _M_check(size_type __pos,
const char* __s)
const
445 if (__pos > this->
size())
446 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
447 "this->size() (which is %zu)"),
448 __s, (
size_t)__pos, (
size_t)this->
size());
454 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
457 __throw_length_error(__N(__s));
464 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
466 const bool __testoff = __off < this->
size() - __pos;
467 return __testoff ? __off : this->
size() - __pos;
472 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
474 return (less<const _CharT*>()(__s, _M_data())
475 || less<const _CharT*>()(_M_data() + this->
size(), __s));
482 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
485 traits_type::assign(*__d, *__s);
487 traits_type::copy(__d, __s, __n);
492 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
495 traits_type::assign(*__d, *__s);
497 traits_type::move(__d, __s, __n);
502 _S_assign(_CharT* __d, size_type __n, _CharT __c)
505 traits_type::assign(*__d, __c);
507 traits_type::assign(__d, __n, __c);
510#pragma GCC diagnostic push
511#pragma GCC diagnostic ignored "-Wc++17-extensions"
514 template<
class _Iterator>
517 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
519#if __cplusplus >= 201103L
520 using _IterBase =
decltype(std::__niter_base(__k1));
521 if constexpr (__or_<is_same<_IterBase, _CharT*>,
522 is_same<_IterBase, const _CharT*>>::value)
523 _S_copy(__p, std::__niter_base(__k1), __k2 - __k1);
524#if __cpp_lib_concepts
525 else if constexpr (
requires {
526 requires contiguous_iterator<_Iterator>;
528 -> convertible_to<const _CharT*>;
531 const auto __d = __k2 - __k1;
538 for (; __k1 != __k2; ++__k1, (void)++__p)
539 traits_type::assign(*__p,
static_cast<_CharT
>(*__k1));
541#pragma GCC diagnostic pop
543#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
545 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
546 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
549 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
550 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
553 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
554 { _S_copy(__p, __k1, __k2 - __k1); }
557 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
558 { _S_copy(__p, __k1, __k2 - __k1); }
561#if __glibcxx_containers_ranges
563 template<
typename _Rg>
564 static constexpr void
565 _S_copy_range(pointer __p, _Rg&& __rg, size_type __n)
567 if constexpr (
requires {
568 requires ranges::contiguous_range<_Rg>;
570 -> convertible_to<const _CharT*>;
575 auto __first = ranges::begin(__rg);
576 const auto __last = ranges::end(__rg);
577 for (; __first != __last; ++__first)
578 traits_type::assign(*__p++,
static_cast<_CharT
>(*__first));
585 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
587 const difference_type __d = difference_type(__n1 - __n2);
589 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
590 return __gnu_cxx::__numeric_traits<int>::__max;
591 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
592 return __gnu_cxx::__numeric_traits<int>::__min;
603 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
608 _M_erase(size_type __pos, size_type __n);
621#if __cpp_concepts && __glibcxx_type_trait_variable_templates
622 requires is_default_constructible_v<_Alloc>
624 : _M_dataplus(_M_local_data())
636 : _M_dataplus(_M_local_data(), __a)
648 : _M_dataplus(_M_local_data(),
649 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
651 _M_construct<true>(__str._M_data(), __str.
length());
664 const _Alloc& __a = _Alloc())
665 : _M_dataplus(_M_local_data(), __a)
667 const _CharT* __start = __str._M_data()
668 + __str._M_check(__pos,
"basic_string::basic_string");
669 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
682 : _M_dataplus(_M_local_data())
684 const _CharT* __start = __str._M_data()
685 + __str._M_check(__pos,
"basic_string::basic_string");
686 _M_construct(__start, __start + __str._M_limit(__pos, __n),
699 size_type __n,
const _Alloc& __a)
700 : _M_dataplus(_M_local_data(), __a)
702 const _CharT* __start
703 = __str._M_data() + __str._M_check(__pos,
"string::string");
704 _M_construct(__start, __start + __str._M_limit(__pos, __n),
708#if __cplusplus >= 202302L
711 const _Alloc& __a = _Alloc())
712 : _M_dataplus(_M_local_data(), __a)
714 __pos = __str._M_check(__pos,
"string::string");
720 const _Alloc& __a = _Alloc())
721 : _M_dataplus(_M_local_data(), __a)
723 __pos = __str._M_check(__pos,
"string::string");
724 _M_construct(
std::move(__str), __pos, __str._M_limit(__pos, __n));
739 const _Alloc& __a = _Alloc())
740 : _M_dataplus(_M_local_data(), __a)
743 if (__s == 0 && __n > 0)
744 std::__throw_logic_error(__N(
"basic_string: "
745 "construction from null is not valid"));
754#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
757 template<
typename = _RequireAllocator<_Alloc>>
761 : _M_dataplus(_M_local_data(), __a)
765 std::__throw_logic_error(__N(
"basic_string: "
766 "construction from null is not valid"));
767 const _CharT* __end = __s + traits_type::length(__s);
777#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
780 template<
typename = _RequireAllocator<_Alloc>>
784 : _M_dataplus(_M_local_data(), __a)
785 { _M_construct(__n, __c); }
787#if __cplusplus >= 201103L
797 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
799 if (__str._M_is_local())
802 traits_type::copy(_M_local_buf, __str._M_local_buf,
807 _M_data(__str._M_data());
808 _M_capacity(__str._M_allocated_capacity);
814 _M_length(__str.
length());
815 __str._M_data(__str._M_use_local_data());
816 __str._M_set_length(0);
819#if __glibcxx_containers_ranges
824 template<__detail::__container_compatible_range<_CharT> _Rg>
826 basic_string(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
831 const auto __n =
static_cast<size_type>(ranges::distance(__rg));
838 auto __first = ranges::begin(__rg);
839 const auto __last = ranges::end(__rg);
840 for (; __first != __last; ++__first)
853 : _M_dataplus(_M_local_data(), __a)
858 : _M_dataplus(_M_local_data(), __a)
863 noexcept(_Alloc_traits::_S_always_equal())
864 : _M_dataplus(_M_local_data(), __a)
866 if (__str._M_is_local())
869 traits_type::copy(_M_local_buf, __str._M_local_buf,
871 _M_length(__str.length());
872 __str._M_set_length(0);
874 else if (_Alloc_traits::_S_always_equal()
877 _M_data(__str._M_data());
878 _M_length(__str.length());
879 _M_capacity(__str._M_allocated_capacity);
880 __str._M_data(__str._M_use_local_data());
881 __str._M_set_length(0);
888#if __cplusplus >= 202100L
899#if __cplusplus >= 201103L
900 template<
typename _InputIterator,
901 typename = std::_RequireInputIter<_InputIterator>>
903 template<
typename _InputIterator>
907 const _Alloc& __a = _Alloc())
908 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
910#if __cplusplus >= 201103L
911 _M_construct(__beg, __end, std::__iterator_category(__beg));
913 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
914 _M_construct_aux(__beg, __end, _Integral());
918#ifdef __glibcxx_string_view
926 template<
typename _Tp,
930 const _Alloc& __a = _Alloc())
938 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
941 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
942 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
960 return this->
assign(__str);
970 {
return this->
assign(__s); }
987#if __cplusplus >= 201103L
1000 noexcept(_Alloc_traits::_S_nothrow_move())
1002 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
1003 || _M_get_allocator() == __str._M_get_allocator();
1004 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
1008 _M_destroy(_M_allocated_capacity);
1009 _M_data(_M_local_data());
1013 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
1015 if (__str._M_is_local())
1023 this->_S_copy(_M_data(), __str._M_data(), __str.
size());
1024 _M_set_length(__str.
size());
1027 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
1030 pointer __data =
nullptr;
1031 size_type __capacity;
1038 __capacity = _M_allocated_capacity;
1041 _M_destroy(_M_allocated_capacity);
1044 _M_data(__str._M_data());
1045 _M_length(__str.
length());
1046 _M_capacity(__str._M_allocated_capacity);
1049 __str._M_data(__data);
1050 __str._M_capacity(__capacity);
1053 __str._M_data(__str._M_use_local_data());
1065 _GLIBCXX20_CONSTEXPR
1069 this->
assign(__l.begin(), __l.size());
1074#ifdef __glibcxx_string_view
1079 template<
typename _Tp>
1080 _GLIBCXX20_CONSTEXPR
1081 _If_sv<_Tp, basic_string&>
1082 operator=(
const _Tp& __svt)
1083 {
return this->
assign(__svt); }
1089 _GLIBCXX20_CONSTEXPR
1090 operator __sv_type() const noexcept
1091 {
return __sv_type(
data(),
size()); }
1099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1102 {
return iterator(_M_data()); }
1108 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1111 {
return const_iterator(_M_data()); }
1117 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1120 {
return iterator(_M_data() + this->
size()); }
1126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1129 {
return const_iterator(_M_data() + this->
size()); }
1136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1139 {
return reverse_iterator(this->
end()); }
1146 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1147 const_reverse_iterator
1149 {
return const_reverse_iterator(this->
end()); }
1156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1159 {
return reverse_iterator(this->
begin()); }
1166 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1167 const_reverse_iterator
1169 {
return const_reverse_iterator(this->
begin()); }
1171#if __cplusplus >= 201103L
1176 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1179 {
return const_iterator(this->_M_data()); }
1185 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1188 {
return const_iterator(this->_M_data() + this->
size()); }
1195 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1196 const_reverse_iterator
1198 {
return const_reverse_iterator(this->
end()); }
1205 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1206 const_reverse_iterator
1208 {
return const_reverse_iterator(this->
begin()); }
1215 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1219 size_type __sz = _M_string_length;
1221 __builtin_unreachable();
1227 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1233 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1237 const size_t __diffmax
1238 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1240 return (
std::min)(__diffmax, __allocmax) - 1;
1253 _GLIBCXX20_CONSTEXPR
1267 _GLIBCXX20_CONSTEXPR
1270 { this->
resize(__n, _CharT()); }
1272#if __cplusplus >= 201103L
1273#pragma GCC diagnostic push
1274#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1276 _GLIBCXX20_CONSTEXPR
1280#pragma GCC diagnostic pop
1283#ifdef __glibcxx_string_resize_and_overwrite
1313 template<
typename _Operation>
1315 resize_and_overwrite(
size_type __n, _Operation __op);
1318#if __cplusplus >= 201103L
1320 template<
typename _Operation>
1321 _GLIBCXX20_CONSTEXPR
void
1329 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1333 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1334 : _M_allocated_capacity;
1335 if (__sz < _S_local_capacity || __sz >
max_size ())
1336 __builtin_unreachable();
1357 _GLIBCXX20_CONSTEXPR
1364#if __cplusplus >= 202002L
1365 [[deprecated(
"use shrink_to_fit() instead")]]
1367 _GLIBCXX20_CONSTEXPR
1374 _GLIBCXX20_CONSTEXPR
1377 { _M_set_length(0); }
1383 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1386 {
return _M_string_length == 0; }
1399 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1403 __glibcxx_assert(__pos <=
size());
1404 return _M_data()[__pos];
1417 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1423 __glibcxx_assert(__pos <=
size());
1425 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1426 return _M_data()[__pos];
1439 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1443 if (__n >= this->
size())
1444 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1445 "(which is %zu) >= this->size() "
1448 return _M_data()[__n];
1461 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1466 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1467 "(which is %zu) >= this->size() "
1470 return _M_data()[__n];
1473#if __cplusplus >= 201103L
1478 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1482 __glibcxx_assert(!
empty());
1490 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1494 __glibcxx_assert(!
empty());
1502 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1506 __glibcxx_assert(!
empty());
1514 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1518 __glibcxx_assert(!
empty());
1529 _GLIBCXX20_CONSTEXPR
1532 {
return this->
append(__str); }
1539 _GLIBCXX20_CONSTEXPR
1542 {
return this->
append(__s); }
1549 _GLIBCXX20_CONSTEXPR
1557#if __cplusplus >= 201103L
1563 _GLIBCXX20_CONSTEXPR
1566 {
return this->
append(__l.begin(), __l.size()); }
1569#ifdef __glibcxx_string_view
1575 template<
typename _Tp>
1576 _GLIBCXX20_CONSTEXPR
1577 _If_sv<_Tp, basic_string&>
1579 {
return this->
append(__svt); }
1587 _GLIBCXX20_CONSTEXPR
1590 {
return this->
append(__str._M_data(), __str.
size()); }
1605 _GLIBCXX20_CONSTEXPR
1608 {
return this->
append(__str._M_data()
1609 + __str._M_check(__pos,
"basic_string::append"),
1610 __str._M_limit(__pos, __n)); }
1618 _GLIBCXX20_CONSTEXPR
1622 __glibcxx_requires_string_len(__s, __n);
1623 _M_check_length(size_type(0), __n,
"basic_string::append");
1624 return _M_append(__s, __n);
1632 _GLIBCXX20_CONSTEXPR
1636 __glibcxx_requires_string(__s);
1637 const size_type __n = traits_type::length(__s);
1638 _M_check_length(size_type(0), __n,
"basic_string::append");
1639 return _M_append(__s, __n);
1650 _GLIBCXX20_CONSTEXPR
1653 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1655#if __glibcxx_containers_ranges
1663 template<__detail::__container_compatible_range<_CharT> _Rg>
1665 append_range(_Rg&& __rg)
1672 const auto __len =
size_type(ranges::distance(__rg));
1682 _M_check_length(0, __len,
"basic_string::append_range");
1684 __s.reserve(__newlen);
1687 _S_copy(__s._M_data(), _M_data(),
size());
1689 _M_destroy(_M_allocated_capacity);
1690 _M_data(__s._M_data());
1691 _M_capacity(__s._M_allocated_capacity);
1692 __s._M_data(__s._M_local_data());
1695 _M_set_length(__newlen);
1700 _M_get_allocator());
1707#if __cplusplus >= 201103L
1713 _GLIBCXX20_CONSTEXPR
1716 {
return this->
append(__l.begin(), __l.size()); }
1727#if __cplusplus >= 201103L
1728 template<
class _InputIterator,
1729 typename = std::_RequireInputIter<_InputIterator>>
1730 _GLIBCXX20_CONSTEXPR
1732 template<
class _InputIterator>
1735 append(_InputIterator __first, _InputIterator __last)
1738#ifdef __glibcxx_string_view
1744 template<
typename _Tp>
1745 _GLIBCXX20_CONSTEXPR
1746 _If_sv<_Tp, basic_string&>
1749 __sv_type __sv = __svt;
1750 return this->
append(__sv.data(), __sv.size());
1760 template<
typename _Tp>
1761 _GLIBCXX20_CONSTEXPR
1762 _If_sv<_Tp, basic_string&>
1763 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1765 __sv_type __sv = __svt;
1766 return _M_append(__sv.data()
1767 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1768 std::__sv_limit(__sv.size(), __pos, __n));
1776 _GLIBCXX20_CONSTEXPR
1780 const size_type __size = this->
size();
1782 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1783 traits_type::assign(this->_M_data()[__size], __c);
1784 this->_M_set_length(__size + 1);
1792 _GLIBCXX20_CONSTEXPR
1796#if __cplusplus >= 201103L
1797 if (_Alloc_traits::_S_propagate_on_copy_assign())
1799 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1800 && _M_get_allocator() != __str._M_get_allocator())
1804 if (__str.
size() <= _S_local_capacity)
1806 _M_destroy(_M_allocated_capacity);
1807 _M_data(_M_use_local_data());
1812 const auto __len = __str.
size();
1813 auto __alloc = __str._M_get_allocator();
1815 auto __r = _S_allocate_at_least(__alloc, __len + 1);
1816 _M_destroy(_M_allocated_capacity);
1818 _M_capacity(__r.__count - 1);
1819 _M_set_length(__len);
1822 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1825 this->_M_assign(__str);
1829#if __cplusplus >= 201103L
1838 _GLIBCXX20_CONSTEXPR
1841 noexcept(_Alloc_traits::_S_nothrow_move())
1862 _GLIBCXX20_CONSTEXPR
1865 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1866 + __str._M_check(__pos,
"basic_string::assign"),
1867 __str._M_limit(__pos, __n)); }
1879 _GLIBCXX20_CONSTEXPR
1883 __glibcxx_requires_string_len(__s, __n);
1884 return _M_replace(size_type(0), this->
size(), __s, __n);
1896 _GLIBCXX20_CONSTEXPR
1900 __glibcxx_requires_string(__s);
1901 return _M_replace(size_type(0), this->
size(), __s,
1902 traits_type::length(__s));
1914 _GLIBCXX20_CONSTEXPR
1917 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1927#if __cplusplus >= 201103L
1928#pragma GCC diagnostic push
1929#pragma GCC diagnostic ignored "-Wc++17-extensions"
1930 template<
class _InputIterator,
1931 typename = std::_RequireInputIter<_InputIterator>>
1932 _GLIBCXX20_CONSTEXPR
1934 assign(_InputIterator __first, _InputIterator __last)
1937 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1938 &&
is_same<
typename _IterTraits::value_type,
1941 __glibcxx_requires_valid_range(__first, __last);
1942 return _M_replace(size_type(0),
size(),
1943 std::__niter_base(__first), __last - __first);
1945#if __cplusplus >= 202002L
1946 else if constexpr (contiguous_iterator<_InputIterator>
1947 && is_same_v<iter_value_t<_InputIterator>,
1950 __glibcxx_requires_valid_range(__first, __last);
1951 return _M_replace(size_type(0),
size(),
1958#pragma GCC diagnostic pop
1960 template<
class _InputIterator>
1962 assign(_InputIterator __first, _InputIterator __last)
1966#if __glibcxx_containers_ranges
1974 template<__detail::__container_compatible_range<_CharT> _Rg>
1976 assign_range(_Rg&& __rg)
1979 _M_get_allocator());
1985#if __cplusplus >= 201103L
1991 _GLIBCXX20_CONSTEXPR
1997 const size_type __n = __l.size();
2003 _S_copy(_M_data(), __l.begin(), __n);
2010#ifdef __glibcxx_string_view
2016 template<
typename _Tp>
2017 _GLIBCXX20_CONSTEXPR
2018 _If_sv<_Tp, basic_string&>
2021 __sv_type __sv = __svt;
2022 return this->
assign(__sv.data(), __sv.size());
2032 template<
typename _Tp>
2033 _GLIBCXX20_CONSTEXPR
2034 _If_sv<_Tp, basic_string&>
2035 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
2037 __sv_type __sv = __svt;
2038 return _M_replace(size_type(0), this->
size(),
2040 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
2041 std::__sv_limit(__sv.size(), __pos, __n));
2045#if __cplusplus >= 201103L
2061 _GLIBCXX20_CONSTEXPR
2063 insert(const_iterator __p, size_type __n, _CharT __c)
2065 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2066 const size_type __pos = __p -
begin();
2067 this->
replace(__p, __p, __n, __c);
2068 return iterator(this->_M_data() + __pos);
2086 { this->
replace(__p, __p, __n, __c); }
2089#if __cplusplus >= 201103L
2104 template<
class _InputIterator,
2105 typename = std::_RequireInputIter<_InputIterator>>
2106 _GLIBCXX20_CONSTEXPR
2108 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
2110 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2111 const size_type __pos = __p -
begin();
2112 this->
replace(__p, __p, __beg, __end);
2113 return iterator(this->_M_data() + __pos);
2128 template<
class _InputIterator>
2131 { this->
replace(__p, __p, __beg, __end); }
2134#if __glibcxx_containers_ranges
2142 template<__detail::__container_compatible_range<_CharT> _Rg>
2144 insert_range(const_iterator __p, _Rg&& __rg)
2146 auto __pos = __p -
cbegin();
2148 if constexpr (ranges::forward_range<_Rg>)
2149 if (ranges::empty(__rg))
2150 return begin() + __pos;
2158 _M_get_allocator());
2161 return begin() + __pos;
2165#if __cplusplus >= 201103L
2172 _GLIBCXX20_CONSTEXPR
2175 {
return this->
insert(__p, __l.begin(), __l.end()); }
2177#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
2182 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2183 this->
insert(__p -
begin(), __l.begin(), __l.size());
2200 _GLIBCXX20_CONSTEXPR
2203 {
return this->
replace(__pos1, size_type(0),
2204 __str._M_data(), __str.
size()); }
2224 _GLIBCXX20_CONSTEXPR
2227 size_type __pos2, size_type __n =
npos)
2228 {
return this->
replace(__pos1, size_type(0), __str._M_data()
2229 + __str._M_check(__pos2,
"basic_string::insert"),
2230 __str._M_limit(__pos2, __n)); }
2248 _GLIBCXX20_CONSTEXPR
2250 insert(size_type __pos,
const _CharT* __s, size_type __n)
2251 {
return this->
replace(__pos, size_type(0), __s, __n); }
2268 _GLIBCXX20_CONSTEXPR
2272 __glibcxx_requires_string(__s);
2273 return this->
replace(__pos, size_type(0), __s,
2274 traits_type::length(__s));
2293 _GLIBCXX20_CONSTEXPR
2295 insert(size_type __pos, size_type __n, _CharT __c)
2296 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2297 size_type(0), __n, __c); }
2312 _GLIBCXX20_CONSTEXPR
2316 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2317 const size_type __pos = __p -
begin();
2318 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2319 return iterator(_M_data() + __pos);
2322#ifdef __glibcxx_string_view
2329 template<
typename _Tp>
2330 _GLIBCXX20_CONSTEXPR
2331 _If_sv<_Tp, basic_string&>
2334 __sv_type __sv = __svt;
2335 return this->
insert(__pos, __sv.data(), __sv.size());
2346 template<
typename _Tp>
2347 _GLIBCXX20_CONSTEXPR
2348 _If_sv<_Tp, basic_string&>
2349 insert(size_type __pos1,
const _Tp& __svt,
2350 size_type __pos2, size_type __n =
npos)
2352 __sv_type __sv = __svt;
2353 return this->
replace(__pos1, size_type(0),
2355 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2356 std::__sv_limit(__sv.size(), __pos2, __n));
2375 _GLIBCXX20_CONSTEXPR
2379 _M_check(__pos,
"basic_string::erase");
2381 this->_M_set_length(__pos);
2383 this->_M_erase(__pos, _M_limit(__pos, __n));
2395 _GLIBCXX20_CONSTEXPR
2399 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2400 && __position <
end());
2401 const size_type __pos = __position -
begin();
2402 this->_M_erase(__pos, size_type(1));
2403 return iterator(_M_data() + __pos);
2415 _GLIBCXX20_CONSTEXPR
2417 erase(__const_iterator __first, __const_iterator __last)
2419 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2420 && __last <=
end());
2421 const size_type __pos = __first -
begin();
2422 if (__last ==
end())
2423 this->_M_set_length(__pos);
2425 this->_M_erase(__pos, __last - __first);
2426 return iterator(this->_M_data() + __pos);
2429#if __cplusplus >= 201103L
2435 _GLIBCXX20_CONSTEXPR
2439 __glibcxx_assert(!
empty());
2440 _M_erase(
size() - 1, 1);
2461 _GLIBCXX20_CONSTEXPR
2464 {
return this->
replace(__pos, __n, __str._M_data(), __str.
size()); }
2484 _GLIBCXX20_CONSTEXPR
2487 size_type __pos2, size_type __n2 =
npos)
2488 {
return this->
replace(__pos1, __n1, __str._M_data()
2489 + __str._M_check(__pos2,
"basic_string::replace"),
2490 __str._M_limit(__pos2, __n2)); }
2510 _GLIBCXX20_CONSTEXPR
2512 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2515 __glibcxx_requires_string_len(__s, __n2);
2516 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2517 _M_limit(__pos, __n1), __s, __n2);
2536 _GLIBCXX20_CONSTEXPR
2538 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2540 __glibcxx_requires_string(__s);
2541 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2561 _GLIBCXX20_CONSTEXPR
2563 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2564 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2565 _M_limit(__pos, __n1), __n2, __c); }
2580 _GLIBCXX20_CONSTEXPR
2582 replace(__const_iterator __i1, __const_iterator __i2,
2584 {
return this->
replace(__i1, __i2, __str._M_data(), __str.
size()); }
2601 _GLIBCXX20_CONSTEXPR
2603 replace(__const_iterator __i1, __const_iterator __i2,
2604 const _CharT* __s, size_type __n)
2606 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2608 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2624 _GLIBCXX20_CONSTEXPR
2626 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2628 __glibcxx_requires_string(__s);
2629 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2646 _GLIBCXX20_CONSTEXPR
2648 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2651 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2653 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2671#if __cplusplus >= 201103L
2672 template<
class _InputIterator,
2673 typename = std::_RequireInputIter<_InputIterator>>
2674 _GLIBCXX20_CONSTEXPR
2677 _InputIterator __k1, _InputIterator __k2)
2679 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2681 __glibcxx_requires_valid_range(__k1, __k2);
2682 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2683 std::__false_type());
2686 template<
class _InputIterator>
2687#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2688 typename __enable_if_not_native_iterator<_InputIterator>::__type
2693 _InputIterator __k1, _InputIterator __k2)
2695 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2697 __glibcxx_requires_valid_range(__k1, __k2);
2698 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2699 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2705 _GLIBCXX20_CONSTEXPR
2707 replace(__const_iterator __i1, __const_iterator __i2,
2708 _CharT* __k1, _CharT* __k2)
2710 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2712 __glibcxx_requires_valid_range(__k1, __k2);
2717 _GLIBCXX20_CONSTEXPR
2719 replace(__const_iterator __i1, __const_iterator __i2,
2720 const _CharT* __k1,
const _CharT* __k2)
2722 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2724 __glibcxx_requires_valid_range(__k1, __k2);
2729 _GLIBCXX20_CONSTEXPR
2731 replace(__const_iterator __i1, __const_iterator __i2,
2732 iterator __k1, iterator __k2)
2734 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2736 __glibcxx_requires_valid_range(__k1, __k2);
2738 __k1.base(), __k2 - __k1);
2741 _GLIBCXX20_CONSTEXPR
2743 replace(__const_iterator __i1, __const_iterator __i2,
2744 const_iterator __k1, const_iterator __k2)
2746 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2748 __glibcxx_requires_valid_range(__k1, __k2);
2750 __k1.base(), __k2 - __k1);
2753#if __glibcxx_containers_ranges
2761 template<__detail::__container_compatible_range<_CharT> _Rg>
2763 replace_with_range(const_iterator __i1, const_iterator __i2, _Rg&& __rg)
2770 _M_get_allocator());
2777#if __cplusplus >= 201103L
2792 _GLIBCXX20_CONSTEXPR
2795 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2798#ifdef __glibcxx_string_view
2806 template<
typename _Tp>
2807 _GLIBCXX20_CONSTEXPR
2808 _If_sv<_Tp, basic_string&>
2811 __sv_type __sv = __svt;
2812 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2824 template<
typename _Tp>
2825 _GLIBCXX20_CONSTEXPR
2826 _If_sv<_Tp, basic_string&>
2827 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2828 size_type __pos2, size_type __n2 =
npos)
2830 __sv_type __sv = __svt;
2831 return this->
replace(__pos1, __n1,
2833 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2834 std::__sv_limit(__sv.size(), __pos2, __n2));
2846 template<
typename _Tp>
2847 _GLIBCXX20_CONSTEXPR
2848 _If_sv<_Tp, basic_string&>
2849 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2851 __sv_type __sv = __svt;
2852 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2857 template<
class _Integer>
2858 _GLIBCXX20_CONSTEXPR
2860 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2861 _Integer __n, _Integer __val, __true_type)
2862 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2864 template<
class _InputIterator>
2865 _GLIBCXX20_CONSTEXPR
2867 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2868 _InputIterator __k1, _InputIterator __k2,
2871 _GLIBCXX20_CONSTEXPR
2873 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2876 __attribute__((__noinline__, __noclone__, __cold__))
void
2877 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2878 const size_type __len2,
const size_type __how_much);
2880 _GLIBCXX20_CONSTEXPR
2882 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2883 const size_type __len2);
2885 _GLIBCXX20_CONSTEXPR
2887 _M_append(
const _CharT* __s, size_type __n);
2903 _GLIBCXX20_CONSTEXPR
2905 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2914 _GLIBCXX20_CONSTEXPR
2925 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2928 {
return _M_data(); }
2938 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2941 {
return _M_data(); }
2943#if __cplusplus >= 201703L
2950 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2953 {
return _M_data(); }
2959 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2962 {
return _M_get_allocator(); }
2976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2978 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2991 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2995 {
return this->
find(__str.
data(), __pos, __str.
size()); }
2997#ifdef __glibcxx_string_view
3004 template<
typename _Tp>
3005 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3006 _If_sv<_Tp, size_type>
3008 noexcept(
is_same<_Tp, __sv_type>::value)
3010 __sv_type __sv = __svt;
3011 return this->
find(__sv.data(), __pos, __sv.size());
3025 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3027 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
3029 __glibcxx_requires_string(__s);
3030 return this->
find(__s, __pos, traits_type::length(__s));
3043 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3045 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
3057 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3061 {
return this->
rfind(__str.data(), __pos, __str.size()); }
3063#ifdef __glibcxx_string_view
3070 template<
typename _Tp>
3071 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3072 _If_sv<_Tp, size_type>
3076 __sv_type __sv = __svt;
3077 return this->
rfind(__sv.data(), __pos, __sv.size());
3093 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3095 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
3108 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3112 __glibcxx_requires_string(__s);
3113 return this->
rfind(__s, __pos, traits_type::length(__s));
3126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3128 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
3141 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3147#ifdef __glibcxx_string_view
3155 template<
typename _Tp>
3156 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3157 _If_sv<_Tp, size_type>
3159 noexcept(
is_same<_Tp, __sv_type>::value)
3161 __sv_type __sv = __svt;
3162 return this->
find_first_of(__sv.data(), __pos, __sv.size());
3178 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3193 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3198 __glibcxx_requires_string(__s);
3199 return this->
find_first_of(__s, __pos, traits_type::length(__s));
3214 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3217 {
return this->
find(__c, __pos); }
3230 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3236#ifdef __glibcxx_string_view
3244 template<
typename _Tp>
3245 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3246 _If_sv<_Tp, size_type>
3250 __sv_type __sv = __svt;
3251 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3267 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3282 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3287 __glibcxx_requires_string(__s);
3288 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3303 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3306 {
return this->
rfind(__c, __pos); }
3318 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3324#ifdef __glibcxx_string_view
3332 template<
typename _Tp>
3333 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3334 _If_sv<_Tp, size_type>
3336 noexcept(
is_same<_Tp, __sv_type>::value)
3338 __sv_type __sv = __svt;
3355 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3358 size_type __n)
const _GLIBCXX_NOEXCEPT;
3370 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3375 __glibcxx_requires_string(__s);
3389 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3405 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3411#ifdef __glibcxx_string_view
3419 template<
typename _Tp>
3420 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3421 _If_sv<_Tp, size_type>
3425 __sv_type __sv = __svt;
3442 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3445 size_type __n)
const _GLIBCXX_NOEXCEPT;
3457 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3462 __glibcxx_requires_string(__s);
3476 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3493 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3497 _M_check(__pos,
"basic_string::substr"), __n); }
3499#if __cplusplus >= 202302L
3507 substr(size_type __pos, size_type __n) &&
3511#ifdef __glibcxx_string_subview
3525 constexpr basic_string_view<_CharT, _Traits>
3527 {
return __sv_type(*this).subview(__pos, __n); }
3544 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3548 const size_type __size = this->
size();
3549 const size_type __osize = __str.
size();
3550 const size_type __len =
std::min(__size, __osize);
3552 int __r = traits_type::compare(_M_data(), __str.
data(), __len);
3554 __r = _S_compare(__size, __osize);
3558#ifdef __glibcxx_string_view
3564 template<
typename _Tp>
3565 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3567 compare(
const _Tp& __svt)
const
3570 __sv_type __sv = __svt;
3572 const size_type __osize = __sv.size();
3575 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3577 __r = _S_compare(__size, __osize);
3589 template<
typename _Tp>
3590 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3592 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3594 __sv_type __sv = __svt;
3595 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3608 template<
typename _Tp>
3609 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3611 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3612 size_type __pos2, size_type __n2 =
npos)
const
3614 __sv_type __sv = __svt;
3615 return __sv_type(*
this)
3616 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3639 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3643 _M_check(__pos,
"basic_string::compare");
3644 __n = _M_limit(__pos, __n);
3645 const size_type __osize = __str.
size();
3646 const size_type __len =
std::min(__n, __osize);
3647 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
3649 __r = _S_compare(__n, __osize);
3676 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3679 size_type __pos2, size_type __n2 =
npos)
const
3681 _M_check(__pos1,
"basic_string::compare");
3682 __str._M_check(__pos2,
"basic_string::compare");
3683 __n1 = _M_limit(__pos1, __n1);
3684 __n2 = __str._M_limit(__pos2, __n2);
3685 const size_type __len =
std::min(__n1, __n2);
3686 int __r = traits_type::compare(_M_data() + __pos1,
3687 __str.
data() + __pos2, __len);
3689 __r = _S_compare(__n1, __n2);
3707 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3709 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3711 __glibcxx_requires_string(__s);
3712 const size_type __size = this->
size();
3713 const size_type __osize = traits_type::length(__s);
3714 const size_type __len =
std::min(__size, __osize);
3715 int __r = traits_type::compare(_M_data(), __s, __len);
3717 __r = _S_compare(__size, __osize);
3742 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3744 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3746 __glibcxx_requires_string(__s);
3747 _M_check(__pos,
"basic_string::compare");
3748 __n1 = _M_limit(__pos, __n1);
3749 const size_type __osize = traits_type::length(__s);
3750 const size_type __len =
std::min(__n1, __osize);
3751 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3753 __r = _S_compare(__n1, __osize);
3781 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3783 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3784 size_type __n2)
const
3786 __glibcxx_requires_string_len(__s, __n2);
3787 _M_check(__pos,
"basic_string::compare");
3788 __n1 = _M_limit(__pos, __n1);
3789 const size_type __len =
std::min(__n1, __n2);
3790 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3792 __r = _S_compare(__n1, __n2);
3796#if __cplusplus >= 202002L
3800 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3804 starts_with(_CharT __x)
const noexcept
3805 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3807 [[nodiscard, __gnu__::__nonnull__]]
3809 starts_with(
const _CharT* __x)
const noexcept
3810 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3814 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3815 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3819 ends_with(_CharT __x)
const noexcept
3820 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3822 [[nodiscard, __gnu__::__nonnull__]]
3824 ends_with(
const _CharT* __x)
const noexcept
3825 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3828#if __cplusplus > 202002L
3831 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3832 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3836 contains(_CharT __x)
const noexcept
3837 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3839 [[nodiscard, __gnu__::__nonnull__]]
3841 contains(
const _CharT* __x)
const noexcept
3842 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3846 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3848_GLIBCXX_END_NAMESPACE_CXX11
3849_GLIBCXX_END_NAMESPACE_VERSION
3853namespace std _GLIBCXX_VISIBILITY(default)
3855_GLIBCXX_BEGIN_NAMESPACE_VERSION
3857#if __cpp_deduction_guides >= 201606
3858_GLIBCXX_BEGIN_NAMESPACE_CXX11
3859 template<
typename _InputIterator,
typename _CharT
3862 typename = _RequireInputIter<_InputIterator>,
3863 typename = _RequireAllocator<_Allocator>>
3864 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3869 template<
typename _CharT,
typename _Traits,
3871 typename = _RequireAllocator<_Allocator>>
3875 template<
typename _CharT,
typename _Traits,
3877 typename = _RequireAllocator<_Allocator>>
3879 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3880 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3881 const _Allocator& = _Allocator())
3884#if __glibcxx_containers_ranges
3887 basic_string(from_range_t, _Rg&&, _Allocator = _Allocator())
3892_GLIBCXX_END_NAMESPACE_CXX11
3895 template<
typename _Str>
3896 _GLIBCXX20_CONSTEXPR
3898 __str_concat(
typename _Str::value_type
const* __lhs,
3899 typename _Str::size_type __lhs_len,
3900 typename _Str::value_type
const* __rhs,
3901 typename _Str::size_type __rhs_len,
3902 typename _Str::allocator_type
const& __a)
3904 typedef typename _Str::allocator_type allocator_type;
3905 typedef __gnu_cxx::__alloc_traits<allocator_type> _Alloc_traits;
3906 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3907 __str.
reserve(__lhs_len + __rhs_len);
3908 __str.
append(__lhs, __lhs_len);
3909 __str.
append(__rhs, __rhs_len);
3920 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3921 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3927 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3938 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3939 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3940 inline basic_string<_CharT,_Traits,_Alloc>
3944 __glibcxx_requires_string(__lhs);
3946 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3957 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3958 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3959 inline basic_string<_CharT,_Traits,_Alloc>
3963 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3974 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3975 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3976 inline basic_string<_CharT, _Traits, _Alloc>
3978 const _CharT* __rhs)
3980 __glibcxx_requires_string(__rhs);
3982 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3983 __rhs, _Traits::length(__rhs),
3992 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3993 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3994 inline basic_string<_CharT, _Traits, _Alloc>
3998 return std::__str_concat<_Str>(__lhs.
c_str(), __lhs.
size(),
3999 __builtin_addressof(__rhs), 1,
4003#if __cplusplus >= 201103L
4004 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4005 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4006 inline basic_string<_CharT, _Traits, _Alloc>
4007 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4008 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4009 {
return std::move(__lhs.append(__rhs)); }
4011 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4012 _GLIBCXX20_CONSTEXPR
4016 {
return std::move(__rhs.insert(0, __lhs)); }
4018 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4024#pragma GCC diagnostic push
4025#pragma GCC diagnostic ignored "-Wc++17-extensions"
4028 bool __use_rhs =
false;
4031 else if (__lhs.get_allocator() == __rhs.get_allocator())
4035 const auto __size = __lhs.size() + __rhs.size();
4036 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
4037 return std::move(__rhs.insert(0, __lhs));
4040#pragma GCC diagnostic pop
4043 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4044 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4048 {
return std::move(__rhs.insert(0, __lhs)); }
4050 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4051 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4055 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4057 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4058 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4061 const _CharT* __rhs)
4062 {
return std::move(__lhs.append(__rhs)); }
4064 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4065 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4069 {
return std::move(__lhs.append(1, __rhs)); }
4072#if __glibcxx_string_view >= 202403L
4074 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4081 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4082 __rhs.data(), __rhs.size(),
4083 __lhs.get_allocator());
4087 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4104 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
4105 __rhs.data(), __rhs.size(),
4106 __rhs.get_allocator());
4110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4116 return std::move(__rhs.insert(0, __lhs));
4127 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4128 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4134 return __lhs.size() == __rhs.size()
4135 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
4144 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4145 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
4148 const _CharT* __rhs)
4150 return __lhs.
size() == _Traits::length(__rhs)
4151 && !_Traits::compare(__lhs.
data(), __rhs, __lhs.
size());
4154#if __cpp_lib_three_way_comparison
4162 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4167 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4168 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4177 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4181 const _CharT* __rhs)
noexcept
4182 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
4183 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
4191 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4194 operator==(
const _CharT* __lhs,
4195 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4196 {
return __rhs == __lhs; }
4205 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4211 {
return !(__lhs == __rhs); }
4219 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4222 operator!=(
const _CharT* __lhs,
4224 {
return !(__rhs == __lhs); }
4232 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4236 const _CharT* __rhs)
4237 {
return !(__lhs == __rhs); }
4246 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4252 {
return __lhs.compare(__rhs) < 0; }
4260 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4264 const _CharT* __rhs)
4265 {
return __lhs.compare(__rhs) < 0; }
4273 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4276 operator<(
const _CharT* __lhs,
4278 {
return __rhs.compare(__lhs) > 0; }
4287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4293 {
return __lhs.compare(__rhs) > 0; }
4301 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4305 const _CharT* __rhs)
4306 {
return __lhs.compare(__rhs) > 0; }
4314 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4317 operator>(
const _CharT* __lhs,
4319 {
return __rhs.compare(__lhs) < 0; }
4328 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4334 {
return __lhs.compare(__rhs) <= 0; }
4342 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4346 const _CharT* __rhs)
4347 {
return __lhs.compare(__rhs) <= 0; }
4355 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4358 operator<=(
const _CharT* __lhs,
4360 {
return __rhs.compare(__lhs) >= 0; }
4369 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4375 {
return __lhs.compare(__rhs) >= 0; }
4383 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4387 const _CharT* __rhs)
4388 {
return __lhs.compare(__rhs) >= 0; }
4396 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4399 operator>=(
const _CharT* __lhs,
4401 {
return __rhs.compare(__lhs) <= 0; }
4411 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4412 _GLIBCXX20_CONSTEXPR
4416 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4417 { __lhs.swap(__rhs); }
4432 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4433 basic_istream<_CharT, _Traits>&
4434 operator>>(basic_istream<_CharT, _Traits>& __is,
4435 basic_string<_CharT, _Traits, _Alloc>& __str);
4438 basic_istream<char>&
4450 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4457 return __ostream_insert(__os, __str.
data(), __str.
size());
4473 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4474 basic_istream<_CharT, _Traits>&
4475 getline(basic_istream<_CharT, _Traits>& __is,
4476 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4490 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4491 inline basic_istream<_CharT, _Traits>&
4496#if __cplusplus >= 201103L
4498 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4499 inline basic_istream<_CharT, _Traits>&
4505 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4506 inline basic_istream<_CharT, _Traits>&
4513 basic_istream<char>&
4514 getline(basic_istream<char>& __in, basic_string<char>& __str,
4517#ifdef _GLIBCXX_USE_WCHAR_T
4519 basic_istream<wchar_t>&
4520 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4524_GLIBCXX_END_NAMESPACE_VERSION
4527#if __cplusplus >= 201103L
4532namespace std _GLIBCXX_VISIBILITY(default)
4534_GLIBCXX_BEGIN_NAMESPACE_VERSION
4535_GLIBCXX_BEGIN_NAMESPACE_CXX11
4539 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4540 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4544 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4545 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4548 inline unsigned long
4549 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4550 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4553#if _GLIBCXX_USE_C99_STDLIB
4555 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4556 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4559 inline unsigned long long
4560 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4561 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4563#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4565 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4566 {
return std::stol(__str, __idx, __base); }
4568 inline unsigned long long
4569 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4570 {
return std::stoul(__str, __idx, __base); }
4574 stod(
const string& __str,
size_t* __idx = 0)
4575 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4577#if _GLIBCXX_HAVE_STRTOF
4580 stof(
const string& __str,
size_t* __idx = 0)
4581 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4584 stof(
const string& __str,
size_t* __idx = 0)
4586 double __d = std::stod(__str, __idx);
4587 if (__builtin_isfinite(__d) && __d != 0.0)
4589 double __abs_d = __builtin_fabs(__d);
4590 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4593 std::__throw_out_of_range(
"stof");
4600#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4602 stold(
const string& __str,
size_t* __idx = 0)
4603 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4604#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4606 stold(
const string& __str,
size_t* __idx = 0)
4607 {
return std::stod(__str, __idx); }
4615 to_string(
int __val)
4616#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4620 const bool __neg = __val < 0;
4621 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4622 const auto __len = __detail::__to_chars_len(__uval);
4624 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4626 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4634 to_string(
unsigned __val)
4635#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4639 const auto __len = __detail::__to_chars_len(__val);
4641 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4642 __detail::__to_chars_10_impl(__p, __n, __val);
4650 to_string(
long __val)
4651#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4655 const bool __neg = __val < 0;
4656 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4657 const auto __len = __detail::__to_chars_len(__uval);
4659 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4661 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4669 to_string(
unsigned long __val)
4670#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
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);
4685 to_string(
long long __val)
4687 const bool __neg = __val < 0;
4688 const unsigned long long __uval
4689 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4690 const auto __len = __detail::__to_chars_len(__uval);
4692 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4694 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4702 to_string(
unsigned long long __val)
4704 const auto __len = __detail::__to_chars_len(__val);
4706 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4707 __detail::__to_chars_10_impl(__p, __n, __val);
4713#if __glibcxx_to_string >= 202306L
4717 to_string(
float __val)
4722 __str.resize_and_overwrite(__len,
4723 [__val, &__len] (
char* __p,
size_t __n) {
4724 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4725 if (__err == errc{}) [[likely]]
4730 }
while (__str.empty());
4736 to_string(
double __val)
4741 __str.resize_and_overwrite(__len,
4742 [__val, &__len] (
char* __p,
size_t __n) {
4743 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4744 if (__err == errc{}) [[likely]]
4749 }
while (__str.empty());
4755 to_string(
long double __val)
4760 __str.resize_and_overwrite(__len,
4761 [__val, &__len] (
char* __p,
size_t __n) {
4762 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4763 if (__err == errc{}) [[likely]]
4768 }
while (__str.empty());
4771#elif _GLIBCXX_USE_C99_STDIO
4772#pragma GCC diagnostic push
4773#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4778 to_string(
float __val)
4781 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4782 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4788 to_string(
double __val)
4791 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4792 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4798 to_string(
long double __val)
4801 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4802 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4805#pragma GCC diagnostic pop
4808#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4810 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4811 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4815 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4816 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4819 inline unsigned long
4820 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4821 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4825 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4826 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4829 inline unsigned long long
4830 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4831 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4836 stof(
const wstring& __str,
size_t* __idx = 0)
4837 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4840 stod(
const wstring& __str,
size_t* __idx = 0)
4841 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4844 stold(
const wstring& __str,
size_t* __idx = 0)
4845 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4848#ifdef _GLIBCXX_USE_WCHAR_T
4849#pragma GCC diagnostic push
4850#pragma GCC diagnostic ignored "-Wc++17-extensions"
4851 _GLIBCXX20_CONSTEXPR
4853 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4857 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4858 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4860 for (
int __i = 0; __i < __len; ++__i)
4861 __wout[__i] = (
wchar_t) __s[__i];
4866 for (
int __i =
'0'; __i <=
'9'; ++__i)
4867 __wc[__i] = L
'0' + __i;
4892 for (
int __i = 0; __i < __len; ++__i)
4893 __wout[__i] = __wc[(
int)__s[__i]];
4897#if __glibcxx_constexpr_string >= 201907L
4901#ifdef __glibcxx_string_view
4902 __to_wstring_numeric(string_view __s)
4904 __to_wstring_numeric(
const string& __s)
4907 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4908 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4909 return wstring(__s.data(), __s.data() + __s.size());
4913 auto __f = __s.data();
4914 __ws.__resize_and_overwrite(__s.size(),
4915 [__f] (
wchar_t* __to,
int __n) {
4916 std::__to_wstring_numeric(__f, __n, __to);
4922#pragma GCC diagnostic pop
4926 to_wstring(
int __val)
4927 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4931 to_wstring(
unsigned __val)
4932 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4936 to_wstring(
long __val)
4937 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4941 to_wstring(
unsigned long __val)
4942 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4946 to_wstring(
long long __val)
4947 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4951 to_wstring(
unsigned long long __val)
4952 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4954#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4957 to_wstring(
float __val)
4958 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4962 to_wstring(
double __val)
4963 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4967 to_wstring(
long double __val)
4968 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4972_GLIBCXX_END_NAMESPACE_CXX11
4973_GLIBCXX_END_NAMESPACE_VERSION
4978#if __cplusplus >= 201103L
4982namespace std _GLIBCXX_VISIBILITY(default)
4984_GLIBCXX_BEGIN_NAMESPACE_VERSION
4989 template<
typename _CharT,
typename _Alloc,
4991 struct __str_hash_base
4992 :
public __hash_base<size_t, _StrT>
4996 operator()(
const _StrT& __s)
const noexcept
4997 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
5000#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5002 template<
typename _Alloc>
5004 :
public __str_hash_base<char, _Alloc>
5008 template<
typename _Alloc>
5010 :
public __str_hash_base<wchar_t, _Alloc>
5013 template<
typename _Alloc>
5020#ifdef _GLIBCXX_USE_CHAR8_T
5022 template<
typename _Alloc>
5023 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
5024 :
public __str_hash_base<char8_t, _Alloc>
5029 template<
typename _Alloc>
5031 :
public __str_hash_base<char16_t, _Alloc>
5035 template<
typename _Alloc>
5037 :
public __str_hash_base<char32_t, _Alloc>
5040#if ! _GLIBCXX_INLINE_VERSION
5046#ifdef _GLIBCXX_USE_CHAR8_T
5051 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5057#ifdef __glibcxx_string_udls
5060 inline namespace string_literals
5062#pragma GCC diagnostic push
5063#pragma GCC diagnostic ignored "-Wliteral-suffix"
5065#if __glibcxx_constexpr_string >= 201907L
5066# define _GLIBCXX_STRING_CONSTEXPR constexpr
5068# define _GLIBCXX_STRING_CONSTEXPR
5071 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5072 inline basic_string<char>
5073 operator""s(
const char* __str,
size_t __len)
5074 {
return basic_string<char>{__str, __len}; }
5076 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5077 inline basic_string<wchar_t>
5078 operator""s(
const wchar_t* __str,
size_t __len)
5079 {
return basic_string<wchar_t>{__str, __len}; }
5081#ifdef _GLIBCXX_USE_CHAR8_T
5082 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5083 inline basic_string<char8_t>
5084 operator""s(
const char8_t* __str,
size_t __len)
5085 {
return basic_string<char8_t>{__str, __len}; }
5088 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5089 inline basic_string<char16_t>
5090 operator""s(
const char16_t* __str,
size_t __len)
5091 {
return basic_string<char16_t>{__str, __len}; }
5093 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
5094 inline basic_string<char32_t>
5095 operator""s(
const char32_t* __str,
size_t __len)
5096 {
return basic_string<char32_t>{__str, __len}; }
5098#undef _GLIBCXX_STRING_CONSTEXPR
5099#pragma GCC diagnostic pop
5104#ifdef __glibcxx_variant
5105 namespace __detail::__variant
5107 template<
typename>
struct _Never_valueless_alt;
5111 template<
typename _Tp,
typename _Traits,
typename _Alloc>
5112 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
5114 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
5115 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
5121_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.
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
static constexpr allocation_result< pointer, size_type > allocate_at_least(_Char_alloc_type &__a, size_type __n)
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 basic_string_view< _CharT, _Traits > subview(size_type __pos=0, size_type __n=npos) const
Get a subview.
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.