34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
38#pragma GCC system_header
44#if __cplusplus >= 201103L
48#if __cplusplus >= 201703L
52#if __cplusplus > 202302L
58#if ! _GLIBCXX_USE_CXX11_ABI
62namespace std _GLIBCXX_VISIBILITY(default)
64_GLIBCXX_BEGIN_NAMESPACE_VERSION
65_GLIBCXX_BEGIN_NAMESPACE_CXX11
87 template<
typename _CharT,
typename _Traits,
typename _Alloc>
90#if __cplusplus >= 202002L
91 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
92 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
93 using _Char_alloc_type = _Alloc;
96 rebind<_CharT>::other _Char_alloc_type;
103 typedef _Traits traits_type;
104 typedef typename _Traits::char_type value_type;
105 typedef _Char_alloc_type allocator_type;
106 typedef typename _Alloc_traits::size_type size_type;
107 typedef typename _Alloc_traits::difference_type difference_type;
108 typedef typename _Alloc_traits::reference reference;
109 typedef typename _Alloc_traits::const_reference const_reference;
110 typedef typename _Alloc_traits::pointer pointer;
111 typedef typename _Alloc_traits::const_pointer const_pointer;
112 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
113 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
119 static const size_type
npos =
static_cast<size_type
>(-1);
123#if __cplusplus < 201103L
124 typedef iterator __const_iterator;
126 typedef const_iterator __const_iterator;
130 static _GLIBCXX20_CONSTEXPR pointer
131 _S_allocate(_Char_alloc_type& __a, size_type __n)
134#if __glibcxx_constexpr_string >= 201907L
137 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
138 if (std::__is_constant_evaluated())
140 for (size_type __i = 0; __i < __n; ++__i)
141 std::construct_at(__builtin_addressof(__p[__i]));
146#if __cplusplus >= 201703L
150 template<
typename _Tp,
typename _Res>
152 __and_<is_convertible<const _Tp&, __sv_type>,
153 __not_<is_convertible<const _Tp*, const basic_string*>>,
154 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
160 _S_to_string_view(__sv_type __svt)
noexcept
169 _GLIBCXX20_CONSTEXPR
explicit
170 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
188 struct _Alloc_hider : allocator_type
190#if __cplusplus < 201103L
191 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
192 : allocator_type(__a), _M_p(__dat) { }
195 _Alloc_hider(pointer __dat,
const _Alloc& __a)
196 : allocator_type(__a), _M_p(__dat) { }
199 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
200 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
206 _Alloc_hider _M_dataplus;
207 size_type _M_string_length;
209 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
213 _CharT _M_local_buf[_S_local_capacity + 1];
214 size_type _M_allocated_capacity;
220 { _M_dataplus._M_p = __p; }
224 _M_length(size_type __length)
225 { _M_string_length = __length; }
230 {
return _M_dataplus._M_p; }
236#if __cplusplus >= 201103L
239 return pointer(_M_local_buf);
245 _M_local_data()
const
247#if __cplusplus >= 201103L
250 return const_pointer(_M_local_buf);
256 _M_capacity(size_type __capacity)
257 { _M_allocated_capacity = __capacity; }
261 _M_set_length(size_type __n)
264 traits_type::assign(_M_data()[__n], _CharT());
271 if (_M_data() == _M_local_data())
273 if (_M_string_length > _S_local_capacity)
274 __builtin_unreachable();
283 _M_create(size_type&, size_type);
290 _M_destroy(_M_allocated_capacity);
295 _M_destroy(size_type __size)
throw()
298#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
301 template<
typename _InIterator>
303 _M_construct_aux(_InIterator __beg, _InIterator __end,
306 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
307 _M_construct(__beg, __end, _Tag());
312 template<
typename _Integer>
314 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
315 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
318 _M_construct_aux_2(size_type __req, _CharT __c)
319 { _M_construct(__req, __c); }
323 template<
typename _InIterator>
326 _M_construct(_InIterator __beg, _InIterator __end,
331 template<
typename _FwdIterator>
334 _M_construct(_FwdIterator __beg, _FwdIterator __end,
339 _M_construct(size_type __req, _CharT __c);
344 {
return _M_dataplus; }
347 const allocator_type&
348 _M_get_allocator()
const
349 {
return _M_dataplus; }
352 __attribute__((__always_inline__))
355 _M_init_local_buf() _GLIBCXX_NOEXCEPT
357#if __glibcxx_is_constant_evaluated
358 if (std::is_constant_evaluated())
359 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
360 _M_local_buf[__i] = _CharT();
364 __attribute__((__always_inline__))
367 _M_use_local_data() _GLIBCXX_NOEXCEPT
369#if __cpp_lib_is_constant_evaluated
372 return _M_local_data();
377#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
380 template<
typename _Tp,
bool _Requires =
381 !__are_same<_Tp, _CharT*>::__value
382 && !__are_same<_Tp, const _CharT*>::__value
383 && !__are_same<_Tp, iterator>::__value
384 && !__are_same<_Tp, const_iterator>::__value>
385 struct __enable_if_not_native_iterator
386 {
typedef basic_string& __type; };
387 template<
typename _Tp>
388 struct __enable_if_not_native_iterator<_Tp, false> { };
393 _M_check(size_type __pos,
const char* __s)
const
395 if (__pos > this->
size())
396 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
397 "this->size() (which is %zu)"),
398 __s, __pos, this->
size());
404 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
407 __throw_length_error(__N(__s));
414 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
416 const bool __testoff = __off < this->
size() - __pos;
417 return __testoff ? __off : this->
size() - __pos;
422 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
424 return (less<const _CharT*>()(__s, _M_data())
425 || less<const _CharT*>()(_M_data() + this->
size(), __s));
432 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
435 traits_type::assign(*__d, *__s);
437 traits_type::copy(__d, __s, __n);
442 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
445 traits_type::assign(*__d, *__s);
447 traits_type::move(__d, __s, __n);
452 _S_assign(_CharT* __d, size_type __n, _CharT __c)
455 traits_type::assign(*__d, __c);
457 traits_type::assign(__d, __n, __c);
462 template<
class _Iterator>
465 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
467 for (; __k1 != __k2; ++__k1, (void)++__p)
468 traits_type::assign(*__p, *__k1);
473 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
474 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
478 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
480 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
484 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
485 { _S_copy(__p, __k1, __k2 - __k1); }
489 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
491 { _S_copy(__p, __k1, __k2 - __k1); }
495 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
497 const difference_type __d = difference_type(__n1 - __n2);
499 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
500 return __gnu_cxx::__numeric_traits<int>::__max;
501 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
502 return __gnu_cxx::__numeric_traits<int>::__min;
513 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
518 _M_erase(size_type __pos, size_type __n);
531#if __cpp_concepts && __glibcxx_type_trait_variable_templates
532 requires is_default_constructible_v<_Alloc>
534 : _M_dataplus(_M_local_data())
546 : _M_dataplus(_M_local_data(), __a)
558 : _M_dataplus(_M_local_data(),
561 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
575 const _Alloc& __a = _Alloc())
576 : _M_dataplus(_M_local_data(), __a)
578 const _CharT* __start = __str._M_data()
579 + __str._M_check(__pos,
"basic_string::basic_string");
580 _M_construct(__start, __start + __str._M_limit(__pos,
npos),
593 : _M_dataplus(_M_local_data())
595 const _CharT* __start = __str._M_data()
596 + __str._M_check(__pos,
"basic_string::basic_string");
597 _M_construct(__start, __start + __str._M_limit(__pos, __n),
610 size_type __n,
const _Alloc& __a)
611 : _M_dataplus(_M_local_data(), __a)
613 const _CharT* __start
614 = __str._M_data() + __str._M_check(__pos,
"string::string");
615 _M_construct(__start, __start + __str._M_limit(__pos, __n),
630 const _Alloc& __a = _Alloc())
631 : _M_dataplus(_M_local_data(), __a)
634 if (__s == 0 && __n > 0)
635 std::__throw_logic_error(__N(
"basic_string: "
636 "construction from null is not valid"));
645#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
648 template<
typename = _RequireAllocator<_Alloc>>
652 : _M_dataplus(_M_local_data(), __a)
656 std::__throw_logic_error(__N(
"basic_string: "
657 "construction from null is not valid"));
658 const _CharT* __end = __s + traits_type::length(__s);
668#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
671 template<
typename = _RequireAllocator<_Alloc>>
675 : _M_dataplus(_M_local_data(), __a)
676 { _M_construct(__n, __c); }
678#if __cplusplus >= 201103L
688 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
690 if (__str._M_is_local())
693 traits_type::copy(_M_local_buf, __str._M_local_buf,
698 _M_data(__str._M_data());
699 _M_capacity(__str._M_allocated_capacity);
705 _M_length(__str.length());
706 __str._M_data(__str._M_use_local_data());
707 __str._M_set_length(0);
717 : _M_dataplus(_M_local_data(), __a)
722 : _M_dataplus(_M_local_data(), __a)
727 noexcept(_Alloc_traits::_S_always_equal())
728 : _M_dataplus(_M_local_data(), __a)
730 if (__str._M_is_local())
733 traits_type::copy(_M_local_buf, __str._M_local_buf,
735 _M_length(__str.length());
736 __str._M_set_length(0);
738 else if (_Alloc_traits::_S_always_equal()
739 || __str.get_allocator() == __a)
741 _M_data(__str._M_data());
742 _M_length(__str.length());
743 _M_capacity(__str._M_allocated_capacity);
744 __str._M_data(__str._M_use_local_data());
745 __str._M_set_length(0);
752#if __cplusplus >= 202100L
763#if __cplusplus >= 201103L
764 template<
typename _InputIterator,
765 typename = std::_RequireInputIter<_InputIterator>>
767 template<
typename _InputIterator>
771 const _Alloc& __a = _Alloc())
772 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
774#if __cplusplus >= 201103L
777 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
778 _M_construct_aux(__beg, __end, _Integral());
782#if __cplusplus >= 201703L
790 template<
typename _Tp,
794 const _Alloc& __a = _Alloc())
802 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
806 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
824 return this->
assign(__str);
834 {
return this->
assign(__s); }
851#if __cplusplus >= 201103L
864 noexcept(_Alloc_traits::_S_nothrow_move())
866 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
867 || _M_get_allocator() == __str._M_get_allocator();
868 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
872 _M_destroy(_M_allocated_capacity);
873 _M_data(_M_local_data());
877 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
879 if (__str._M_is_local())
887 this->_S_copy(_M_data(), __str._M_data(), __str.size());
888 _M_set_length(__str.size());
891 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
894 pointer __data =
nullptr;
895 size_type __capacity;
902 __capacity = _M_allocated_capacity;
905 _M_destroy(_M_allocated_capacity);
908 _M_data(__str._M_data());
909 _M_length(__str.length());
910 _M_capacity(__str._M_allocated_capacity);
913 __str._M_data(__data);
914 __str._M_capacity(__capacity);
917 __str._M_data(__str._M_use_local_data());
933 this->
assign(__l.begin(), __l.size());
938#if __cplusplus >= 201703L
943 template<
typename _Tp>
945 _If_sv<_Tp, basic_string&>
947 {
return this->
assign(__svt); }
963 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
966 {
return iterator(_M_data()); }
972 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
975 {
return const_iterator(_M_data()); }
981 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
984 {
return iterator(_M_data() + this->
size()); }
990 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
992 end() const _GLIBCXX_NOEXCEPT
993 {
return const_iterator(_M_data() + this->
size()); }
1000 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1010 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1011 const_reverse_iterator
1020 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1030 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1031 const_reverse_iterator
1035#if __cplusplus >= 201103L
1040 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1043 {
return const_iterator(this->_M_data()); }
1049 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1052 {
return const_iterator(this->_M_data() + this->
size()); }
1059 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1060 const_reverse_iterator
1069 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1070 const_reverse_iterator
1079 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1083 size_type __sz = _M_string_length;
1085 __builtin_unreachable ();
1091 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1097 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1101 const size_t __diffmax
1102 = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max /
sizeof(_CharT);
1104 return (
std::min)(__diffmax, __allocmax) - 1;
1117 _GLIBCXX20_CONSTEXPR
1119 resize(size_type __n, _CharT __c);
1131 _GLIBCXX20_CONSTEXPR
1134 { this->
resize(__n, _CharT()); }
1136#if __cplusplus >= 201103L
1137#pragma GCC diagnostic push
1138#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1140 _GLIBCXX20_CONSTEXPR
1144#pragma GCC diagnostic pop
1147#ifdef __glibcxx_string_resize_and_overwrite
1177 template<
typename _Operation>
1179 resize_and_overwrite(size_type __n, _Operation __op);
1182#if __cplusplus >= 201103L
1184 template<
typename _Operation>
1185 _GLIBCXX20_CONSTEXPR
void
1193 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1197 size_t __sz = _M_is_local() ? size_type(_S_local_capacity)
1198 : _M_allocated_capacity;
1199 if (__sz < _S_local_capacity || __sz >
max_size ())
1200 __builtin_unreachable ();
1221 _GLIBCXX20_CONSTEXPR
1228#if __cplusplus > 201703L
1229 [[deprecated(
"use shrink_to_fit() instead")]]
1231 _GLIBCXX20_CONSTEXPR
1238 _GLIBCXX20_CONSTEXPR
1241 { _M_set_length(0); }
1247 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1250 {
return _M_string_length == 0; }
1263 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1267 __glibcxx_assert(__pos <=
size());
1268 return _M_data()[__pos];
1281 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1287 __glibcxx_assert(__pos <=
size());
1289 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1290 return _M_data()[__pos];
1303 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1307 if (__n >= this->
size())
1308 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1309 "(which is %zu) >= this->size() "
1312 return _M_data()[__n];
1325 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1330 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1331 "(which is %zu) >= this->size() "
1334 return _M_data()[__n];
1337#if __cplusplus >= 201103L
1342 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1346 __glibcxx_assert(!
empty());
1354 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1358 __glibcxx_assert(!
empty());
1366 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1370 __glibcxx_assert(!
empty());
1378 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1382 __glibcxx_assert(!
empty());
1393 _GLIBCXX20_CONSTEXPR
1396 {
return this->
append(__str); }
1403 _GLIBCXX20_CONSTEXPR
1406 {
return this->
append(__s); }
1413 _GLIBCXX20_CONSTEXPR
1421#if __cplusplus >= 201103L
1427 _GLIBCXX20_CONSTEXPR
1430 {
return this->
append(__l.begin(), __l.size()); }
1433#if __cplusplus >= 201703L
1439 template<
typename _Tp>
1440 _GLIBCXX20_CONSTEXPR
1441 _If_sv<_Tp, basic_string&>
1443 {
return this->
append(__svt); }
1451 _GLIBCXX20_CONSTEXPR
1454 {
return this->
append(__str._M_data(), __str.size()); }
1469 _GLIBCXX20_CONSTEXPR
1472 {
return this->
append(__str._M_data()
1473 + __str._M_check(__pos,
"basic_string::append"),
1474 __str._M_limit(__pos, __n)); }
1482 _GLIBCXX20_CONSTEXPR
1486 __glibcxx_requires_string_len(__s, __n);
1487 _M_check_length(size_type(0), __n,
"basic_string::append");
1488 return _M_append(__s, __n);
1496 _GLIBCXX20_CONSTEXPR
1500 __glibcxx_requires_string(__s);
1501 const size_type __n = traits_type::length(__s);
1502 _M_check_length(size_type(0), __n,
"basic_string::append");
1503 return _M_append(__s, __n);
1514 _GLIBCXX20_CONSTEXPR
1517 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1519#if __cplusplus >= 201103L
1525 _GLIBCXX20_CONSTEXPR
1528 {
return this->
append(__l.begin(), __l.size()); }
1539#if __cplusplus >= 201103L
1540 template<
class _InputIterator,
1541 typename = std::_RequireInputIter<_InputIterator>>
1542 _GLIBCXX20_CONSTEXPR
1544 template<
class _InputIterator>
1547 append(_InputIterator __first, _InputIterator __last)
1550#if __cplusplus >= 201703L
1556 template<
typename _Tp>
1557 _GLIBCXX20_CONSTEXPR
1558 _If_sv<_Tp, basic_string&>
1562 return this->
append(__sv.data(), __sv.size());
1572 template<
typename _Tp>
1573 _GLIBCXX20_CONSTEXPR
1574 _If_sv<_Tp, basic_string&>
1578 return _M_append(__sv.data()
1579 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1580 std::__sv_limit(__sv.size(), __pos, __n));
1588 _GLIBCXX20_CONSTEXPR
1592 const size_type __size = this->
size();
1594 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1595 traits_type::assign(this->_M_data()[__size], __c);
1596 this->_M_set_length(__size + 1);
1604 _GLIBCXX20_CONSTEXPR
1608#if __cplusplus >= 201103L
1609 if (_Alloc_traits::_S_propagate_on_copy_assign())
1611 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1612 && _M_get_allocator() != __str._M_get_allocator())
1616 if (__str.size() <= _S_local_capacity)
1618 _M_destroy(_M_allocated_capacity);
1619 _M_data(_M_use_local_data());
1624 const auto __len = __str.size();
1625 auto __alloc = __str._M_get_allocator();
1627 auto __ptr = _S_allocate(__alloc, __len + 1);
1628 _M_destroy(_M_allocated_capacity);
1631 _M_set_length(__len);
1634 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1637 this->_M_assign(__str);
1641#if __cplusplus >= 201103L
1650 _GLIBCXX20_CONSTEXPR
1653 noexcept(_Alloc_traits::_S_nothrow_move())
1674 _GLIBCXX20_CONSTEXPR
1677 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1678 + __str._M_check(__pos,
"basic_string::assign"),
1679 __str._M_limit(__pos, __n)); }
1691 _GLIBCXX20_CONSTEXPR
1695 __glibcxx_requires_string_len(__s, __n);
1696 return _M_replace(size_type(0), this->
size(), __s, __n);
1708 _GLIBCXX20_CONSTEXPR
1712 __glibcxx_requires_string(__s);
1713 return _M_replace(size_type(0), this->
size(), __s,
1714 traits_type::length(__s));
1726 _GLIBCXX20_CONSTEXPR
1729 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1739#if __cplusplus >= 201103L
1740#pragma GCC diagnostic push
1741#pragma GCC diagnostic ignored "-Wc++17-extensions"
1742 template<
class _InputIterator,
1743 typename = std::_RequireInputIter<_InputIterator>>
1744 _GLIBCXX20_CONSTEXPR
1746 assign(_InputIterator __first, _InputIterator __last)
1749 if constexpr (
is_pointer<
decltype(std::__niter_base(__first))>::value
1750 &&
is_same<
typename _IterTraits::value_type,
1753 __glibcxx_requires_valid_range(__first, __last);
1754 return _M_replace(size_type(0),
size(),
1755 std::__niter_base(__first), __last - __first);
1757#if __cplusplus >= 202002L
1758 else if constexpr (contiguous_iterator<_InputIterator>
1759 && is_same_v<iter_value_t<_InputIterator>,
1762 __glibcxx_requires_valid_range(__first, __last);
1763 return _M_replace(size_type(0),
size(),
1770#pragma GCC diagnostic pop
1772 template<
class _InputIterator>
1774 assign(_InputIterator __first, _InputIterator __last)
1778#if __cplusplus >= 201103L
1784 _GLIBCXX20_CONSTEXPR
1790 const size_type __n = __l.size();
1796 _S_copy(_M_data(), __l.begin(), __n);
1803#if __cplusplus >= 201703L
1809 template<
typename _Tp>
1810 _GLIBCXX20_CONSTEXPR
1811 _If_sv<_Tp, basic_string&>
1815 return this->
assign(__sv.data(), __sv.size());
1825 template<
typename _Tp>
1826 _GLIBCXX20_CONSTEXPR
1827 _If_sv<_Tp, basic_string&>
1831 return _M_replace(size_type(0), this->
size(),
1833 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1834 std::__sv_limit(__sv.size(), __pos, __n));
1838#if __cplusplus >= 201103L
1854 _GLIBCXX20_CONSTEXPR
1856 insert(const_iterator __p, size_type __n, _CharT __c)
1858 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1859 const size_type __pos = __p -
begin();
1860 this->
replace(__p, __p, __n, __c);
1861 return iterator(this->_M_data() + __pos);
1879 { this->
replace(__p, __p, __n, __c); }
1882#if __cplusplus >= 201103L
1897 template<
class _InputIterator,
1898 typename = std::_RequireInputIter<_InputIterator>>
1899 _GLIBCXX20_CONSTEXPR
1901 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1903 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1904 const size_type __pos = __p -
begin();
1905 this->
replace(__p, __p, __beg, __end);
1906 return iterator(this->_M_data() + __pos);
1921 template<
class _InputIterator>
1924 { this->
replace(__p, __p, __beg, __end); }
1927#if __cplusplus >= 201103L
1934 _GLIBCXX20_CONSTEXPR
1937 {
return this->
insert(__p, __l.begin(), __l.end()); }
1939#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1944 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1945 this->
insert(__p -
begin(), __l.begin(), __l.size());
1962 _GLIBCXX20_CONSTEXPR
1965 {
return this->
replace(__pos1, size_type(0),
1966 __str._M_data(), __str.size()); }
1986 _GLIBCXX20_CONSTEXPR
1989 size_type __pos2, size_type __n =
npos)
1990 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1991 + __str._M_check(__pos2,
"basic_string::insert"),
1992 __str._M_limit(__pos2, __n)); }
2010 _GLIBCXX20_CONSTEXPR
2012 insert(size_type __pos,
const _CharT* __s, size_type __n)
2013 {
return this->
replace(__pos, size_type(0), __s, __n); }
2030 _GLIBCXX20_CONSTEXPR
2034 __glibcxx_requires_string(__s);
2035 return this->
replace(__pos, size_type(0), __s,
2036 traits_type::length(__s));
2055 _GLIBCXX20_CONSTEXPR
2057 insert(size_type __pos, size_type __n, _CharT __c)
2058 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
2059 size_type(0), __n, __c); }
2074 _GLIBCXX20_CONSTEXPR
2078 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
2079 const size_type __pos = __p -
begin();
2080 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2081 return iterator(_M_data() + __pos);
2084#if __cplusplus >= 201703L
2091 template<
typename _Tp>
2092 _GLIBCXX20_CONSTEXPR
2093 _If_sv<_Tp, basic_string&>
2097 return this->
insert(__pos, __sv.data(), __sv.size());
2108 template<
typename _Tp>
2109 _GLIBCXX20_CONSTEXPR
2110 _If_sv<_Tp, basic_string&>
2112 size_type __pos2, size_type __n =
npos)
2115 return this->
replace(__pos1, size_type(0),
2117 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
2118 std::__sv_limit(__sv.size(), __pos2, __n));
2137 _GLIBCXX20_CONSTEXPR
2141 _M_check(__pos,
"basic_string::erase");
2143 this->_M_set_length(__pos);
2145 this->_M_erase(__pos, _M_limit(__pos, __n));
2157 _GLIBCXX20_CONSTEXPR
2161 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
2162 && __position <
end());
2163 const size_type __pos = __position -
begin();
2164 this->_M_erase(__pos, size_type(1));
2165 return iterator(_M_data() + __pos);
2177 _GLIBCXX20_CONSTEXPR
2179 erase(__const_iterator __first, __const_iterator __last)
2181 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
2182 && __last <=
end());
2183 const size_type __pos = __first -
begin();
2184 if (__last ==
end())
2185 this->_M_set_length(__pos);
2187 this->_M_erase(__pos, __last - __first);
2188 return iterator(this->_M_data() + __pos);
2191#if __cplusplus >= 201103L
2197 _GLIBCXX20_CONSTEXPR
2201 __glibcxx_assert(!
empty());
2202 _M_erase(
size() - 1, 1);
2223 _GLIBCXX20_CONSTEXPR
2226 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
2246 _GLIBCXX20_CONSTEXPR
2249 size_type __pos2, size_type __n2 =
npos)
2250 {
return this->
replace(__pos1, __n1, __str._M_data()
2251 + __str._M_check(__pos2,
"basic_string::replace"),
2252 __str._M_limit(__pos2, __n2)); }
2272 _GLIBCXX20_CONSTEXPR
2274 replace(size_type __pos, size_type __n1,
const _CharT* __s,
2277 __glibcxx_requires_string_len(__s, __n2);
2278 return _M_replace(_M_check(__pos,
"basic_string::replace"),
2279 _M_limit(__pos, __n1), __s, __n2);
2298 _GLIBCXX20_CONSTEXPR
2300 replace(size_type __pos, size_type __n1,
const _CharT* __s)
2302 __glibcxx_requires_string(__s);
2303 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2323 _GLIBCXX20_CONSTEXPR
2325 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2326 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2327 _M_limit(__pos, __n1), __n2, __c); }
2342 _GLIBCXX20_CONSTEXPR
2344 replace(__const_iterator __i1, __const_iterator __i2,
2346 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2363 _GLIBCXX20_CONSTEXPR
2365 replace(__const_iterator __i1, __const_iterator __i2,
2366 const _CharT* __s, size_type __n)
2368 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2370 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2386 _GLIBCXX20_CONSTEXPR
2388 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2390 __glibcxx_requires_string(__s);
2391 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2408 _GLIBCXX20_CONSTEXPR
2410 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2413 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2415 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2433#if __cplusplus >= 201103L
2434 template<
class _InputIterator,
2435 typename = std::_RequireInputIter<_InputIterator>>
2436 _GLIBCXX20_CONSTEXPR
2439 _InputIterator __k1, _InputIterator __k2)
2441 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2443 __glibcxx_requires_valid_range(__k1, __k2);
2444 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2445 std::__false_type());
2448 template<
class _InputIterator>
2449#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2450 typename __enable_if_not_native_iterator<_InputIterator>::__type
2455 _InputIterator __k1, _InputIterator __k2)
2457 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2459 __glibcxx_requires_valid_range(__k1, __k2);
2460 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2461 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2467 _GLIBCXX20_CONSTEXPR
2469 replace(__const_iterator __i1, __const_iterator __i2,
2470 _CharT* __k1, _CharT* __k2)
2472 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2474 __glibcxx_requires_valid_range(__k1, __k2);
2479 _GLIBCXX20_CONSTEXPR
2481 replace(__const_iterator __i1, __const_iterator __i2,
2482 const _CharT* __k1,
const _CharT* __k2)
2484 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2486 __glibcxx_requires_valid_range(__k1, __k2);
2491 _GLIBCXX20_CONSTEXPR
2493 replace(__const_iterator __i1, __const_iterator __i2,
2494 iterator __k1, iterator __k2)
2496 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2498 __glibcxx_requires_valid_range(__k1, __k2);
2500 __k1.base(), __k2 - __k1);
2503 _GLIBCXX20_CONSTEXPR
2505 replace(__const_iterator __i1, __const_iterator __i2,
2506 const_iterator __k1, const_iterator __k2)
2508 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2510 __glibcxx_requires_valid_range(__k1, __k2);
2512 __k1.base(), __k2 - __k1);
2515#if __cplusplus >= 201103L
2530 _GLIBCXX20_CONSTEXPR
2533 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2536#if __cplusplus >= 201703L
2544 template<
typename _Tp>
2545 _GLIBCXX20_CONSTEXPR
2546 _If_sv<_Tp, basic_string&>
2547 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2550 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2562 template<
typename _Tp>
2563 _GLIBCXX20_CONSTEXPR
2564 _If_sv<_Tp, basic_string&>
2565 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2566 size_type __pos2, size_type __n2 =
npos)
2569 return this->
replace(__pos1, __n1,
2571 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2572 std::__sv_limit(__sv.size(), __pos2, __n2));
2584 template<
typename _Tp>
2585 _GLIBCXX20_CONSTEXPR
2586 _If_sv<_Tp, basic_string&>
2587 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2590 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2595 template<
class _Integer>
2596 _GLIBCXX20_CONSTEXPR
2598 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2599 _Integer __n, _Integer __val, __true_type)
2600 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2602 template<
class _InputIterator>
2603 _GLIBCXX20_CONSTEXPR
2605 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2606 _InputIterator __k1, _InputIterator __k2,
2609 _GLIBCXX20_CONSTEXPR
2611 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2614 __attribute__((__noinline__, __noclone__, __cold__))
void
2615 _M_replace_cold(pointer __p, size_type __len1,
const _CharT* __s,
2616 const size_type __len2,
const size_type __how_much);
2618 _GLIBCXX20_CONSTEXPR
2620 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2621 const size_type __len2);
2623 _GLIBCXX20_CONSTEXPR
2625 _M_append(
const _CharT* __s, size_type __n);
2641 _GLIBCXX20_CONSTEXPR
2643 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2652 _GLIBCXX20_CONSTEXPR
2663 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2666 {
return _M_data(); }
2676 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2679 {
return _M_data(); }
2681#if __cplusplus >= 201703L
2688 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2691 {
return _M_data(); }
2697 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2700 {
return _M_get_allocator(); }
2714 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2716 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2729 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2733 {
return this->
find(__str.data(), __pos, __str.size()); }
2735#if __cplusplus >= 201703L
2742 template<
typename _Tp>
2743 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2744 _If_sv<_Tp, size_type>
2745 find(
const _Tp& __svt, size_type __pos = 0) const
2749 return this->
find(__sv.data(), __pos, __sv.size());
2763 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2765 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2767 __glibcxx_requires_string(__s);
2768 return this->
find(__s, __pos, traits_type::length(__s));
2781 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2783 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2795 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2799 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2801#if __cplusplus >= 201703L
2808 template<
typename _Tp>
2809 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2810 _If_sv<_Tp, size_type>
2815 return this->
rfind(__sv.data(), __pos, __sv.size());
2831 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2833 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2846 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2850 __glibcxx_requires_string(__s);
2851 return this->
rfind(__s, __pos, traits_type::length(__s));
2864 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2866 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2879 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2883 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2885#if __cplusplus >= 201703L
2893 template<
typename _Tp>
2894 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2895 _If_sv<_Tp, size_type>
2900 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2916 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2918 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2931 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2936 __glibcxx_requires_string(__s);
2937 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2952 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2955 {
return this->
find(__c, __pos); }
2968 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2972 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2974#if __cplusplus >= 201703L
2982 template<
typename _Tp>
2983 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2984 _If_sv<_Tp, size_type>
2989 return this->
find_last_of(__sv.data(), __pos, __sv.size());
3005 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3007 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
3020 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3025 __glibcxx_requires_string(__s);
3026 return this->
find_last_of(__s, __pos, traits_type::length(__s));
3041 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3044 {
return this->
rfind(__c, __pos); }
3056 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3062#if __cplusplus >= 201703L
3070 template<
typename _Tp>
3071 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3072 _If_sv<_Tp, size_type>
3093 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3096 size_type __n)
const _GLIBCXX_NOEXCEPT;
3108 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3113 __glibcxx_requires_string(__s);
3127 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3143 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3149#if __cplusplus >= 201703L
3157 template<
typename _Tp>
3158 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3159 _If_sv<_Tp, size_type>
3180 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3183 size_type __n)
const _GLIBCXX_NOEXCEPT;
3195 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3200 __glibcxx_requires_string(__s);
3214 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3231 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3235 _M_check(__pos,
"basic_string::substr"), __n); }
3251 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3255 const size_type __size = this->
size();
3256 const size_type __osize = __str.size();
3257 const size_type __len =
std::min(__size, __osize);
3259 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3261 __r = _S_compare(__size, __osize);
3265#if __cplusplus >= 201703L
3271 template<
typename _Tp>
3272 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3278 const size_type __size = this->
size();
3279 const size_type __osize = __sv.size();
3280 const size_type __len =
std::min(__size, __osize);
3282 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3284 __r = _S_compare(__size, __osize);
3296 template<
typename _Tp>
3297 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3299 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
3303 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3316 template<
typename _Tp>
3317 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3319 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
3320 size_type __pos2, size_type __n2 =
npos)
const
3325 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3348 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3352 _M_check(__pos,
"basic_string::compare");
3353 __n = _M_limit(__pos, __n);
3354 const size_type __osize = __str.size();
3355 const size_type __len =
std::min(__n, __osize);
3356 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3358 __r = _S_compare(__n, __osize);
3385 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3388 size_type __pos2, size_type __n2 =
npos)
const
3390 _M_check(__pos1,
"basic_string::compare");
3391 __str._M_check(__pos2,
"basic_string::compare");
3392 __n1 = _M_limit(__pos1, __n1);
3393 __n2 = __str._M_limit(__pos2, __n2);
3394 const size_type __len =
std::min(__n1, __n2);
3395 int __r = traits_type::compare(_M_data() + __pos1,
3396 __str.data() + __pos2, __len);
3398 __r = _S_compare(__n1, __n2);
3416 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3418 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3420 __glibcxx_requires_string(__s);
3421 const size_type __size = this->
size();
3422 const size_type __osize = traits_type::length(__s);
3423 const size_type __len =
std::min(__size, __osize);
3424 int __r = traits_type::compare(_M_data(), __s, __len);
3426 __r = _S_compare(__size, __osize);
3451 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3453 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
3455 __glibcxx_requires_string(__s);
3456 _M_check(__pos,
"basic_string::compare");
3457 __n1 = _M_limit(__pos, __n1);
3458 const size_type __osize = traits_type::length(__s);
3459 const size_type __len =
std::min(__n1, __osize);
3460 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3462 __r = _S_compare(__n1, __osize);
3490 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3492 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3493 size_type __n2)
const
3495 __glibcxx_requires_string_len(__s, __n2);
3496 _M_check(__pos,
"basic_string::compare");
3497 __n1 = _M_limit(__pos, __n1);
3498 const size_type __len =
std::min(__n1, __n2);
3499 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3501 __r = _S_compare(__n1, __n2);
3505#if __cplusplus >= 202002L
3509 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3513 starts_with(_CharT __x)
const noexcept
3514 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3516 [[nodiscard, __gnu__::__nonnull__]]
3518 starts_with(
const _CharT* __x)
const noexcept
3519 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3523 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3524 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3528 ends_with(_CharT __x)
const noexcept
3529 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3531 [[nodiscard, __gnu__::__nonnull__]]
3533 ends_with(
const _CharT* __x)
const noexcept
3534 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3537#if __cplusplus > 202002L
3540 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3541 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3545 contains(_CharT __x)
const noexcept
3546 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3548 [[nodiscard, __gnu__::__nonnull__]]
3550 contains(
const _CharT* __x)
const noexcept
3551 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3555 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3557_GLIBCXX_END_NAMESPACE_CXX11
3558_GLIBCXX_END_NAMESPACE_VERSION
3562namespace std _GLIBCXX_VISIBILITY(default)
3564_GLIBCXX_BEGIN_NAMESPACE_VERSION
3566#if __cpp_deduction_guides >= 201606
3567_GLIBCXX_BEGIN_NAMESPACE_CXX11
3568 template<
typename _InputIterator,
typename _CharT
3569 =
typename iterator_traits<_InputIterator>::value_type,
3570 typename _Allocator = allocator<_CharT>,
3571 typename = _RequireInputIter<_InputIterator>,
3572 typename = _RequireAllocator<_Allocator>>
3573 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3574 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3578 template<
typename _CharT,
typename _Traits,
3579 typename _Allocator = allocator<_CharT>,
3580 typename = _RequireAllocator<_Allocator>>
3581 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
3582 -> basic_string<_CharT, _Traits, _Allocator>;
3584 template<
typename _CharT,
typename _Traits,
3585 typename _Allocator = allocator<_CharT>,
3586 typename = _RequireAllocator<_Allocator>>
3587 basic_string(basic_string_view<_CharT, _Traits>,
3588 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3589 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3590 const _Allocator& = _Allocator())
3591 -> basic_string<_CharT, _Traits, _Allocator>;
3592_GLIBCXX_END_NAMESPACE_CXX11
3595 template<
typename _Str>
3596 _GLIBCXX20_CONSTEXPR
3598 __str_concat(
typename _Str::value_type
const* __lhs,
3599 typename _Str::size_type __lhs_len,
3600 typename _Str::value_type
const* __rhs,
3601 typename _Str::size_type __rhs_len,
3602 typename _Str::allocator_type
const& __a)
3604 typedef typename _Str::allocator_type allocator_type;
3606 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3607 __str.reserve(__lhs_len + __rhs_len);
3608 __str.append(__lhs, __lhs_len);
3609 __str.append(__rhs, __rhs_len);
3620 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3621 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3622 inline basic_string<_CharT, _Traits, _Alloc>
3627 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3628 __rhs.c_str(), __rhs.size(),
3629 __lhs.get_allocator());
3638 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3639 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3640 inline basic_string<_CharT,_Traits,_Alloc>
3644 __glibcxx_requires_string(__lhs);
3646 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3647 __rhs.c_str(), __rhs.size(),
3648 __rhs.get_allocator());
3657 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3658 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3659 inline basic_string<_CharT,_Traits,_Alloc>
3663 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3664 __rhs.c_str(), __rhs.size(),
3665 __rhs.get_allocator());
3674 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3675 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3676 inline basic_string<_CharT, _Traits, _Alloc>
3678 const _CharT* __rhs)
3680 __glibcxx_requires_string(__rhs);
3682 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3683 __rhs, _Traits::length(__rhs),
3684 __lhs.get_allocator());
3692 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3693 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3694 inline basic_string<_CharT, _Traits, _Alloc>
3698 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3699 __builtin_addressof(__rhs), 1,
3700 __lhs.get_allocator());
3703#if __cplusplus >= 201103L
3704 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3705 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3706 inline basic_string<_CharT, _Traits, _Alloc>
3707 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3708 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3709 {
return std::move(__lhs.append(__rhs)); }
3711 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3712 _GLIBCXX20_CONSTEXPR
3713 inline basic_string<_CharT, _Traits, _Alloc>
3714 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3715 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3716 {
return std::move(__rhs.insert(0, __lhs)); }
3718 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3719 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3720 inline basic_string<_CharT, _Traits, _Alloc>
3721 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3722 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3724#if _GLIBCXX_USE_CXX11_ABI
3725 using _Alloc_traits = allocator_traits<_Alloc>;
3726 bool __use_rhs =
false;
3727 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
3729 else if (__lhs.get_allocator() == __rhs.get_allocator())
3734 const auto __size = __lhs.size() + __rhs.size();
3735 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3736 return std::move(__rhs.insert(0, __lhs));
3741 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3742 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3743 inline basic_string<_CharT, _Traits, _Alloc>
3745 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3746 {
return std::move(__rhs.insert(0, __lhs)); }
3748 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3749 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3750 inline basic_string<_CharT, _Traits, _Alloc>
3752 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3753 {
return std::move(__rhs.insert(0, 1, __lhs)); }
3755 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3756 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3757 inline basic_string<_CharT, _Traits, _Alloc>
3758 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3759 const _CharT* __rhs)
3760 {
return std::move(__lhs.append(__rhs)); }
3762 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3763 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3764 inline basic_string<_CharT, _Traits, _Alloc>
3765 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3767 {
return std::move(__lhs.append(1, __rhs)); }
3770#if __glibcxx_string_view >= 202403L
3772 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3774 constexpr basic_string<_CharT, _Traits, _Alloc>
3775 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3776 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs)
3778 using _Str = basic_string<_CharT, _Traits, _Alloc>;
3779 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
3780 __rhs.data(), __rhs.size(),
3781 __lhs.get_allocator());
3785 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3787 constexpr basic_string<_CharT, _Traits, _Alloc>
3788 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3789 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs)
3795 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3797 constexpr basic_string<_CharT, _Traits, _Alloc>
3798 operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
3799 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3801 using _Str = basic_string<_CharT, _Traits, _Alloc>;
3802 return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
3803 __rhs.data(), __rhs.size(),
3804 __rhs.get_allocator());
3808 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3810 constexpr basic_string<_CharT, _Traits, _Alloc>
3811 operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
3812 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3814 return std::move(__rhs.insert(0, __lhs));
3825 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3826 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3832 return __lhs.size() == __rhs.size()
3833 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3842 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3843 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3846 const _CharT* __rhs)
3848 return __lhs.size() == _Traits::length(__rhs)
3849 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3852#if __cpp_lib_three_way_comparison
3860 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3865 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3866 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3875 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3879 const _CharT* __rhs)
noexcept
3880 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3881 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3889 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3892 operator==(
const _CharT* __lhs,
3893 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3894 {
return __rhs == __lhs; }
3903 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3906 operator!=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3907 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3909 {
return !(__lhs == __rhs); }
3917 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3920 operator!=(
const _CharT* __lhs,
3921 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3922 {
return !(__rhs == __lhs); }
3930 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3933 operator!=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3934 const _CharT* __rhs)
3935 {
return !(__lhs == __rhs); }
3944 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3947 operator<(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3948 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3950 {
return __lhs.compare(__rhs) < 0; }
3958 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3961 operator<(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3962 const _CharT* __rhs)
3963 {
return __lhs.compare(__rhs) < 0; }
3971 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3975 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3976 {
return __rhs.compare(__lhs) > 0; }
3985 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3988 operator>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3989 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3991 {
return __lhs.compare(__rhs) > 0; }
3999 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4002 operator>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4003 const _CharT* __rhs)
4004 {
return __lhs.compare(__rhs) > 0; }
4012 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4016 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4017 {
return __rhs.compare(__lhs) < 0; }
4026 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4029 operator<=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4030 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4032 {
return __lhs.compare(__rhs) <= 0; }
4040 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4043 operator<=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4044 const _CharT* __rhs)
4045 {
return __lhs.compare(__rhs) <= 0; }
4053 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4057 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4058 {
return __rhs.compare(__lhs) >= 0; }
4067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4070 operator>=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4071 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4073 {
return __lhs.compare(__rhs) >= 0; }
4081 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4084 operator>=(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4085 const _CharT* __rhs)
4086 {
return __lhs.compare(__rhs) >= 0; }
4094 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4098 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4099 {
return __rhs.compare(__lhs) <= 0; }
4109 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4110 _GLIBCXX20_CONSTEXPR
4114 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
4115 { __lhs.swap(__rhs); }
4130 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4131 basic_istream<_CharT, _Traits>&
4132 operator>>(basic_istream<_CharT, _Traits>& __is,
4133 basic_string<_CharT, _Traits, _Alloc>& __str);
4136 basic_istream<char>&
4148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4155 return __ostream_insert(__os, __str.data(), __str.size());
4171 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4172 basic_istream<_CharT, _Traits>&
4173 getline(basic_istream<_CharT, _Traits>& __is,
4174 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4188 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4189 inline basic_istream<_CharT, _Traits>&
4194#if __cplusplus >= 201103L
4196 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4197 inline basic_istream<_CharT, _Traits>&
4203 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4204 inline basic_istream<_CharT, _Traits>&
4211 basic_istream<char>&
4212 getline(basic_istream<char>& __in, basic_string<char>& __str,
4215#ifdef _GLIBCXX_USE_WCHAR_T
4217 basic_istream<wchar_t>&
4218 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4222_GLIBCXX_END_NAMESPACE_VERSION
4225#if __cplusplus >= 201103L
4230namespace std _GLIBCXX_VISIBILITY(default)
4232_GLIBCXX_BEGIN_NAMESPACE_VERSION
4233_GLIBCXX_BEGIN_NAMESPACE_CXX11
4237 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4238 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
4242 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4243 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
4246 inline unsigned long
4247 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4248 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
4251#if _GLIBCXX_USE_C99_STDLIB
4253 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4254 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
4257 inline unsigned long long
4258 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4259 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
4261#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4263 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4264 {
return std::stol(__str, __idx, __base); }
4266 inline unsigned long long
4267 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
4268 {
return std::stoul(__str, __idx, __base); }
4272 stod(
const string& __str,
size_t* __idx = 0)
4273 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
4275#if _GLIBCXX_HAVE_STRTOF
4278 stof(
const string& __str,
size_t* __idx = 0)
4279 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
4282 stof(
const string& __str,
size_t* __idx = 0)
4284 double __d = std::stod(__str, __idx);
4285 if (__builtin_isfinite(__d) && __d != 0.0)
4287 double __abs_d = __builtin_fabs(__d);
4288 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4291 std::__throw_out_of_range(
"stof");
4298#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4300 stold(
const string& __str,
size_t* __idx = 0)
4301 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
4302#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4304 stold(
const string& __str,
size_t* __idx = 0)
4305 {
return std::stod(__str, __idx); }
4313 to_string(
int __val)
4314#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4318 const bool __neg = __val < 0;
4319 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4320 const auto __len = __detail::__to_chars_len(__uval);
4322 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4324 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4332 to_string(
unsigned __val)
4333#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4337 const auto __len = __detail::__to_chars_len(__val);
4339 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4340 __detail::__to_chars_10_impl(__p, __n, __val);
4348 to_string(
long __val)
4349#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4353 const bool __neg = __val < 0;
4354 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
4355 const auto __len = __detail::__to_chars_len(__uval);
4357 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4359 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4367 to_string(
unsigned long __val)
4368#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4372 const auto __len = __detail::__to_chars_len(__val);
4374 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4375 __detail::__to_chars_10_impl(__p, __n, __val);
4383 to_string(
long long __val)
4385 const bool __neg = __val < 0;
4386 const unsigned long long __uval
4387 = __neg ? (
unsigned long long)~__val + 1ull : __val;
4388 const auto __len = __detail::__to_chars_len(__uval);
4390 __str.__resize_and_overwrite(__neg + __len, [=](
char* __p,
size_t __n) {
4392 __detail::__to_chars_10_impl(__p + (
int)__neg, __len, __uval);
4400 to_string(
unsigned long long __val)
4402 const auto __len = __detail::__to_chars_len(__val);
4404 __str.__resize_and_overwrite(__len, [__val](
char* __p,
size_t __n) {
4405 __detail::__to_chars_10_impl(__p, __n, __val);
4411#if __glibcxx_to_string >= 202306L
4415 to_string(
float __val)
4420 __str.resize_and_overwrite(__len,
4421 [__val, &__len] (
char* __p,
size_t __n) {
4422 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4423 if (__err == errc{}) [[likely]]
4428 }
while (__str.empty());
4434 to_string(
double __val)
4439 __str.resize_and_overwrite(__len,
4440 [__val, &__len] (
char* __p,
size_t __n) {
4441 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4442 if (__err == errc{}) [[likely]]
4447 }
while (__str.empty());
4453 to_string(
long double __val)
4458 __str.resize_and_overwrite(__len,
4459 [__val, &__len] (
char* __p,
size_t __n) {
4460 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4461 if (__err == errc{}) [[likely]]
4466 }
while (__str.empty());
4469#elif _GLIBCXX_USE_C99_STDIO
4470#pragma GCC diagnostic push
4471#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
4476 to_string(
float __val)
4479 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
4480 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4486 to_string(
double __val)
4489 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
4490 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4496 to_string(
long double __val)
4499 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
4500 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
4503#pragma GCC diagnostic pop
4506#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4508 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4509 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
4513 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4514 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
4517 inline unsigned long
4518 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4519 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
4523 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4524 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
4527 inline unsigned long long
4528 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
4529 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
4534 stof(
const wstring& __str,
size_t* __idx = 0)
4535 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
4538 stod(
const wstring& __str,
size_t* __idx = 0)
4539 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
4542 stold(
const wstring& __str,
size_t* __idx = 0)
4543 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
4546#ifdef _GLIBCXX_USE_WCHAR_T
4547#pragma GCC diagnostic push
4548#pragma GCC diagnostic ignored "-Wc++17-extensions"
4549 _GLIBCXX20_CONSTEXPR
4551 __to_wstring_numeric(
const char* __s,
int __len,
wchar_t* __wout)
4555 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4556 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4558 for (
int __i = 0; __i < __len; ++__i)
4559 __wout[__i] = (
wchar_t) __s[__i];
4564 for (
int __i =
'0'; __i <=
'9'; ++__i)
4565 __wc[__i] = L
'0' + __i;
4588 for (
int __i = 0; __i < __len; ++__i)
4589 __wout[__i] = __wc[(
int)__s[__i]];
4593#if __glibcxx_constexpr_string >= 201907L
4597#if __cplusplus >= 201703L
4598 __to_wstring_numeric(string_view __s)
4600 __to_wstring_numeric(
const string& __s)
4603 if constexpr (wchar_t(
'0') == L
'0' && wchar_t(
'-') == L
'-'
4604 && wchar_t(
'.') == L
'.' && wchar_t(
'e') == L
'e')
4605 return wstring(__s.data(), __s.data() + __s.size());
4609 auto __f = __s.data();
4610 __ws.__resize_and_overwrite(__s.size(),
4611 [__f] (
wchar_t* __to,
int __n) {
4612 std::__to_wstring_numeric(__f, __n, __to);
4618#pragma GCC diagnostic pop
4622 to_wstring(
int __val)
4623 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4627 to_wstring(
unsigned __val)
4628 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4632 to_wstring(
long __val)
4633 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4637 to_wstring(
unsigned long __val)
4638 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4642 to_wstring(
long long __val)
4643 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4647 to_wstring(
unsigned long long __val)
4648 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4650#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4653 to_wstring(
float __val)
4654 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4658 to_wstring(
double __val)
4659 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4663 to_wstring(
long double __val)
4664 {
return std::__to_wstring_numeric(std::to_string(__val)); }
4668_GLIBCXX_END_NAMESPACE_CXX11
4669_GLIBCXX_END_NAMESPACE_VERSION
4674#if __cplusplus >= 201103L
4678namespace std _GLIBCXX_VISIBILITY(default)
4680_GLIBCXX_BEGIN_NAMESPACE_VERSION
4685 template<
typename _CharT,
typename _Alloc,
4686 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4687 struct __str_hash_base
4688 :
public __hash_base<size_t, _StrT>
4692 operator()(
const _StrT& __s)
const noexcept
4693 {
return _Hash_impl::hash(__s.data(), __s.length() *
sizeof(_CharT)); }
4696#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4698 template<
typename _Alloc>
4700 :
public __str_hash_base<char, _Alloc>
4704 template<
typename _Alloc>
4706 :
public __str_hash_base<wchar_t, _Alloc>
4709 template<
typename _Alloc>
4716#ifdef _GLIBCXX_USE_CHAR8_T
4718 template<
typename _Alloc>
4719 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4720 :
public __str_hash_base<char8_t, _Alloc>
4725 template<
typename _Alloc>
4727 :
public __str_hash_base<char16_t, _Alloc>
4731 template<
typename _Alloc>
4733 :
public __str_hash_base<char32_t, _Alloc>
4736#if ! _GLIBCXX_INLINE_VERSION
4742#ifdef _GLIBCXX_USE_CHAR8_T
4743 template<>
struct __is_fast_hash<hash<u8string>> :
std::false_type { };
4747 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4748 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4753#ifdef __glibcxx_string_udls
4754 inline namespace literals
4756 inline namespace string_literals
4758#pragma GCC diagnostic push
4759#pragma GCC diagnostic ignored "-Wliteral-suffix"
4761#if __glibcxx_constexpr_string >= 201907L
4762# define _GLIBCXX_STRING_CONSTEXPR constexpr
4764# define _GLIBCXX_STRING_CONSTEXPR
4767 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4768 inline basic_string<char>
4769 operator""s(
const char* __str,
size_t __len)
4770 {
return basic_string<char>{__str, __len}; }
4772 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4773 inline basic_string<wchar_t>
4774 operator""s(
const wchar_t* __str,
size_t __len)
4775 {
return basic_string<wchar_t>{__str, __len}; }
4777#ifdef _GLIBCXX_USE_CHAR8_T
4778 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4779 inline basic_string<char8_t>
4780 operator""s(
const char8_t* __str,
size_t __len)
4781 {
return basic_string<char8_t>{__str, __len}; }
4784 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4785 inline basic_string<char16_t>
4786 operator""s(
const char16_t* __str,
size_t __len)
4787 {
return basic_string<char16_t>{__str, __len}; }
4789 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4790 inline basic_string<char32_t>
4791 operator""s(
const char32_t* __str,
size_t __len)
4792 {
return basic_string<char32_t>{__str, __len}; }
4794#undef _GLIBCXX_STRING_CONSTEXPR
4795#pragma GCC diagnostic pop
4800#if __cplusplus >= 201703L
4801 namespace __detail::__variant
4803 template<
typename>
struct _Never_valueless_alt;
4807 template<
typename _Tp,
typename _Traits,
typename _Alloc>
4808 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
4810 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4811 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4817_GLIBCXX_END_NAMESPACE_VERSION
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
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 const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
basic_string< char32_t > u32string
A string of char32_t.
basic_string< char16_t > u16string
A string of char16_t.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
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 void deallocate(_Alloc &__a, pointer __p, size_type __n)
static constexpr pointer allocate(_Alloc &__a, size_type __n)
static constexpr size_type max_size(const _Alloc &__a) noexcept
Managing sequences of characters and character-like objects.
constexpr _If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
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 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 _If_sv< _Tp, basic_string & > append(const _Tp &__svt, size_type __pos, size_type __n=npos)
Append a range of characters from a string_view.
constexpr _If_sv< _Tp, int > compare(size_type __pos, size_type __n, const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
constexpr size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
constexpr _If_sv< _Tp, int > compare(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
constexpr basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
constexpr const_reverse_iterator rend() const noexcept
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 basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
constexpr void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
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 reference back() noexcept
constexpr _If_sv< _Tp, size_type > find_first_not_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character not in a string_view.
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 _If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
constexpr size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr _If_sv< _Tp, size_type > find_last_not_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character not in a string_view.
constexpr const_reverse_iterator crbegin() const noexcept
constexpr _If_sv< _Tp, size_type > find(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a string_view.
constexpr _If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
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 iterator erase(__const_iterator __first, __const_iterator __last)
Remove a range of characters.
constexpr _If_sv< _Tp, basic_string & > replace(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos)
Replace range of characters with string_view.
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 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 _If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
constexpr basic_string & operator=(basic_string &&__str) noexcept(_Alloc_traits::_S_nothrow_move())
Move assign the value of str to this string.
constexpr _If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
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
Find last position of a string.
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 _If_sv< _Tp, size_type > find_last_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character of 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 _If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
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(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
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 capacity() const noexcept
constexpr _If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
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.
constexpr basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
static const size_type npos
Value returned by various member functions when they fail.
constexpr size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
constexpr _If_sv< _Tp, basic_string & > assign(const _Tp &__svt, size_type __pos, size_type __n=npos)
Set value from a range of characters in a string_view.
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 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 _If_sv< _Tp, size_type > find_first_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character of a string_view.
constexpr int compare(size_type __pos, size_type __n1, const _CharT *__s, size_type __n2) const
Compare substring against a character array.
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 _If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
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.
constexpr _If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
constexpr _If_sv< _Tp, size_type > rfind(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a string_view.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Traits class for iterators.
Uniform interface to C++98 and C++11 allocators.