34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
37#pragma GCC system_header
43#if __cplusplus >= 201103L
47#if __cplusplus >= 201703L
51namespace std _GLIBCXX_VISIBILITY(default)
53_GLIBCXX_BEGIN_NAMESPACE_VERSION
55#ifdef __cpp_lib_is_constant_evaluated
57# define __cpp_lib_constexpr_string 201811L
58#elif __cplusplus >= 201703L
60# define __cpp_lib_constexpr_string 201611L
61#elif __cplusplus > 201703L
64#if _GLIBCXX_USE_CXX11_ABI
65_GLIBCXX_BEGIN_NAMESPACE_CXX11
84 template<
typename _CharT,
typename _Traits,
typename _Alloc>
88 rebind<_CharT>::other _Char_alloc_type;
93 typedef _Traits traits_type;
94 typedef typename _Traits::char_type value_type;
95 typedef _Char_alloc_type allocator_type;
96 typedef typename _Alloc_traits::size_type size_type;
97 typedef typename _Alloc_traits::difference_type difference_type;
98 typedef typename _Alloc_traits::reference reference;
99 typedef typename _Alloc_traits::const_reference const_reference;
100 typedef typename _Alloc_traits::pointer pointer;
101 typedef typename _Alloc_traits::const_pointer const_pointer;
102 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
103 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
109 static const size_type
npos =
static_cast<size_type
>(-1);
113#if __cplusplus < 201103L
114 typedef iterator __const_iterator;
116 typedef const_iterator __const_iterator;
120#if __cplusplus >= 201703L
122 typedef basic_string_view<_CharT, _Traits> __sv_type;
124 template<
typename _Tp,
typename _Res>
126 __and_<is_convertible<const _Tp&, __sv_type>,
127 __not_<is_convertible<const _Tp*, const basic_string*>>,
128 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
133 _S_to_string_view(__sv_type __svt)
noexcept
142 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
158 struct _Alloc_hider : allocator_type
160#if __cplusplus < 201103L
161 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
162 : allocator_type(__a), _M_p(__dat) { }
164 _Alloc_hider(pointer __dat,
const _Alloc& __a)
165 : allocator_type(__a), _M_p(__dat) { }
167 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
168 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
174 _Alloc_hider _M_dataplus;
175 size_type _M_string_length;
177 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
181 _CharT _M_local_buf[_S_local_capacity + 1];
182 size_type _M_allocated_capacity;
187 { _M_dataplus._M_p = __p; }
190 _M_length(size_type __length)
191 { _M_string_length = __length; }
195 {
return _M_dataplus._M_p; }
200#if __cplusplus >= 201103L
203 return pointer(_M_local_buf);
208 _M_local_data()
const
210#if __cplusplus >= 201103L
213 return const_pointer(_M_local_buf);
218 _M_capacity(size_type __capacity)
219 { _M_allocated_capacity = __capacity; }
222 _M_set_length(size_type __n)
225 traits_type::assign(_M_data()[__n], _CharT());
230 {
return _M_data() == _M_local_data(); }
234 _M_create(size_type&, size_type);
240 _M_destroy(_M_allocated_capacity);
244 _M_destroy(size_type __size)
throw()
245 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
249 template<
typename _InIterator>
251 _M_construct_aux(_InIterator __beg, _InIterator __end,
254 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
255 _M_construct(__beg, __end, _Tag());
260 template<
typename _Integer>
262 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
263 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
266 _M_construct_aux_2(size_type __req, _CharT __c)
267 { _M_construct(__req, __c); }
269 template<
typename _InIterator>
271 _M_construct(_InIterator __beg, _InIterator __end)
273 typedef typename std::__is_integer<_InIterator>::__type _Integral;
274 _M_construct_aux(__beg, __end, _Integral());
278 template<
typename _InIterator>
280 _M_construct(_InIterator __beg, _InIterator __end,
285 template<
typename _FwdIterator>
287 _M_construct(_FwdIterator __beg, _FwdIterator __end,
291 _M_construct(size_type __req, _CharT __c);
295 {
return _M_dataplus; }
297 const allocator_type&
298 _M_get_allocator()
const
299 {
return _M_dataplus; }
303#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
306 template<
typename _Tp,
bool _Requires =
307 !__are_same<_Tp, _CharT*>::__value
308 && !__are_same<_Tp, const _CharT*>::__value
309 && !__are_same<_Tp, iterator>::__value
310 && !__are_same<_Tp, const_iterator>::__value>
311 struct __enable_if_not_native_iterator
312 {
typedef basic_string& __type; };
313 template<
typename _Tp>
314 struct __enable_if_not_native_iterator<_Tp, false> { };
318 _M_check(size_type __pos,
const char* __s)
const
320 if (__pos > this->
size())
321 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
322 "this->size() (which is %zu)"),
323 __s, __pos, this->
size());
328 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
331 __throw_length_error(__N(__s));
337 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
339 const bool __testoff = __off < this->
size() - __pos;
340 return __testoff ? __off : this->
size() - __pos;
345 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
347 return (less<const _CharT*>()(__s, _M_data())
348 || less<const _CharT*>()(_M_data() + this->
size(), __s));
354 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
357 traits_type::assign(*__d, *__s);
359 traits_type::copy(__d, __s, __n);
363 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
366 traits_type::assign(*__d, *__s);
368 traits_type::move(__d, __s, __n);
372 _S_assign(_CharT* __d, size_type __n, _CharT __c)
375 traits_type::assign(*__d, __c);
377 traits_type::assign(__d, __n, __c);
382 template<
class _Iterator>
384 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
386 for (; __k1 != __k2; ++__k1, (void)++__p)
387 traits_type::assign(*__p, *__k1);
391 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
392 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
395 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
397 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
400 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
401 { _S_copy(__p, __k1, __k2 - __k1); }
404 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
406 { _S_copy(__p, __k1, __k2 - __k1); }
409 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
411 const difference_type __d = difference_type(__n1 - __n2);
413 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
414 return __gnu_cxx::__numeric_traits<int>::__max;
415 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
416 return __gnu_cxx::__numeric_traits<int>::__min;
425 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
429 _M_erase(size_type __pos, size_type __n);
440 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
441 : _M_dataplus(_M_local_data())
442 { _M_set_length(0); }
449 : _M_dataplus(_M_local_data(), __a)
450 { _M_set_length(0); }
457 : _M_dataplus(_M_local_data(),
458 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
459 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
470 const _Alloc& __a = _Alloc())
471 : _M_dataplus(_M_local_data(), __a)
473 const _CharT* __start = __str._M_data()
474 + __str._M_check(__pos,
"basic_string::basic_string");
475 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
486 : _M_dataplus(_M_local_data())
488 const _CharT* __start = __str._M_data()
489 + __str._M_check(__pos,
"basic_string::basic_string");
490 _M_construct(__start, __start + __str._M_limit(__pos, __n));
501 size_type __n,
const _Alloc& __a)
502 : _M_dataplus(_M_local_data(), __a)
504 const _CharT* __start
505 = __str._M_data() + __str._M_check(__pos,
"string::string");
506 _M_construct(__start, __start + __str._M_limit(__pos, __n));
519 const _Alloc& __a = _Alloc())
520 : _M_dataplus(_M_local_data(), __a)
521 { _M_construct(__s, __s + __n); }
528#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
531 template<
typename = _RequireAllocator<_Alloc>>
533 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
534 : _M_dataplus(_M_local_data(), __a)
536 const _CharT* __end = __s ? __s + traits_type::length(__s)
538 : reinterpret_cast<const _CharT*>(__alignof__(_CharT));
539 _M_construct(__s, __end, random_access_iterator_tag());
548#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
551 template<
typename = _RequireAllocator<_Alloc>>
553 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
554 : _M_dataplus(_M_local_data(), __a)
555 { _M_construct(__n, __c); }
557#if __cplusplus >= 201103L
566 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
568 if (__str._M_is_local())
570 traits_type::copy(_M_local_buf, __str._M_local_buf,
571 _S_local_capacity + 1);
575 _M_data(__str._M_data());
576 _M_capacity(__str._M_allocated_capacity);
582 _M_length(__str.length());
583 __str._M_data(__str._M_local_data());
584 __str._M_set_length(0);
592 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
593 : _M_dataplus(_M_local_data(), __a)
594 { _M_construct(__l.begin(), __l.end()); }
597 : _M_dataplus(_M_local_data(), __a)
598 { _M_construct(__str.begin(), __str.end()); }
601 noexcept(_Alloc_traits::_S_always_equal())
602 : _M_dataplus(_M_local_data(), __a)
604 if (__str._M_is_local())
606 traits_type::copy(_M_local_buf, __str._M_local_buf,
607 _S_local_capacity + 1);
608 _M_length(__str.length());
609 __str._M_set_length(0);
611 else if (_Alloc_traits::_S_always_equal()
612 || __str.get_allocator() == __a)
614 _M_data(__str._M_data());
615 _M_length(__str.length());
616 _M_capacity(__str._M_allocated_capacity);
617 __str._M_data(__str._M_local_buf);
618 __str._M_set_length(0);
621 _M_construct(__str.begin(), __str.end());
632#if __cplusplus >= 201103L
633 template<
typename _InputIterator,
634 typename = std::_RequireInputIter<_InputIterator>>
636 template<
typename _InputIterator>
638 basic_string(_InputIterator __beg, _InputIterator __end,
639 const _Alloc& __a = _Alloc())
640 : _M_dataplus(_M_local_data(), __a)
641 { _M_construct(__beg, __end); }
643#if __cplusplus >= 201703L
651 template<
typename _Tp,
652 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
653 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
654 const _Alloc& __a = _Alloc())
662 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
664 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
665 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
681 return this->
assign(__str);
690 {
return this->
assign(__s); }
706#if __cplusplus >= 201103L
718 noexcept(_Alloc_traits::_S_nothrow_move())
720 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
721 && !_Alloc_traits::_S_always_equal()
722 && _M_get_allocator() != __str._M_get_allocator())
725 _M_destroy(_M_allocated_capacity);
726 _M_data(_M_local_data());
730 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
732 if (__str._M_is_local())
740 this->_S_copy(_M_data(), __str._M_data(), __str.size());
741 _M_set_length(__str.size());
744 else if (_Alloc_traits::_S_propagate_on_move_assign()
745 || _Alloc_traits::_S_always_equal()
746 || _M_get_allocator() == __str._M_get_allocator())
749 pointer __data =
nullptr;
750 size_type __capacity;
753 if (_Alloc_traits::_S_always_equal())
757 __capacity = _M_allocated_capacity;
760 _M_destroy(_M_allocated_capacity);
763 _M_data(__str._M_data());
764 _M_length(__str.length());
765 _M_capacity(__str._M_allocated_capacity);
768 __str._M_data(__data);
769 __str._M_capacity(__capacity);
772 __str._M_data(__str._M_local_buf);
787 this->
assign(__l.begin(), __l.size());
792#if __cplusplus >= 201703L
797 template<
typename _Tp>
798 _If_sv<_Tp, basic_string&>
800 {
return this->
assign(__svt); }
806 operator __sv_type() const noexcept
807 {
return __sv_type(
data(),
size()); }
816 begin() _GLIBCXX_NOEXCEPT
817 {
return iterator(_M_data()); }
824 begin() const _GLIBCXX_NOEXCEPT
825 {
return const_iterator(_M_data()); }
832 end() _GLIBCXX_NOEXCEPT
833 {
return iterator(_M_data() + this->
size()); }
840 end() const _GLIBCXX_NOEXCEPT
841 {
return const_iterator(_M_data() + this->
size()); }
849 rbegin() _GLIBCXX_NOEXCEPT
850 {
return reverse_iterator(this->
end()); }
857 const_reverse_iterator
858 rbegin() const _GLIBCXX_NOEXCEPT
859 {
return const_reverse_iterator(this->
end()); }
867 rend() _GLIBCXX_NOEXCEPT
868 {
return reverse_iterator(this->
begin()); }
875 const_reverse_iterator
876 rend() const _GLIBCXX_NOEXCEPT
877 {
return const_reverse_iterator(this->
begin()); }
879#if __cplusplus >= 201103L
886 {
return const_iterator(this->_M_data()); }
893 cend() const noexcept
894 {
return const_iterator(this->_M_data() + this->
size()); }
901 const_reverse_iterator
903 {
return const_reverse_iterator(this->
end()); }
910 const_reverse_iterator
911 crend() const noexcept
912 {
return const_reverse_iterator(this->
begin()); }
920 size() const _GLIBCXX_NOEXCEPT
921 {
return _M_string_length; }
926 length() const _GLIBCXX_NOEXCEPT
927 {
return _M_string_length; }
932 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
945 resize(size_type __n, _CharT __c);
959 { this->
resize(__n, _CharT()); }
961#if __cplusplus >= 201103L
962#pragma GCC diagnostic push
963#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
968#pragma GCC diagnostic pop
978 return _M_is_local() ? size_type(_S_local_capacity)
979 : _M_allocated_capacity;
1005#if __cplusplus > 201703L
1006 [[deprecated(
"use shrink_to_fit() instead")]]
1015 clear() _GLIBCXX_NOEXCEPT
1016 { _M_set_length(0); }
1022 _GLIBCXX_NODISCARD
bool
1023 empty() const _GLIBCXX_NOEXCEPT
1024 {
return this->
size() == 0; }
1038 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1040 __glibcxx_assert(__pos <=
size());
1041 return _M_data()[__pos];
1059 __glibcxx_assert(__pos <=
size());
1061 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1062 return _M_data()[__pos];
1076 at(size_type __n)
const
1078 if (__n >= this->
size())
1079 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1080 "(which is %zu) >= this->size() "
1083 return _M_data()[__n];
1100 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1101 "(which is %zu) >= this->size() "
1104 return _M_data()[__n];
1107#if __cplusplus >= 201103L
1115 __glibcxx_assert(!
empty());
1124 front() const noexcept
1126 __glibcxx_assert(!
empty());
1137 __glibcxx_assert(!
empty());
1146 back() const noexcept
1148 __glibcxx_assert(!
empty());
1161 {
return this->
append(__str); }
1170 {
return this->
append(__s); }
1184#if __cplusplus >= 201103L
1192 {
return this->
append(__l.begin(), __l.size()); }
1195#if __cplusplus >= 201703L
1201 template<
typename _Tp>
1202 _If_sv<_Tp, basic_string&>
1204 {
return this->
append(__svt); }
1214 {
return _M_append(__str._M_data(), __str.size()); }
1231 {
return _M_append(__str._M_data()
1232 + __str._M_check(__pos,
"basic_string::append"),
1233 __str._M_limit(__pos, __n)); }
1242 append(
const _CharT* __s, size_type __n)
1244 __glibcxx_requires_string_len(__s, __n);
1245 _M_check_length(size_type(0), __n,
"basic_string::append");
1246 return _M_append(__s, __n);
1255 append(
const _CharT* __s)
1257 __glibcxx_requires_string(__s);
1258 const size_type __n = traits_type::length(__s);
1259 _M_check_length(size_type(0), __n,
"basic_string::append");
1260 return _M_append(__s, __n);
1272 append(size_type __n, _CharT __c)
1273 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1275#if __cplusplus >= 201103L
1282 append(initializer_list<_CharT> __l)
1283 {
return this->
append(__l.begin(), __l.size()); }
1294#if __cplusplus >= 201103L
1295 template<
class _InputIterator,
1296 typename = std::_RequireInputIter<_InputIterator>>
1298 template<
class _InputIterator>
1301 append(_InputIterator __first, _InputIterator __last)
1304#if __cplusplus >= 201703L
1310 template<
typename _Tp>
1311 _If_sv<_Tp, basic_string&>
1314 __sv_type __sv = __svt;
1315 return this->
append(__sv.data(), __sv.size());
1325 template<
typename _Tp>
1326 _If_sv<_Tp, basic_string&>
1327 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1329 __sv_type __sv = __svt;
1330 return _M_append(__sv.data()
1331 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1332 std::__sv_limit(__sv.size(), __pos, __n));
1343 const size_type __size = this->
size();
1345 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1346 traits_type::assign(this->_M_data()[__size], __c);
1347 this->_M_set_length(__size + 1);
1358#if __cplusplus >= 201103L
1359 if (_Alloc_traits::_S_propagate_on_copy_assign())
1361 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1362 && _M_get_allocator() != __str._M_get_allocator())
1366 if (__str.size() <= _S_local_capacity)
1368 _M_destroy(_M_allocated_capacity);
1369 _M_data(_M_local_data());
1374 const auto __len = __str.size();
1375 auto __alloc = __str._M_get_allocator();
1377 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1378 _M_destroy(_M_allocated_capacity);
1381 _M_set_length(__len);
1384 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1387 this->_M_assign(__str);
1391#if __cplusplus >= 201103L
1402 noexcept(_Alloc_traits::_S_nothrow_move())
1425 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1426 + __str._M_check(__pos,
"basic_string::assign"),
1427 __str._M_limit(__pos, __n)); }
1440 assign(
const _CharT* __s, size_type __n)
1442 __glibcxx_requires_string_len(__s, __n);
1443 return _M_replace(size_type(0), this->
size(), __s, __n);
1456 assign(
const _CharT* __s)
1458 __glibcxx_requires_string(__s);
1459 return _M_replace(size_type(0), this->
size(), __s,
1460 traits_type::length(__s));
1473 assign(size_type __n, _CharT __c)
1474 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1484#if __cplusplus >= 201103L
1485 template<
class _InputIterator,
1486 typename = std::_RequireInputIter<_InputIterator>>
1488 template<
class _InputIterator>
1491 assign(_InputIterator __first, _InputIterator __last)
1494#if __cplusplus >= 201103L
1501 assign(initializer_list<_CharT> __l)
1502 {
return this->
assign(__l.begin(), __l.size()); }
1505#if __cplusplus >= 201703L
1511 template<
typename _Tp>
1512 _If_sv<_Tp, basic_string&>
1515 __sv_type __sv = __svt;
1516 return this->
assign(__sv.data(), __sv.size());
1526 template<
typename _Tp>
1527 _If_sv<_Tp, basic_string&>
1528 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1530 __sv_type __sv = __svt;
1531 return _M_replace(size_type(0), this->
size(),
1533 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1534 std::__sv_limit(__sv.size(), __pos, __n));
1538#if __cplusplus >= 201103L
1555 insert(const_iterator __p, size_type __n, _CharT __c)
1557 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1558 const size_type __pos = __p -
begin();
1559 this->
replace(__p, __p, __n, __c);
1560 return iterator(this->_M_data() + __pos);
1577 insert(iterator __p, size_type __n, _CharT __c)
1578 { this->
replace(__p, __p, __n, __c); }
1581#if __cplusplus >= 201103L
1596 template<
class _InputIterator,
1597 typename = std::_RequireInputIter<_InputIterator>>
1599 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1601 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1602 const size_type __pos = __p -
begin();
1603 this->
replace(__p, __p, __beg, __end);
1604 return iterator(this->_M_data() + __pos);
1619 template<
class _InputIterator>
1621 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1622 { this->
replace(__p, __p, __beg, __end); }
1625#if __cplusplus >= 201103L
1633 insert(const_iterator __p, initializer_list<_CharT> __l)
1634 {
return this->
insert(__p, __l.begin(), __l.end()); }
1636#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1639 insert(iterator __p, initializer_list<_CharT> __l)
1641 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1642 this->
insert(__p -
begin(), __l.begin(), __l.size());
1661 {
return this->
replace(__pos1, size_type(0),
1662 __str._M_data(), __str.size()); }
1684 size_type __pos2, size_type __n =
npos)
1685 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1686 + __str._M_check(__pos2,
"basic_string::insert"),
1687 __str._M_limit(__pos2, __n)); }
1706 insert(size_type __pos,
const _CharT* __s, size_type __n)
1707 {
return this->
replace(__pos, size_type(0), __s, __n); }
1725 insert(size_type __pos,
const _CharT* __s)
1727 __glibcxx_requires_string(__s);
1728 return this->
replace(__pos, size_type(0), __s,
1729 traits_type::length(__s));
1749 insert(size_type __pos, size_type __n, _CharT __c)
1750 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1751 size_type(0), __n, __c); }
1767 insert(__const_iterator __p, _CharT __c)
1769 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1770 const size_type __pos = __p -
begin();
1771 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1772 return iterator(_M_data() + __pos);
1775#if __cplusplus >= 201703L
1782 template<
typename _Tp>
1783 _If_sv<_Tp, basic_string&>
1784 insert(size_type __pos,
const _Tp& __svt)
1786 __sv_type __sv = __svt;
1787 return this->
insert(__pos, __sv.data(), __sv.size());
1798 template<
typename _Tp>
1799 _If_sv<_Tp, basic_string&>
1800 insert(size_type __pos1,
const _Tp& __svt,
1801 size_type __pos2, size_type __n =
npos)
1803 __sv_type __sv = __svt;
1804 return this->
replace(__pos1, size_type(0),
1806 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1807 std::__sv_limit(__sv.size(), __pos2, __n));
1827 erase(size_type __pos = 0, size_type __n =
npos)
1829 _M_check(__pos,
"basic_string::erase");
1831 this->_M_set_length(__pos);
1833 this->_M_erase(__pos, _M_limit(__pos, __n));
1846 erase(__const_iterator __position)
1848 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1849 && __position <
end());
1850 const size_type __pos = __position -
begin();
1851 this->_M_erase(__pos, size_type(1));
1852 return iterator(_M_data() + __pos);
1865 erase(__const_iterator __first, __const_iterator __last)
1867 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1868 && __last <=
end());
1869 const size_type __pos = __first -
begin();
1870 if (__last ==
end())
1871 this->_M_set_length(__pos);
1873 this->_M_erase(__pos, __last - __first);
1874 return iterator(this->_M_data() + __pos);
1877#if __cplusplus >= 201103L
1886 __glibcxx_assert(!
empty());
1887 _M_erase(
size() - 1, 1);
1910 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1932 size_type __pos2, size_type __n2 =
npos)
1933 {
return this->
replace(__pos1, __n1, __str._M_data()
1934 + __str._M_check(__pos2,
"basic_string::replace"),
1935 __str._M_limit(__pos2, __n2)); }
1956 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1959 __glibcxx_requires_string_len(__s, __n2);
1960 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1961 _M_limit(__pos, __n1), __s, __n2);
1981 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1983 __glibcxx_requires_string(__s);
1984 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2005 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2006 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2007 _M_limit(__pos, __n1), __n2, __c); }
2023 replace(__const_iterator __i1, __const_iterator __i2,
2025 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2043 replace(__const_iterator __i1, __const_iterator __i2,
2044 const _CharT* __s, size_type __n)
2046 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2048 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2065 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2067 __glibcxx_requires_string(__s);
2068 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2086 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2089 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2091 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2109#if __cplusplus >= 201103L
2110 template<
class _InputIterator,
2111 typename = std::_RequireInputIter<_InputIterator>>
2113 replace(const_iterator __i1, const_iterator __i2,
2114 _InputIterator __k1, _InputIterator __k2)
2116 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2118 __glibcxx_requires_valid_range(__k1, __k2);
2119 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2120 std::__false_type());
2123 template<
class _InputIterator>
2124#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2125 typename __enable_if_not_native_iterator<_InputIterator>::__type
2129 replace(iterator __i1, iterator __i2,
2130 _InputIterator __k1, _InputIterator __k2)
2132 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2134 __glibcxx_requires_valid_range(__k1, __k2);
2135 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2136 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2143 replace(__const_iterator __i1, __const_iterator __i2,
2144 _CharT* __k1, _CharT* __k2)
2146 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2148 __glibcxx_requires_valid_range(__k1, __k2);
2154 replace(__const_iterator __i1, __const_iterator __i2,
2155 const _CharT* __k1,
const _CharT* __k2)
2157 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2159 __glibcxx_requires_valid_range(__k1, __k2);
2165 replace(__const_iterator __i1, __const_iterator __i2,
2166 iterator __k1, iterator __k2)
2168 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2170 __glibcxx_requires_valid_range(__k1, __k2);
2172 __k1.base(), __k2 - __k1);
2176 replace(__const_iterator __i1, __const_iterator __i2,
2177 const_iterator __k1, const_iterator __k2)
2179 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2181 __glibcxx_requires_valid_range(__k1, __k2);
2183 __k1.base(), __k2 - __k1);
2186#if __cplusplus >= 201103L
2202 initializer_list<_CharT> __l)
2203 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2206#if __cplusplus >= 201703L
2214 template<
typename _Tp>
2215 _If_sv<_Tp, basic_string&>
2216 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2218 __sv_type __sv = __svt;
2219 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2231 template<
typename _Tp>
2232 _If_sv<_Tp, basic_string&>
2233 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2234 size_type __pos2, size_type __n2 =
npos)
2236 __sv_type __sv = __svt;
2237 return this->
replace(__pos1, __n1,
2239 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2240 std::__sv_limit(__sv.size(), __pos2, __n2));
2252 template<
typename _Tp>
2253 _If_sv<_Tp, basic_string&>
2254 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2256 __sv_type __sv = __svt;
2257 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2262 template<
class _Integer>
2264 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2265 _Integer __n, _Integer __val, __true_type)
2266 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2268 template<
class _InputIterator>
2270 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2271 _InputIterator __k1, _InputIterator __k2,
2275 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2279 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2280 const size_type __len2);
2283 _M_append(
const _CharT* __s, size_type __n);
2300 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2320 c_str() const _GLIBCXX_NOEXCEPT
2321 {
return _M_data(); }
2332 data() const _GLIBCXX_NOEXCEPT
2333 {
return _M_data(); }
2335#if __cplusplus >= 201703L
2344 {
return _M_data(); }
2352 {
return _M_get_allocator(); }
2367 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2383 {
return this->
find(__str.data(), __pos, __str.size()); }
2385#if __cplusplus >= 201703L
2392 template<
typename _Tp>
2393 _If_sv<_Tp, size_type>
2394 find(
const _Tp& __svt, size_type __pos = 0) const
2395 noexcept(is_same<_Tp, __sv_type>::value)
2397 __sv_type __sv = __svt;
2398 return this->
find(__sv.data(), __pos, __sv.size());
2413 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2415 __glibcxx_requires_string(__s);
2416 return this->
find(__s, __pos, traits_type::length(__s));
2430 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2445 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2447#if __cplusplus >= 201703L
2454 template<
typename _Tp>
2455 _If_sv<_Tp, size_type>
2456 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2457 noexcept(is_same<_Tp, __sv_type>::value)
2459 __sv_type __sv = __svt;
2460 return this->
rfind(__sv.data(), __pos, __sv.size());
2477 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2491 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2493 __glibcxx_requires_string(__s);
2494 return this->
rfind(__s, __pos, traits_type::length(__s));
2508 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2524 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2526#if __cplusplus >= 201703L
2534 template<
typename _Tp>
2535 _If_sv<_Tp, size_type>
2537 noexcept(is_same<_Tp, __sv_type>::value)
2539 __sv_type __sv = __svt;
2540 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2557 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2574 __glibcxx_requires_string(__s);
2575 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2591 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2592 {
return this->
find(__c, __pos); }
2608 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2610#if __cplusplus >= 201703L
2618 template<
typename _Tp>
2619 _If_sv<_Tp, size_type>
2621 noexcept(is_same<_Tp, __sv_type>::value)
2623 __sv_type __sv = __svt;
2624 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2641 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2658 __glibcxx_requires_string(__s);
2659 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2676 {
return this->
rfind(__c, __pos); }
2693#if __cplusplus >= 201703L
2701 template<
typename _Tp>
2702 _If_sv<_Tp, size_type>
2704 noexcept(is_same<_Tp, __sv_type>::value)
2706 __sv_type __sv = __svt;
2725 size_type __n)
const _GLIBCXX_NOEXCEPT;
2741 __glibcxx_requires_string(__s);
2775#if __cplusplus >= 201703L
2783 template<
typename _Tp>
2784 _If_sv<_Tp, size_type>
2786 noexcept(is_same<_Tp, __sv_type>::value)
2788 __sv_type __sv = __svt;
2807 size_type __n)
const _GLIBCXX_NOEXCEPT;
2823 __glibcxx_requires_string(__s);
2854 substr(size_type __pos = 0, size_type __n =
npos)
const
2856 _M_check(__pos,
"basic_string::substr"), __n); }
2875 const size_type __size = this->
size();
2876 const size_type __osize = __str.size();
2877 const size_type __len =
std::min(__size, __osize);
2879 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2881 __r = _S_compare(__size, __osize);
2885#if __cplusplus >= 201703L
2891 template<
typename _Tp>
2893 compare(
const _Tp& __svt)
const
2894 noexcept(is_same<_Tp, __sv_type>::value)
2896 __sv_type __sv = __svt;
2897 const size_type __size = this->
size();
2898 const size_type __osize = __sv.size();
2899 const size_type __len =
std::min(__size, __osize);
2901 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2903 __r = _S_compare(__size, __osize);
2915 template<
typename _Tp>
2917 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2918 noexcept(is_same<_Tp, __sv_type>::value)
2920 __sv_type __sv = __svt;
2921 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2934 template<
typename _Tp>
2936 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2937 size_type __pos2, size_type __n2 =
npos)
const
2938 noexcept(is_same<_Tp, __sv_type>::value)
2940 __sv_type __sv = __svt;
2941 return __sv_type(*
this)
2942 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2993 size_type __pos2, size_type __n2 =
npos)
const;
3010 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3034 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3061 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3062 size_type __n2)
const;
3064#if __cplusplus > 201703L
3066 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3067 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3070 starts_with(_CharT __x)
const noexcept
3071 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3074 starts_with(
const _CharT* __x)
const noexcept
3075 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3078 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3079 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3082 ends_with(_CharT __x)
const noexcept
3083 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3086 ends_with(
const _CharT* __x)
const noexcept
3087 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3090#if __cplusplus > 202002L
3092 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3093 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3096 contains(_CharT __x)
const noexcept
3097 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3100 contains(
const _CharT* __x)
const noexcept
3101 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3105 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3107_GLIBCXX_END_NAMESPACE_CXX11
3173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3177 rebind<_CharT>::other _CharT_alloc_type;
3182 typedef _Traits traits_type;
3183 typedef typename _Traits::char_type value_type;
3184 typedef _Alloc allocator_type;
3185 typedef typename _CharT_alloc_traits::size_type size_type;
3186 typedef typename _CharT_alloc_traits::difference_type difference_type;
3187#if __cplusplus < 201103L
3188 typedef typename _CharT_alloc_type::reference reference;
3189 typedef typename _CharT_alloc_type::const_reference const_reference;
3191 typedef value_type& reference;
3192 typedef const value_type& const_reference;
3194 typedef typename _CharT_alloc_traits::pointer pointer;
3195 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3196 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3197 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3204 typedef iterator __const_iterator;
3223 size_type _M_length;
3224 size_type _M_capacity;
3225 _Atomic_word _M_refcount;
3228 struct _Rep : _Rep_base
3232 rebind<char>::other _Raw_bytes_alloc;
3247 static const size_type _S_max_size;
3248 static const _CharT _S_terminal;
3252 static size_type _S_empty_rep_storage[];
3255 _S_empty_rep() _GLIBCXX_NOEXCEPT
3260 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3261 return *
reinterpret_cast<_Rep*
>(__p);
3265 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3267#if defined(__GTHREADS)
3272 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3274 return this->_M_refcount < 0;
3279 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3281#if defined(__GTHREADS)
3287 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3289 return this->_M_refcount > 0;
3294 _M_set_leaked() _GLIBCXX_NOEXCEPT
3295 { this->_M_refcount = -1; }
3298 _M_set_sharable() _GLIBCXX_NOEXCEPT
3299 { this->_M_refcount = 0; }
3302 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3304#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3305 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3308 this->_M_set_sharable();
3309 this->_M_length = __n;
3310 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3317 _M_refdata()
throw()
3318 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3321 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3323 return (!_M_is_leaked() && __alloc1 == __alloc2)
3324 ? _M_refcopy() : _M_clone(__alloc1);
3329 _S_create(size_type, size_type,
const _Alloc&);
3332 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3334#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3335 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3339 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3348 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3351 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3358 _M_destroy(
const _Alloc&)
throw();
3361 _M_refcopy()
throw()
3363#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3364 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3366 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3367 return _M_refdata();
3371 _M_clone(
const _Alloc&, size_type __res = 0);
3375 struct _Alloc_hider : _Alloc
3377 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3378 : _Alloc(__a), _M_p(__dat) { }
3388 static const size_type
npos =
static_cast<size_type
>(-1);
3392 mutable _Alloc_hider _M_dataplus;
3395 _M_data() const _GLIBCXX_NOEXCEPT
3396 {
return _M_dataplus._M_p; }
3399 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3400 {
return (_M_dataplus._M_p = __p); }
3403 _M_rep() const _GLIBCXX_NOEXCEPT
3404 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3409 _M_ibegin() const _GLIBCXX_NOEXCEPT
3410 {
return iterator(_M_data()); }
3413 _M_iend() const _GLIBCXX_NOEXCEPT
3414 {
return iterator(_M_data() + this->
size()); }
3419 if (!_M_rep()->_M_is_leaked())
3424 _M_check(size_type __pos,
const char* __s)
const
3426 if (__pos > this->
size())
3427 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3428 "this->size() (which is %zu)"),
3429 __s, __pos, this->
size());
3434 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3437 __throw_length_error(__N(__s));
3442 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3444 const bool __testoff = __off < this->
size() - __pos;
3445 return __testoff ? __off : this->
size() - __pos;
3450 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3452 return (less<const _CharT*>()(__s, _M_data())
3453 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3459 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3462 traits_type::assign(*__d, *__s);
3464 traits_type::copy(__d, __s, __n);
3468 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3471 traits_type::assign(*__d, *__s);
3473 traits_type::move(__d, __s, __n);
3477 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3480 traits_type::assign(*__d, __c);
3482 traits_type::assign(__d, __n, __c);
3487 template<
class _Iterator>
3489 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3491 for (; __k1 != __k2; ++__k1, (void)++__p)
3492 traits_type::assign(*__p, *__k1);
3496 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3497 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3500 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3502 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3505 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3506 { _M_copy(__p, __k1, __k2 - __k1); }
3509 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3511 { _M_copy(__p, __k1, __k2 - __k1); }
3514 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3516 const difference_type __d = difference_type(__n1 - __n2);
3518 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3519 return __gnu_cxx::__numeric_traits<int>::__max;
3520 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3521 return __gnu_cxx::__numeric_traits<int>::__min;
3527 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3533 _S_empty_rep() _GLIBCXX_NOEXCEPT
3534 {
return _Rep::_S_empty_rep(); }
3536#if __cplusplus >= 201703L
3538 typedef basic_string_view<_CharT, _Traits> __sv_type;
3540 template<
typename _Tp,
typename _Res>
3542 __and_<is_convertible<const _Tp&, __sv_type>,
3543 __not_<is_convertible<const _Tp*, const basic_string*>>,
3544 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3549 _S_to_string_view(__sv_type __svt)
noexcept
3558 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3582#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3584 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3586 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3595 : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
3604 : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.
get_allocator()),
3618 const _Alloc& __a = _Alloc());
3636 size_type __n,
const _Alloc& __a);
3648 const _Alloc& __a = _Alloc())
3649 : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
3657#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3660 template<
typename = _RequireAllocator<_Alloc>>
3663 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3664 __s +
npos, __a), __a)
3674 : _M_dataplus(_S_construct(__n, __c, __a), __a)
3677#if __cplusplus >= 201103L
3686#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3689 : _M_dataplus(
std::move(__str._M_dataplus))
3691#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3692 __str._M_data(_S_empty_rep()._M_refdata());
3694 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3704 : _M_dataplus(_S_construct(__l.
begin(), __l.
end(), __a), __a)
3708 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3712 : _M_dataplus(__str._M_data(), __a)
3714 if (__a == __str.get_allocator())
3716#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3717 __str._M_data(_S_empty_rep()._M_refdata());
3719 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3723 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3733 template<
class _InputIterator>
3735 const _Alloc& __a = _Alloc())
3736 : _M_dataplus(_S_construct(__beg, __end, __a), __a)
3739#if __cplusplus >= 201703L
3747 template<
typename _Tp,
3750 const _Alloc& __a = _Alloc())
3758 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3761 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3776 {
return this->
assign(__str); }
3784 {
return this->
assign(__s); }
3800#if __cplusplus >= 201103L
3824 this->
assign(__l.begin(), __l.size());
3829#if __cplusplus >= 201703L
3834 template<
typename _Tp>
3835 _If_sv<_Tp, basic_string&>
3837 {
return this->
assign(__svt); }
3856 return iterator(_M_data());
3865 {
return const_iterator(_M_data()); }
3875 return iterator(_M_data() + this->
size());
3884 {
return const_iterator(_M_data() + this->
size()); }
3900 const_reverse_iterator
3918 const_reverse_iterator
3922#if __cplusplus >= 201103L
3929 {
return const_iterator(this->_M_data()); }
3937 {
return const_iterator(this->_M_data() + this->
size()); }
3944 const_reverse_iterator
3953 const_reverse_iterator
3964 {
return _M_rep()->_M_length; }
3970 {
return _M_rep()->_M_length; }
3975 {
return _Rep::_S_max_size; }
3988 resize(size_type __n, _CharT __c);
4002 { this->
resize(__n, _CharT()); }
4004#if __cplusplus >= 201103L
4005#pragma GCC diagnostic push
4006#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
4011#pragma GCC diagnostic pop
4020 {
return _M_rep()->_M_capacity; }
4043#if __cplusplus > 201703L
4044 [[deprecated(
"use shrink_to_fit() instead")]]
4052#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4056 if (_M_rep()->_M_is_shared())
4059 _M_data(_S_empty_rep()._M_refdata());
4062 _M_rep()->_M_set_length_and_sharable(0);
4068 { _M_mutate(0, this->
size(), 0); }
4075 _GLIBCXX_NODISCARD
bool
4077 {
return this->
size() == 0; }
4093 __glibcxx_assert(__pos <=
size());
4094 return _M_data()[__pos];
4112 __glibcxx_assert(__pos <=
size());
4114 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4116 return _M_data()[__pos];
4132 if (__n >= this->
size())
4133 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4134 "(which is %zu) >= this->size() "
4137 return _M_data()[__n];
4155 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4156 "(which is %zu) >= this->size() "
4160 return _M_data()[__n];
4163#if __cplusplus >= 201103L
4171 __glibcxx_assert(!
empty());
4182 __glibcxx_assert(!
empty());
4193 __glibcxx_assert(!
empty());
4204 __glibcxx_assert(!
empty());
4217 {
return this->
append(__str); }
4226 {
return this->
append(__s); }
4240#if __cplusplus >= 201103L
4248 {
return this->
append(__l.begin(), __l.size()); }
4251#if __cplusplus >= 201703L
4257 template<
typename _Tp>
4258 _If_sv<_Tp, basic_string&>
4260 {
return this->
append(__svt); }
4294 append(
const _CharT* __s, size_type __n);
4304 __glibcxx_requires_string(__s);
4305 return this->
append(__s, traits_type::length(__s));
4317 append(size_type __n, _CharT __c);
4319#if __cplusplus >= 201103L
4327 {
return this->
append(__l.begin(), __l.size()); }
4338 template<
class _InputIterator>
4340 append(_InputIterator __first, _InputIterator __last)
4341 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4343#if __cplusplus >= 201703L
4349 template<
typename _Tp>
4350 _If_sv<_Tp, basic_string&>
4354 return this->
append(__sv.data(), __sv.size());
4365 template<
typename _Tp>
4366 _If_sv<_Tp, basic_string&>
4370 return append(__sv.data()
4371 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4372 std::__sv_limit(__sv.size(), __pos, __n));
4383 const size_type __len = 1 + this->
size();
4384 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4386 traits_type::assign(_M_data()[this->
size()], __c);
4387 _M_rep()->_M_set_length_and_sharable(__len);
4398#if __cplusplus >= 201103L
4431 {
return this->
assign(__str._M_data()
4432 + __str._M_check(__pos,
"basic_string::assign"),
4433 __str._M_limit(__pos, __n)); }
4446 assign(
const _CharT* __s, size_type __n);
4460 __glibcxx_requires_string(__s);
4461 return this->
assign(__s, traits_type::length(__s));
4475 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4485 template<
class _InputIterator>
4487 assign(_InputIterator __first, _InputIterator __last)
4488 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4490#if __cplusplus >= 201103L
4498 {
return this->
assign(__l.begin(), __l.size()); }
4501#if __cplusplus >= 201703L
4507 template<
typename _Tp>
4508 _If_sv<_Tp, basic_string&>
4512 return this->
assign(__sv.data(), __sv.size());
4522 template<
typename _Tp>
4523 _If_sv<_Tp, basic_string&>
4527 return assign(__sv.data()
4528 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4529 std::__sv_limit(__sv.size(), __pos, __n));
4547 insert(iterator __p, size_type __n, _CharT __c)
4548 { this->
replace(__p, __p, __n, __c); }
4562 template<
class _InputIterator>
4564 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4565 { this->
replace(__p, __p, __beg, __end); }
4567#if __cplusplus >= 201103L
4577 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4578 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4596 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4618 size_type __pos2, size_type __n =
npos)
4619 {
return this->
insert(__pos1, __str._M_data()
4620 + __str._M_check(__pos2,
"basic_string::insert"),
4621 __str._M_limit(__pos2, __n)); }
4640 insert(size_type __pos,
const _CharT* __s, size_type __n);
4660 __glibcxx_requires_string(__s);
4661 return this->
insert(__pos, __s, traits_type::length(__s));
4681 insert(size_type __pos, size_type __n, _CharT __c)
4682 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4683 size_type(0), __n, __c); }
4701 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4702 const size_type __pos = __p - _M_ibegin();
4703 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4704 _M_rep()->_M_set_leaked();
4705 return iterator(_M_data() + __pos);
4708#if __cplusplus >= 201703L
4715 template<
typename _Tp>
4716 _If_sv<_Tp, basic_string&>
4720 return this->
insert(__pos, __sv.data(), __sv.size());
4731 template<
typename _Tp>
4732 _If_sv<_Tp, basic_string&>
4734 size_type __pos2, size_type __n =
npos)
4737 return this->
replace(__pos1, size_type(0), __sv.data()
4738 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4739 std::__sv_limit(__sv.size(), __pos2, __n));
4761 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4762 _M_limit(__pos, __n), size_type(0));
4777 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4778 && __position < _M_iend());
4779 const size_type __pos = __position - _M_ibegin();
4780 _M_mutate(__pos, size_type(1), size_type(0));
4781 _M_rep()->_M_set_leaked();
4782 return iterator(_M_data() + __pos);
4797#if __cplusplus >= 201103L
4806 __glibcxx_assert(!
empty());
4830 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4852 size_type __pos2, size_type __n2 =
npos)
4853 {
return this->
replace(__pos1, __n1, __str._M_data()
4854 + __str._M_check(__pos2,
"basic_string::replace"),
4855 __str._M_limit(__pos2, __n2)); }
4876 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4896 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4898 __glibcxx_requires_string(__s);
4899 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4920 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4921 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4922 _M_limit(__pos, __n1), __n2, __c); }
4939 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4957 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4959 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4960 && __i2 <= _M_iend());
4961 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4978 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4980 __glibcxx_requires_string(__s);
4981 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4999 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
5001 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5002 && __i2 <= _M_iend());
5003 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
5021 template<
class _InputIterator>
5024 _InputIterator __k1, _InputIterator __k2)
5026 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5027 && __i2 <= _M_iend());
5028 __glibcxx_requires_valid_range(__k1, __k2);
5029 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
5030 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
5038 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5039 && __i2 <= _M_iend());
5040 __glibcxx_requires_valid_range(__k1, __k2);
5041 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5046 replace(iterator __i1, iterator __i2,
5047 const _CharT* __k1,
const _CharT* __k2)
5049 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5050 && __i2 <= _M_iend());
5051 __glibcxx_requires_valid_range(__k1, __k2);
5052 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5057 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5059 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5060 && __i2 <= _M_iend());
5061 __glibcxx_requires_valid_range(__k1, __k2);
5062 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5063 __k1.base(), __k2 - __k1);
5067 replace(iterator __i1, iterator __i2,
5068 const_iterator __k1, const_iterator __k2)
5070 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5071 && __i2 <= _M_iend());
5072 __glibcxx_requires_valid_range(__k1, __k2);
5073 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5074 __k1.base(), __k2 - __k1);
5077#if __cplusplus >= 201103L
5094 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5097#if __cplusplus >= 201703L
5105 template<
typename _Tp>
5106 _If_sv<_Tp, basic_string&>
5107 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5110 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5122 template<
typename _Tp>
5123 _If_sv<_Tp, basic_string&>
5124 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5125 size_type __pos2, size_type __n2 =
npos)
5128 return this->
replace(__pos1, __n1,
5130 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5131 std::__sv_limit(__sv.size(), __pos2, __n2));
5143 template<
typename _Tp>
5144 _If_sv<_Tp, basic_string&>
5145 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5148 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5153 template<
class _Integer>
5156 _Integer __val, __true_type)
5157 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5159 template<
class _InputIterator>
5161 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5162 _InputIterator __k2, __false_type);
5165 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5169 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5174 template<
class _InIterator>
5176 _S_construct_aux(_InIterator __beg, _InIterator __end,
5177 const _Alloc& __a, __false_type)
5179 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5180 return _S_construct(__beg, __end, __a, _Tag());
5185 template<
class _Integer>
5187 _S_construct_aux(_Integer __beg, _Integer __end,
5188 const _Alloc& __a, __true_type)
5189 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5193 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5194 {
return _S_construct(__req, __c, __a); }
5196 template<
class _InIterator>
5198 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5200 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5201 return _S_construct_aux(__beg, __end, __a, _Integral());
5205 template<
class _InIterator>
5207 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5208 input_iterator_tag);
5212 template<
class _FwdIterator>
5214 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5215 forward_iterator_tag);
5218 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5235 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5246 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5257 {
return _M_data(); }
5269 {
return _M_data(); }
5271#if __cplusplus >= 201703L
5291 {
return _M_dataplus; }
5306 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5322 {
return this->
find(__str.data(), __pos, __str.size()); }
5335 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5337 __glibcxx_requires_string(__s);
5338 return this->
find(__s, __pos, traits_type::length(__s));
5352 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5354#if __cplusplus >= 201703L
5361 template<
typename _Tp>
5362 _If_sv<_Tp, size_type>
5363 find(
const _Tp& __svt, size_type __pos = 0) const
5367 return this->
find(__sv.data(), __pos, __sv.size());
5384 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5399 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5413 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5415 __glibcxx_requires_string(__s);
5416 return this->
rfind(__s, __pos, traits_type::length(__s));
5430 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5432#if __cplusplus >= 201703L
5439 template<
typename _Tp>
5440 _If_sv<_Tp, size_type>
5445 return this->
rfind(__sv.data(), __pos, __sv.size());
5463 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5478 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5495 __glibcxx_requires_string(__s);
5496 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5513 {
return this->
find(__c, __pos); }
5515#if __cplusplus >= 201703L
5523 template<
typename _Tp>
5524 _If_sv<_Tp, size_type>
5529 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5547 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5562 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5579 __glibcxx_requires_string(__s);
5580 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5597 {
return this->
rfind(__c, __pos); }
5599#if __cplusplus >= 201703L
5607 template<
typename _Tp>
5608 _If_sv<_Tp, size_type>
5613 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5646 size_type __n)
const _GLIBCXX_NOEXCEPT;
5662 __glibcxx_requires_string(__s);
5680#if __cplusplus >= 201703L
5688 template<
typename _Tp>
5689 _If_sv<_Tp, size_type>
5728 size_type __n)
const _GLIBCXX_NOEXCEPT;
5744 __glibcxx_requires_string(__s);
5762#if __cplusplus >= 201703L
5770 template<
typename _Tp>
5771 _If_sv<_Tp, size_type>
5795 _M_check(__pos,
"basic_string::substr"), __n); }
5814 const size_type __size = this->
size();
5815 const size_type __osize = __str.size();
5816 const size_type __len =
std::min(__size, __osize);
5818 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5820 __r = _S_compare(__size, __osize);
5824#if __cplusplus >= 201703L
5830 template<
typename _Tp>
5836 const size_type __size = this->
size();
5837 const size_type __osize = __sv.size();
5838 const size_type __len =
std::min(__size, __osize);
5840 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5842 __r = _S_compare(__size, __osize);
5854 template<
typename _Tp>
5856 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5860 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5873 template<
typename _Tp>
5875 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5876 size_type __pos2, size_type __n2 =
npos)
const
5881 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5905 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5931 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5932 size_type __pos2, size_type __n2 =
npos)
const;
5949 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5973 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
6000 compare(size_type __pos, size_type __n1,
const _CharT* __s,
6001 size_type __n2)
const;
6003#if __cplusplus > 201703L
6006 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6009 starts_with(_CharT __x)
const noexcept
6010 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6013 starts_with(
const _CharT* __x)
const noexcept
6014 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6017 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
6018 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6021 ends_with(_CharT __x)
const noexcept
6022 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6025 ends_with(
const _CharT* __x)
const noexcept
6026 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6029#if __cplusplus > 202011L
6031 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
6032 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6035 contains(_CharT __x)
const noexcept
6036 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6039 contains(
const _CharT* __x)
const noexcept
6040 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6043# ifdef _GLIBCXX_TM_TS_INTERNAL
6045 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
6048 ::_txnal_cow_string_c_str(
const void *that);
6050 ::_txnal_cow_string_D1(
void *that);
6052 ::_txnal_cow_string_D1_commit(
void *that);
6057#if __cpp_deduction_guides >= 201606
6058_GLIBCXX_BEGIN_NAMESPACE_CXX11
6059 template<
typename _InputIterator,
typename _CharT
6060 =
typename iterator_traits<_InputIterator>::value_type,
6061 typename _Allocator = allocator<_CharT>,
6062 typename = _RequireInputIter<_InputIterator>,
6063 typename = _RequireAllocator<_Allocator>>
6064 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6065 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6069 template<
typename _CharT,
typename _Traits,
6070 typename _Allocator = allocator<_CharT>,
6071 typename = _RequireAllocator<_Allocator>>
6072 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6073 -> basic_string<_CharT, _Traits, _Allocator>;
6075 template<
typename _CharT,
typename _Traits,
6076 typename _Allocator = allocator<_CharT>,
6077 typename = _RequireAllocator<_Allocator>>
6078 basic_string(basic_string_view<_CharT, _Traits>,
6079 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6080 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6081 const _Allocator& = _Allocator())
6082 -> basic_string<_CharT, _Traits, _Allocator>;
6083_GLIBCXX_END_NAMESPACE_CXX11
6093 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6094 basic_string<_CharT, _Traits, _Alloc>
6099 __str.append(__rhs);
6109 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6110 basic_string<_CharT,_Traits,_Alloc>
6112 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6120 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6121 basic_string<_CharT,_Traits,_Alloc>
6122 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6130 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6131 inline basic_string<_CharT, _Traits, _Alloc>
6133 const _CharT* __rhs)
6136 __str.append(__rhs);
6146 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6147 inline basic_string<_CharT, _Traits, _Alloc>
6151 typedef typename __string_type::size_type __size_type;
6152 __string_type __str(__lhs);
6153 __str.append(__size_type(1), __rhs);
6157#if __cplusplus >= 201103L
6158 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6159 inline basic_string<_CharT, _Traits, _Alloc>
6160 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6161 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6162 {
return std::move(__lhs.append(__rhs)); }
6164 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6165 inline basic_string<_CharT, _Traits, _Alloc>
6166 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6167 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6168 {
return std::move(__rhs.insert(0, __lhs)); }
6170 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6171 inline basic_string<_CharT, _Traits, _Alloc>
6172 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6173 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6175#if _GLIBCXX_USE_CXX11_ABI
6176 using _Alloc_traits = allocator_traits<_Alloc>;
6177 bool __use_rhs =
false;
6178 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6180 else if (__lhs.get_allocator() == __rhs.get_allocator())
6185 const auto __size = __lhs.size() + __rhs.size();
6186 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6187 return std::move(__rhs.insert(0, __lhs));
6192 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6193 inline basic_string<_CharT, _Traits, _Alloc>
6195 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6196 {
return std::move(__rhs.insert(0, __lhs)); }
6198 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6199 inline basic_string<_CharT, _Traits, _Alloc>
6201 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6202 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6204 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6205 inline basic_string<_CharT, _Traits, _Alloc>
6206 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6207 const _CharT* __rhs)
6208 {
return std::move(__lhs.append(__rhs)); }
6210 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6211 inline basic_string<_CharT, _Traits, _Alloc>
6212 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6214 {
return std::move(__lhs.append(1, __rhs)); }
6224 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6229 {
return __lhs.compare(__rhs) == 0; }
6231 template<
typename _CharT>
6233 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6234 operator==(
const basic_string<_CharT>& __lhs,
6235 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6236 {
return (__lhs.size() == __rhs.size()
6246 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6249 const _CharT* __rhs)
6250 {
return __lhs.compare(__rhs) == 0; }
6252#if __cpp_lib_three_way_comparison
6260 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6262 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6263 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
6264 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6265 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6276 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6277 const _CharT* __rhs)
noexcept
6278 ->
decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6279 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6289 operator==(
const _CharT* __lhs,
6291 {
return __rhs.compare(__lhs) == 0; }
6300 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6305 {
return !(__lhs == __rhs); }
6313 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6315 operator!=(
const _CharT* __lhs,
6317 {
return !(__lhs == __rhs); }
6325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6328 const _CharT* __rhs)
6329 {
return !(__lhs == __rhs); }
6338 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6343 {
return __lhs.compare(__rhs) < 0; }
6351 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6354 const _CharT* __rhs)
6355 {
return __lhs.compare(__rhs) < 0; }
6363 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6365 operator<(
const _CharT* __lhs,
6367 {
return __rhs.compare(__lhs) > 0; }
6376 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6381 {
return __lhs.compare(__rhs) > 0; }
6389 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6392 const _CharT* __rhs)
6393 {
return __lhs.compare(__rhs) > 0; }
6401 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6403 operator>(
const _CharT* __lhs,
6405 {
return __rhs.compare(__lhs) < 0; }
6414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6419 {
return __lhs.compare(__rhs) <= 0; }
6427 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6430 const _CharT* __rhs)
6431 {
return __lhs.compare(__rhs) <= 0; }
6439 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6441 operator<=(
const _CharT* __lhs,
6443 {
return __rhs.compare(__lhs) >= 0; }
6452 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6457 {
return __lhs.compare(__rhs) >= 0; }
6465 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6468 const _CharT* __rhs)
6469 {
return __lhs.compare(__rhs) >= 0; }
6477 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6479 operator>=(
const _CharT* __lhs,
6481 {
return __rhs.compare(__lhs) <= 0; }
6491 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6495 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
6496 { __lhs.swap(__rhs); }
6511 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6512 basic_istream<_CharT, _Traits>&
6513 operator>>(basic_istream<_CharT, _Traits>& __is,
6514 basic_string<_CharT, _Traits, _Alloc>& __str);
6517 basic_istream<char>&
6529 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6536 return __ostream_insert(__os, __str.data(), __str.size());
6552 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6553 basic_istream<_CharT, _Traits>&
6554 getline(basic_istream<_CharT, _Traits>& __is,
6555 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6569 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6570 inline basic_istream<_CharT, _Traits>&
6575#if __cplusplus >= 201103L
6577 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6578 inline basic_istream<_CharT, _Traits>&
6584 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6585 inline basic_istream<_CharT, _Traits>&
6592 basic_istream<char>&
6593 getline(basic_istream<char>& __in, basic_string<char>& __str,
6596#ifdef _GLIBCXX_USE_WCHAR_T
6598 basic_istream<wchar_t>&
6599 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6603_GLIBCXX_END_NAMESPACE_VERSION
6606#if __cplusplus >= 201103L
6611namespace std _GLIBCXX_VISIBILITY(default)
6613_GLIBCXX_BEGIN_NAMESPACE_VERSION
6614_GLIBCXX_BEGIN_NAMESPACE_CXX11
6616#if _GLIBCXX_USE_C99_STDLIB
6619 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6620 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6624 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6625 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6628 inline unsigned long
6629 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6630 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6634 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6635 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6638 inline unsigned long long
6639 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6640 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6645 stof(
const string& __str,
size_t* __idx = 0)
6646 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6649 stod(
const string& __str,
size_t* __idx = 0)
6650 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6653 stold(
const string& __str,
size_t* __idx = 0)
6654 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6660 to_string(
int __val)
6662 const bool __neg = __val < 0;
6663 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6664 const auto __len = __detail::__to_chars_len(__uval);
6665 string __str(__neg + __len,
'-');
6666 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6671 to_string(
unsigned __val)
6673 string __str(__detail::__to_chars_len(__val),
'\0');
6674 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6679 to_string(
long __val)
6681 const bool __neg = __val < 0;
6682 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6683 const auto __len = __detail::__to_chars_len(__uval);
6684 string __str(__neg + __len,
'-');
6685 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6690 to_string(
unsigned long __val)
6692 string __str(__detail::__to_chars_len(__val),
'\0');
6693 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6698 to_string(
long long __val)
6700 const bool __neg = __val < 0;
6701 const unsigned long long __uval
6702 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6703 const auto __len = __detail::__to_chars_len(__uval);
6704 string __str(__neg + __len,
'-');
6705 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6710 to_string(
unsigned long long __val)
6712 string __str(__detail::__to_chars_len(__val),
'\0');
6713 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6717#if _GLIBCXX_USE_C99_STDIO
6721 to_string(
float __val)
6724 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6725 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6730 to_string(
double __val)
6733 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6734 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6739 to_string(
long double __val)
6742 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6743 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6748#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6750 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6751 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6755 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6756 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6759 inline unsigned long
6760 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6761 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6765 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6766 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6769 inline unsigned long long
6770 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6771 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6776 stof(
const wstring& __str,
size_t* __idx = 0)
6777 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6780 stod(
const wstring& __str,
size_t* __idx = 0)
6781 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6784 stold(
const wstring& __str,
size_t* __idx = 0)
6785 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6787#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6790 to_wstring(
int __val)
6791 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6795 to_wstring(
unsigned __val)
6796 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6797 4 *
sizeof(
unsigned),
6801 to_wstring(
long __val)
6802 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6806 to_wstring(
unsigned long __val)
6807 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6808 4 *
sizeof(
unsigned long),
6812 to_wstring(
long long __val)
6813 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6814 4 *
sizeof(
long long),
6818 to_wstring(
unsigned long long __val)
6819 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6820 4 *
sizeof(
unsigned long long),
6824 to_wstring(
float __val)
6827 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6828 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6833 to_wstring(
double __val)
6836 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6837 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6842 to_wstring(
long double __val)
6845 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6846 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6852_GLIBCXX_END_NAMESPACE_CXX11
6853_GLIBCXX_END_NAMESPACE_VERSION
6858#if __cplusplus >= 201103L
6862namespace std _GLIBCXX_VISIBILITY(default)
6864_GLIBCXX_BEGIN_NAMESPACE_VERSION
6868#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6872 :
public __hash_base<size_t, string>
6875 operator()(
const string& __s)
const noexcept
6876 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6883#ifdef _GLIBCXX_USE_WCHAR_T
6887 :
public __hash_base<size_t, wstring>
6890 operator()(
const wstring& __s)
const noexcept
6891 {
return std::_Hash_impl::hash(__s.
data(),
6892 __s.
length() *
sizeof(
wchar_t)); }
6901#ifdef _GLIBCXX_USE_CHAR8_T
6904 struct hash<u8string>
6905 :
public __hash_base<size_t, u8string>
6908 operator()(
const u8string& __s)
const noexcept
6909 {
return std::_Hash_impl::hash(__s.data(),
6910 __s.length() *
sizeof(
char8_t)); }
6921 :
public __hash_base<size_t, u16string>
6924 operator()(
const u16string& __s)
const noexcept
6925 {
return std::_Hash_impl::hash(__s.
data(),
6926 __s.
length() *
sizeof(
char16_t)); }
6936 :
public __hash_base<size_t, u32string>
6939 operator()(
const u32string& __s)
const noexcept
6940 {
return std::_Hash_impl::hash(__s.
data(),
6941 __s.
length() *
sizeof(
char32_t)); }
6948#if __cplusplus >= 201402L
6950#define __cpp_lib_string_udls 201304
6952 inline namespace literals
6954 inline namespace string_literals
6956#pragma GCC diagnostic push
6957#pragma GCC diagnostic ignored "-Wliteral-suffix"
6958 _GLIBCXX_DEFAULT_ABI_TAG
6959 inline basic_string<char>
6960 operator""s(
const char* __str,
size_t __len)
6961 {
return basic_string<char>{__str, __len}; }
6963#ifdef _GLIBCXX_USE_WCHAR_T
6964 _GLIBCXX_DEFAULT_ABI_TAG
6965 inline basic_string<wchar_t>
6966 operator""s(
const wchar_t* __str,
size_t __len)
6967 {
return basic_string<wchar_t>{__str, __len}; }
6970#ifdef _GLIBCXX_USE_CHAR8_T
6971 _GLIBCXX_DEFAULT_ABI_TAG
6972 inline basic_string<char8_t>
6973 operator""s(
const char8_t* __str,
size_t __len)
6974 {
return basic_string<char8_t>{__str, __len}; }
6977 _GLIBCXX_DEFAULT_ABI_TAG
6978 inline basic_string<char16_t>
6979 operator""s(
const char16_t* __str,
size_t __len)
6980 {
return basic_string<char16_t>{__str, __len}; }
6982 _GLIBCXX_DEFAULT_ABI_TAG
6983 inline basic_string<char32_t>
6984 operator""s(
const char32_t* __str,
size_t __len)
6985 {
return basic_string<char32_t>{__str, __len}; }
6987#pragma GCC diagnostic pop
6991#if __cplusplus >= 201703L
6992 namespace __detail::__variant
6994 template<
typename>
struct _Never_valueless_alt;
6998 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6999 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
7001 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
7002 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
7009_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
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.
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.
Primary class template hash.
Uniform interface to all allocator types.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
_If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
_If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
_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.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
_If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
iterator erase(iterator __position)
Remove one character.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
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.
basic_string(const basic_string &__str)
Construct string with copy of value of str.
int compare(const basic_string &__str) const
Compare to a string.
_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.
_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.
_If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
const_reference front() const noexcept
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.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
reverse_iterator rbegin()
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
basic_string(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
_If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
void pop_back()
Remove the last character.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void reserve()
Equivalent to shrink_to_fit().
_If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
_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.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
_If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator+=(_CharT __c)
Append a character.
const_reverse_iterator crend() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
_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.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
_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.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
bool empty() const noexcept
_If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
_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.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
_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.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_iterator cbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string() noexcept
Default constructor creates an empty string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
_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.
_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.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
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.
_CharT * data() noexcept
Return non-const pointer to contents.
basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
basic_string & append(const _CharT *__s)
Append a C string.
_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.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.