34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 #if _GLIBCXX_USE_CXX11_ABI
57 _GLIBCXX_BEGIN_NAMESPACE_CXX11
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
80 rebind<_CharT>::other _Char_alloc_type;
85 typedef _Traits traits_type;
86 typedef typename _Traits::char_type value_type;
87 typedef _Char_alloc_type allocator_type;
88 typedef typename _Alloc_traits::size_type size_type;
89 typedef typename _Alloc_traits::difference_type difference_type;
90 typedef typename _Alloc_traits::reference reference;
91 typedef typename _Alloc_traits::const_reference const_reference;
92 typedef typename _Alloc_traits::pointer pointer;
93 typedef typename _Alloc_traits::const_pointer const_pointer;
94 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
95 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
101 static const size_type
npos =
static_cast<size_type
>(-1);
105 #if __cplusplus < 201103L
106 typedef iterator __const_iterator;
108 typedef const_iterator __const_iterator;
112 #if __cplusplus >= 201703L
114 typedef basic_string_view<_CharT, _Traits> __sv_type;
116 template<
typename _Tp,
typename _Res>
118 __and_<is_convertible<const _Tp&, __sv_type>,
119 __not_<is_convertible<const _Tp*, const basic_string*>>,
120 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
125 _S_to_string_view(__sv_type __svt) noexcept
134 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
150 struct _Alloc_hider : allocator_type
152 #if __cplusplus < 201103L
153 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
154 : allocator_type(__a), _M_p(__dat) { }
156 _Alloc_hider(pointer __dat,
const _Alloc& __a)
157 : allocator_type(__a), _M_p(__dat) { }
159 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
160 : allocator_type(
std::move(__a)), _M_p(__dat) { }
166 _Alloc_hider _M_dataplus;
167 size_type _M_string_length;
169 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
173 _CharT _M_local_buf[_S_local_capacity + 1];
174 size_type _M_allocated_capacity;
179 { _M_dataplus._M_p = __p; }
182 _M_length(size_type __length)
183 { _M_string_length = __length; }
187 {
return _M_dataplus._M_p; }
192 #if __cplusplus >= 201103L
195 return pointer(_M_local_buf);
200 _M_local_data()
const
202 #if __cplusplus >= 201103L
205 return const_pointer(_M_local_buf);
210 _M_capacity(size_type __capacity)
211 { _M_allocated_capacity = __capacity; }
214 _M_set_length(size_type __n)
217 traits_type::assign(_M_data()[__n], _CharT());
222 {
return _M_data() == _M_local_data(); }
226 _M_create(size_type&, size_type);
232 _M_destroy(_M_allocated_capacity);
236 _M_destroy(size_type __size)
throw()
237 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
241 template<
typename _InIterator>
243 _M_construct_aux(_InIterator __beg, _InIterator __end,
246 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
247 _M_construct(__beg, __end, _Tag());
252 template<
typename _Integer>
254 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
255 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
258 _M_construct_aux_2(size_type __req, _CharT __c)
259 { _M_construct(__req, __c); }
261 template<
typename _InIterator>
263 _M_construct(_InIterator __beg, _InIterator __end)
265 typedef typename std::__is_integer<_InIterator>::__type _Integral;
266 _M_construct_aux(__beg, __end, _Integral());
270 template<
typename _InIterator>
272 _M_construct(_InIterator __beg, _InIterator __end,
277 template<
typename _FwdIterator>
279 _M_construct(_FwdIterator __beg, _FwdIterator __end,
283 _M_construct(size_type __req, _CharT __c);
287 {
return _M_dataplus; }
289 const allocator_type&
290 _M_get_allocator()
const
291 {
return _M_dataplus; }
295 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
298 template<
typename _Tp,
bool _Requires =
299 !__are_same<_Tp, _CharT*>::__value
300 && !__are_same<_Tp, const _CharT*>::__value
301 && !__are_same<_Tp, iterator>::__value
302 && !__are_same<_Tp, const_iterator>::__value>
303 struct __enable_if_not_native_iterator
305 template<
typename _Tp>
306 struct __enable_if_not_native_iterator<_Tp, false> { };
310 _M_check(size_type __pos,
const char* __s)
const
312 if (__pos > this->
size())
313 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
314 "this->size() (which is %zu)"),
315 __s, __pos, this->
size());
320 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
323 __throw_length_error(__N(__s));
329 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
331 const bool __testoff = __off < this->
size() - __pos;
332 return __testoff ? __off : this->
size() - __pos;
337 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
339 return (less<const _CharT*>()(__s, _M_data())
340 || less<const _CharT*>()(_M_data() + this->
size(), __s));
346 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
349 traits_type::assign(*__d, *__s);
351 traits_type::copy(__d, __s, __n);
355 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
358 traits_type::assign(*__d, *__s);
360 traits_type::move(__d, __s, __n);
364 _S_assign(_CharT* __d, size_type __n, _CharT __c)
367 traits_type::assign(*__d, __c);
369 traits_type::assign(__d, __n, __c);
374 template<
class _Iterator>
376 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
378 for (; __k1 != __k2; ++__k1, (void)++__p)
379 traits_type::assign(*__p, *__k1);
383 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
384 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
387 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
389 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
392 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
393 { _S_copy(__p, __k1, __k2 - __k1); }
396 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
398 { _S_copy(__p, __k1, __k2 - __k1); }
401 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
403 const difference_type __d = difference_type(__n1 - __n2);
405 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
406 return __gnu_cxx::__numeric_traits<int>::__max;
407 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
408 return __gnu_cxx::__numeric_traits<int>::__min;
417 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
421 _M_erase(size_type __pos, size_type __n);
432 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
433 : _M_dataplus(_M_local_data())
434 { _M_set_length(0); }
441 : _M_dataplus(_M_local_data(), __a)
442 { _M_set_length(0); }
449 : _M_dataplus(_M_local_data(),
450 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
451 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
462 const _Alloc& __a = _Alloc())
463 : _M_dataplus(_M_local_data(), __a)
465 const _CharT* __start = __str._M_data()
466 + __str._M_check(__pos,
"basic_string::basic_string");
467 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
478 : _M_dataplus(_M_local_data())
480 const _CharT* __start = __str._M_data()
481 + __str._M_check(__pos,
"basic_string::basic_string");
482 _M_construct(__start, __start + __str._M_limit(__pos, __n));
493 size_type __n,
const _Alloc& __a)
494 : _M_dataplus(_M_local_data(), __a)
496 const _CharT* __start
497 = __str._M_data() + __str._M_check(__pos,
"string::string");
498 _M_construct(__start, __start + __str._M_limit(__pos, __n));
511 const _Alloc& __a = _Alloc())
512 : _M_dataplus(_M_local_data(), __a)
513 { _M_construct(__s, __s + __n); }
520 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
523 template<
typename = _RequireAllocator<_Alloc>>
525 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
526 : _M_dataplus(_M_local_data(), __a)
527 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
535 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
538 template<
typename = _RequireAllocator<_Alloc>>
540 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
541 : _M_dataplus(_M_local_data(), __a)
542 { _M_construct(__n, __c); }
544 #if __cplusplus >= 201103L
553 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
555 if (__str._M_is_local())
557 traits_type::copy(_M_local_buf, __str._M_local_buf,
558 _S_local_capacity + 1);
562 _M_data(__str._M_data());
563 _M_capacity(__str._M_allocated_capacity);
569 _M_length(__str.length());
570 __str._M_data(__str._M_local_data());
571 __str._M_set_length(0);
579 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
580 : _M_dataplus(_M_local_data(), __a)
581 { _M_construct(__l.begin(), __l.end()); }
584 : _M_dataplus(_M_local_data(), __a)
585 { _M_construct(__str.begin(), __str.end()); }
588 noexcept(_Alloc_traits::_S_always_equal())
589 : _M_dataplus(_M_local_data(), __a)
591 if (__str._M_is_local())
593 traits_type::copy(_M_local_buf, __str._M_local_buf,
594 _S_local_capacity + 1);
595 _M_length(__str.length());
596 __str._M_set_length(0);
598 else if (_Alloc_traits::_S_always_equal()
599 || __str.get_allocator() == __a)
601 _M_data(__str._M_data());
602 _M_length(__str.length());
603 _M_capacity(__str._M_allocated_capacity);
604 __str._M_data(__str._M_local_buf);
605 __str._M_set_length(0);
608 _M_construct(__str.begin(), __str.end());
619 #if __cplusplus >= 201103L
620 template<
typename _InputIterator,
621 typename = std::_RequireInputIter<_InputIterator>>
623 template<
typename _InputIterator>
625 basic_string(_InputIterator __beg, _InputIterator __end,
626 const _Alloc& __a = _Alloc())
627 : _M_dataplus(_M_local_data(), __a)
628 { _M_construct(__beg, __end); }
630 #if __cplusplus >= 201703L
638 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
639 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
640 const _Alloc& __a = _Alloc())
648 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
650 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
651 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
667 #if __cplusplus >= 201103L
668 if (_Alloc_traits::_S_propagate_on_copy_assign())
670 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
671 && _M_get_allocator() != __str._M_get_allocator())
675 if (__str.size() <= _S_local_capacity)
677 _M_destroy(_M_allocated_capacity);
678 _M_data(_M_local_data());
683 const auto __len = __str.size();
684 auto __alloc = __str._M_get_allocator();
686 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
687 _M_destroy(_M_allocated_capacity);
690 _M_set_length(__len);
693 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
696 return this->
assign(__str);
705 {
return this->
assign(__s); }
721 #if __cplusplus >= 201103L
733 noexcept(_Alloc_traits::_S_nothrow_move())
735 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
736 && !_Alloc_traits::_S_always_equal()
737 && _M_get_allocator() != __str._M_get_allocator())
740 _M_destroy(_M_allocated_capacity);
741 _M_data(_M_local_data());
745 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
747 if (__str._M_is_local())
751 this->_S_copy(_M_data(), __str._M_data(), __str.size());
752 _M_set_length(__str.size());
754 else if (_Alloc_traits::_S_propagate_on_move_assign()
755 || _Alloc_traits::_S_always_equal()
756 || _M_get_allocator() == __str._M_get_allocator())
759 pointer __data =
nullptr;
760 size_type __capacity;
763 if (_Alloc_traits::_S_always_equal())
767 __capacity = _M_allocated_capacity;
770 _M_destroy(_M_allocated_capacity);
773 _M_data(__str._M_data());
774 _M_length(__str.length());
775 _M_capacity(__str._M_allocated_capacity);
778 __str._M_data(__data);
779 __str._M_capacity(__capacity);
782 __str._M_data(__str._M_local_buf);
797 this->
assign(__l.begin(), __l.size());
802 #if __cplusplus >= 201703L
807 template<
typename _Tp>
808 _If_sv<_Tp, basic_string&>
810 {
return this->
assign(__svt); }
816 operator __sv_type() const noexcept
817 {
return __sv_type(
data(),
size()); }
826 begin() _GLIBCXX_NOEXCEPT
827 {
return iterator(_M_data()); }
834 begin() const _GLIBCXX_NOEXCEPT
835 {
return const_iterator(_M_data()); }
842 end() _GLIBCXX_NOEXCEPT
843 {
return iterator(_M_data() + this->
size()); }
850 end() const _GLIBCXX_NOEXCEPT
851 {
return const_iterator(_M_data() + this->
size()); }
859 rbegin() _GLIBCXX_NOEXCEPT
860 {
return reverse_iterator(this->
end()); }
867 const_reverse_iterator
868 rbegin() const _GLIBCXX_NOEXCEPT
869 {
return const_reverse_iterator(this->
end()); }
877 rend() _GLIBCXX_NOEXCEPT
878 {
return reverse_iterator(this->
begin()); }
885 const_reverse_iterator
886 rend() const _GLIBCXX_NOEXCEPT
887 {
return const_reverse_iterator(this->
begin()); }
889 #if __cplusplus >= 201103L
896 {
return const_iterator(this->_M_data()); }
903 cend() const noexcept
904 {
return const_iterator(this->_M_data() + this->
size()); }
911 const_reverse_iterator
913 {
return const_reverse_iterator(this->
end()); }
920 const_reverse_iterator
921 crend() const noexcept
922 {
return const_reverse_iterator(this->
begin()); }
930 size() const _GLIBCXX_NOEXCEPT
931 {
return _M_string_length; }
936 length() const _GLIBCXX_NOEXCEPT
937 {
return _M_string_length; }
942 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
955 resize(size_type __n, _CharT __c);
969 { this->
resize(__n, _CharT()); }
971 #if __cplusplus >= 201103L
995 return _M_is_local() ? size_type(_S_local_capacity)
996 : _M_allocated_capacity;
1017 reserve(size_type __res_arg = 0);
1023 clear() _GLIBCXX_NOEXCEPT
1024 { _M_set_length(0); }
1030 _GLIBCXX_NODISCARD
bool
1031 empty() const _GLIBCXX_NOEXCEPT
1032 {
return this->
size() == 0; }
1046 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1048 __glibcxx_assert(__pos <=
size());
1049 return _M_data()[__pos];
1067 __glibcxx_assert(__pos <=
size());
1069 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1070 return _M_data()[__pos];
1084 at(size_type __n)
const
1086 if (__n >= this->
size())
1087 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1088 "(which is %zu) >= this->size() "
1091 return _M_data()[__n];
1108 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1109 "(which is %zu) >= this->size() "
1112 return _M_data()[__n];
1115 #if __cplusplus >= 201103L
1123 __glibcxx_assert(!
empty());
1132 front() const noexcept
1134 __glibcxx_assert(!
empty());
1145 __glibcxx_assert(!
empty());
1154 back() const noexcept
1156 __glibcxx_assert(!
empty());
1169 {
return this->
append(__str); }
1178 {
return this->
append(__s); }
1192 #if __cplusplus >= 201103L
1200 {
return this->
append(__l.begin(), __l.size()); }
1203 #if __cplusplus >= 201703L
1209 template<
typename _Tp>
1210 _If_sv<_Tp, basic_string&>
1212 {
return this->
append(__svt); }
1222 {
return _M_append(__str._M_data(), __str.size()); }
1239 {
return _M_append(__str._M_data()
1240 + __str._M_check(__pos,
"basic_string::append"),
1241 __str._M_limit(__pos, __n)); }
1250 append(
const _CharT* __s, size_type __n)
1252 __glibcxx_requires_string_len(__s, __n);
1253 _M_check_length(size_type(0), __n,
"basic_string::append");
1254 return _M_append(__s, __n);
1263 append(
const _CharT* __s)
1265 __glibcxx_requires_string(__s);
1266 const size_type __n = traits_type::length(__s);
1267 _M_check_length(size_type(0), __n,
"basic_string::append");
1268 return _M_append(__s, __n);
1280 append(size_type __n, _CharT __c)
1281 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1283 #if __cplusplus >= 201103L
1290 append(initializer_list<_CharT> __l)
1291 {
return this->
append(__l.begin(), __l.size()); }
1302 #if __cplusplus >= 201103L
1303 template<
class _InputIterator,
1304 typename = std::_RequireInputIter<_InputIterator>>
1306 template<
class _InputIterator>
1309 append(_InputIterator __first, _InputIterator __last)
1312 #if __cplusplus >= 201703L
1318 template<
typename _Tp>
1319 _If_sv<_Tp, basic_string&>
1322 __sv_type __sv = __svt;
1323 return this->
append(__sv.data(), __sv.size());
1333 template<
typename _Tp>
1334 _If_sv<_Tp, basic_string&>
1335 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1337 __sv_type __sv = __svt;
1338 return _M_append(__sv.data()
1339 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1340 std::__sv_limit(__sv.size(), __pos, __n));
1351 const size_type __size = this->
size();
1353 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1354 traits_type::assign(this->_M_data()[__size], __c);
1355 this->_M_set_length(__size + 1);
1366 this->_M_assign(__str);
1370 #if __cplusplus >= 201103L
1381 noexcept(_Alloc_traits::_S_nothrow_move())
1385 return *
this = std::move(__str);
1404 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1405 + __str._M_check(__pos,
"basic_string::assign"),
1406 __str._M_limit(__pos, __n)); }
1419 assign(
const _CharT* __s, size_type __n)
1421 __glibcxx_requires_string_len(__s, __n);
1422 return _M_replace(size_type(0), this->
size(), __s, __n);
1435 assign(
const _CharT* __s)
1437 __glibcxx_requires_string(__s);
1438 return _M_replace(size_type(0), this->
size(), __s,
1439 traits_type::length(__s));
1452 assign(size_type __n, _CharT __c)
1453 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1463 #if __cplusplus >= 201103L
1464 template<
class _InputIterator,
1465 typename = std::_RequireInputIter<_InputIterator>>
1467 template<
class _InputIterator>
1470 assign(_InputIterator __first, _InputIterator __last)
1473 #if __cplusplus >= 201103L
1480 assign(initializer_list<_CharT> __l)
1481 {
return this->
assign(__l.begin(), __l.size()); }
1484 #if __cplusplus >= 201703L
1490 template<
typename _Tp>
1491 _If_sv<_Tp, basic_string&>
1494 __sv_type __sv = __svt;
1495 return this->
assign(__sv.data(), __sv.size());
1505 template<
typename _Tp>
1506 _If_sv<_Tp, basic_string&>
1507 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1509 __sv_type __sv = __svt;
1510 return _M_replace(size_type(0), this->
size(),
1512 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1513 std::__sv_limit(__sv.size(), __pos, __n));
1517 #if __cplusplus >= 201103L
1534 insert(const_iterator __p, size_type __n, _CharT __c)
1536 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1537 const size_type __pos = __p -
begin();
1538 this->
replace(__p, __p, __n, __c);
1539 return iterator(this->_M_data() + __pos);
1556 insert(iterator __p, size_type __n, _CharT __c)
1557 { this->
replace(__p, __p, __n, __c); }
1560 #if __cplusplus >= 201103L
1575 template<
class _InputIterator,
1576 typename = std::_RequireInputIter<_InputIterator>>
1578 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1580 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1581 const size_type __pos = __p -
begin();
1582 this->
replace(__p, __p, __beg, __end);
1583 return iterator(this->_M_data() + __pos);
1598 template<
class _InputIterator>
1600 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1601 { this->
replace(__p, __p, __beg, __end); }
1604 #if __cplusplus >= 201103L
1612 insert(const_iterator __p, initializer_list<_CharT> __l)
1613 {
return this->
insert(__p, __l.begin(), __l.end()); }
1615 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1618 insert(iterator __p, initializer_list<_CharT> __l)
1620 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1621 this->
insert(__p -
begin(), __l.begin(), __l.size());
1640 {
return this->
replace(__pos1, size_type(0),
1641 __str._M_data(), __str.size()); }
1663 size_type __pos2, size_type __n =
npos)
1664 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1665 + __str._M_check(__pos2,
"basic_string::insert"),
1666 __str._M_limit(__pos2, __n)); }
1685 insert(size_type __pos,
const _CharT* __s, size_type __n)
1686 {
return this->
replace(__pos, size_type(0), __s, __n); }
1704 insert(size_type __pos,
const _CharT* __s)
1706 __glibcxx_requires_string(__s);
1707 return this->
replace(__pos, size_type(0), __s,
1708 traits_type::length(__s));
1728 insert(size_type __pos, size_type __n, _CharT __c)
1729 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1730 size_type(0), __n, __c); }
1746 insert(__const_iterator __p, _CharT __c)
1748 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1749 const size_type __pos = __p -
begin();
1750 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1751 return iterator(_M_data() + __pos);
1754 #if __cplusplus >= 201703L
1761 template<
typename _Tp>
1762 _If_sv<_Tp, basic_string&>
1763 insert(size_type __pos,
const _Tp& __svt)
1765 __sv_type __sv = __svt;
1766 return this->
insert(__pos, __sv.data(), __sv.size());
1778 template<
typename _Tp>
1779 _If_sv<_Tp, basic_string&>
1780 insert(size_type __pos1,
const _Tp& __svt,
1781 size_type __pos2, size_type __n =
npos)
1783 __sv_type __sv = __svt;
1784 return this->
replace(__pos1, size_type(0),
1786 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1787 std::__sv_limit(__sv.size(), __pos2, __n));
1807 erase(size_type __pos = 0, size_type __n =
npos)
1809 _M_check(__pos,
"basic_string::erase");
1811 this->_M_set_length(__pos);
1813 this->_M_erase(__pos, _M_limit(__pos, __n));
1826 erase(__const_iterator __position)
1828 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1829 && __position <
end());
1830 const size_type __pos = __position -
begin();
1831 this->_M_erase(__pos, size_type(1));
1832 return iterator(_M_data() + __pos);
1845 erase(__const_iterator __first, __const_iterator __last)
1847 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1848 && __last <=
end());
1849 const size_type __pos = __first -
begin();
1850 if (__last ==
end())
1851 this->_M_set_length(__pos);
1853 this->_M_erase(__pos, __last - __first);
1854 return iterator(this->_M_data() + __pos);
1857 #if __cplusplus >= 201103L
1866 __glibcxx_assert(!
empty());
1867 _M_erase(
size() - 1, 1);
1890 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1912 size_type __pos2, size_type __n2 =
npos)
1913 {
return this->
replace(__pos1, __n1, __str._M_data()
1914 + __str._M_check(__pos2,
"basic_string::replace"),
1915 __str._M_limit(__pos2, __n2)); }
1936 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1939 __glibcxx_requires_string_len(__s, __n2);
1940 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1941 _M_limit(__pos, __n1), __s, __n2);
1961 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1963 __glibcxx_requires_string(__s);
1964 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1985 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1986 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1987 _M_limit(__pos, __n1), __n2, __c); }
2003 replace(__const_iterator __i1, __const_iterator __i2,
2005 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2023 replace(__const_iterator __i1, __const_iterator __i2,
2024 const _CharT* __s, size_type __n)
2026 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2028 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2045 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2047 __glibcxx_requires_string(__s);
2048 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2066 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2069 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2071 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2089 #if __cplusplus >= 201103L
2090 template<
class _InputIterator,
2091 typename = std::_RequireInputIter<_InputIterator>>
2093 replace(const_iterator __i1, const_iterator __i2,
2094 _InputIterator __k1, _InputIterator __k2)
2096 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2098 __glibcxx_requires_valid_range(__k1, __k2);
2099 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2100 std::__false_type());
2103 template<
class _InputIterator>
2104 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2105 typename __enable_if_not_native_iterator<_InputIterator>::__type
2109 replace(iterator __i1, iterator __i2,
2110 _InputIterator __k1, _InputIterator __k2)
2112 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2114 __glibcxx_requires_valid_range(__k1, __k2);
2115 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2116 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2123 replace(__const_iterator __i1, __const_iterator __i2,
2124 _CharT* __k1, _CharT* __k2)
2126 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2128 __glibcxx_requires_valid_range(__k1, __k2);
2134 replace(__const_iterator __i1, __const_iterator __i2,
2135 const _CharT* __k1,
const _CharT* __k2)
2137 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2139 __glibcxx_requires_valid_range(__k1, __k2);
2145 replace(__const_iterator __i1, __const_iterator __i2,
2146 iterator __k1, iterator __k2)
2148 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2150 __glibcxx_requires_valid_range(__k1, __k2);
2152 __k1.base(), __k2 - __k1);
2156 replace(__const_iterator __i1, __const_iterator __i2,
2157 const_iterator __k1, const_iterator __k2)
2159 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2161 __glibcxx_requires_valid_range(__k1, __k2);
2163 __k1.base(), __k2 - __k1);
2166 #if __cplusplus >= 201103L
2182 initializer_list<_CharT> __l)
2183 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2186 #if __cplusplus >= 201703L
2194 template<
typename _Tp>
2195 _If_sv<_Tp, basic_string&>
2196 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2198 __sv_type __sv = __svt;
2199 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2211 template<
typename _Tp>
2212 _If_sv<_Tp, basic_string&>
2213 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2214 size_type __pos2, size_type __n2 =
npos)
2216 __sv_type __sv = __svt;
2217 return this->
replace(__pos1, __n1,
2219 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2220 std::__sv_limit(__sv.size(), __pos2, __n2));
2232 template<
typename _Tp>
2233 _If_sv<_Tp, basic_string&>
2234 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2236 __sv_type __sv = __svt;
2237 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2242 template<
class _Integer>
2244 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2245 _Integer __n, _Integer __val, __true_type)
2246 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2248 template<
class _InputIterator>
2250 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2251 _InputIterator __k1, _InputIterator __k2,
2255 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2259 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2260 const size_type __len2);
2263 _M_append(
const _CharT* __s, size_type __n);
2280 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2300 c_str() const _GLIBCXX_NOEXCEPT
2301 {
return _M_data(); }
2312 data() const _GLIBCXX_NOEXCEPT
2313 {
return _M_data(); }
2315 #if __cplusplus >= 201703L
2324 {
return _M_data(); }
2332 {
return _M_get_allocator(); }
2347 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2363 {
return this->
find(__str.data(), __pos, __str.size()); }
2365 #if __cplusplus >= 201703L
2372 template<
typename _Tp>
2373 _If_sv<_Tp, size_type>
2374 find(
const _Tp& __svt, size_type __pos = 0) const
2375 noexcept(is_same<_Tp, __sv_type>::value)
2377 __sv_type __sv = __svt;
2378 return this->
find(__sv.data(), __pos, __sv.size());
2393 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2395 __glibcxx_requires_string(__s);
2396 return this->
find(__s, __pos, traits_type::length(__s));
2410 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2425 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2427 #if __cplusplus >= 201703L
2434 template<
typename _Tp>
2435 _If_sv<_Tp, size_type>
2436 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2437 noexcept(is_same<_Tp, __sv_type>::value)
2439 __sv_type __sv = __svt;
2440 return this->
rfind(__sv.data(), __pos, __sv.size());
2457 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2471 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2473 __glibcxx_requires_string(__s);
2474 return this->
rfind(__s, __pos, traits_type::length(__s));
2488 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2504 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2506 #if __cplusplus >= 201703L
2514 template<
typename _Tp>
2515 _If_sv<_Tp, size_type>
2517 noexcept(is_same<_Tp, __sv_type>::value)
2519 __sv_type __sv = __svt;
2520 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2537 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2554 __glibcxx_requires_string(__s);
2555 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2571 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2572 {
return this->
find(__c, __pos); }
2588 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2590 #if __cplusplus >= 201703L
2598 template<
typename _Tp>
2599 _If_sv<_Tp, size_type>
2601 noexcept(is_same<_Tp, __sv_type>::value)
2603 __sv_type __sv = __svt;
2604 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2621 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2638 __glibcxx_requires_string(__s);
2639 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2656 {
return this->
rfind(__c, __pos); }
2673 #if __cplusplus >= 201703L
2681 template<
typename _Tp>
2682 _If_sv<_Tp, size_type>
2684 noexcept(is_same<_Tp, __sv_type>::value)
2686 __sv_type __sv = __svt;
2705 size_type __n)
const _GLIBCXX_NOEXCEPT;
2721 __glibcxx_requires_string(__s);
2755 #if __cplusplus >= 201703L
2763 template<
typename _Tp>
2764 _If_sv<_Tp, size_type>
2766 noexcept(is_same<_Tp, __sv_type>::value)
2768 __sv_type __sv = __svt;
2787 size_type __n)
const _GLIBCXX_NOEXCEPT;
2803 __glibcxx_requires_string(__s);
2834 substr(size_type __pos = 0, size_type __n =
npos)
const
2836 _M_check(__pos,
"basic_string::substr"), __n); }
2855 const size_type __size = this->
size();
2856 const size_type __osize = __str.size();
2857 const size_type __len =
std::min(__size, __osize);
2859 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2861 __r = _S_compare(__size, __osize);
2865 #if __cplusplus >= 201703L
2871 template<
typename _Tp>
2873 compare(
const _Tp& __svt)
const
2874 noexcept(is_same<_Tp, __sv_type>::value)
2876 __sv_type __sv = __svt;
2877 const size_type __size = this->
size();
2878 const size_type __osize = __sv.size();
2879 const size_type __len =
std::min(__size, __osize);
2881 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2883 __r = _S_compare(__size, __osize);
2895 template<
typename _Tp>
2897 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2898 noexcept(is_same<_Tp, __sv_type>::value)
2900 __sv_type __sv = __svt;
2901 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2914 template<
typename _Tp>
2916 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2917 size_type __pos2, size_type __n2 =
npos)
const
2918 noexcept(is_same<_Tp, __sv_type>::value)
2920 __sv_type __sv = __svt;
2921 return __sv_type(*
this)
2922 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2973 size_type __pos2, size_type __n2 =
npos)
const;
2990 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3014 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3041 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3042 size_type __n2)
const;
3044 #if __cplusplus > 201703L
3046 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3047 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3050 starts_with(_CharT __x)
const noexcept
3051 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3054 starts_with(
const _CharT* __x)
const noexcept
3055 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3058 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3059 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3062 ends_with(_CharT __x)
const noexcept
3063 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3066 ends_with(
const _CharT* __x)
const noexcept
3067 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3071 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3073 _GLIBCXX_END_NAMESPACE_CXX11
3139 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3142 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3146 typedef _Traits traits_type;
3147 typedef typename _Traits::char_type value_type;
3148 typedef _Alloc allocator_type;
3149 typedef typename _CharT_alloc_type::size_type size_type;
3150 typedef typename _CharT_alloc_type::difference_type difference_type;
3151 #if __cplusplus < 201103L
3152 typedef typename _CharT_alloc_type::reference reference;
3153 typedef typename _CharT_alloc_type::const_reference const_reference;
3155 typedef value_type& reference;
3156 typedef const value_type& const_reference;
3158 typedef typename _CharT_alloc_type::pointer pointer;
3159 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3160 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3161 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3168 typedef iterator __const_iterator;
3187 size_type _M_length;
3188 size_type _M_capacity;
3189 _Atomic_word _M_refcount;
3192 struct _Rep : _Rep_base
3195 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3210 static const size_type _S_max_size;
3211 static const _CharT _S_terminal;
3215 static size_type _S_empty_rep_storage[];
3218 _S_empty_rep() _GLIBCXX_NOEXCEPT
3223 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3224 return *
reinterpret_cast<_Rep*
>(__p);
3228 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3230 #if defined(__GTHREADS)
3235 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3237 return this->_M_refcount < 0;
3242 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3244 #if defined(__GTHREADS)
3250 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3252 return this->_M_refcount > 0;
3257 _M_set_leaked() _GLIBCXX_NOEXCEPT
3258 { this->_M_refcount = -1; }
3261 _M_set_sharable() _GLIBCXX_NOEXCEPT
3262 { this->_M_refcount = 0; }
3265 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3267 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3268 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3271 this->_M_set_sharable();
3272 this->_M_length = __n;
3273 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3280 _M_refdata()
throw()
3281 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3284 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3286 return (!_M_is_leaked() && __alloc1 == __alloc2)
3287 ? _M_refcopy() : _M_clone(__alloc1);
3292 _S_create(size_type, size_type,
const _Alloc&);
3295 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3297 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3298 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3302 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3311 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3314 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3321 _M_destroy(
const _Alloc&)
throw();
3324 _M_refcopy()
throw()
3326 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3327 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3329 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3330 return _M_refdata();
3334 _M_clone(
const _Alloc&, size_type __res = 0);
3338 struct _Alloc_hider : _Alloc
3340 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3341 : _Alloc(__a), _M_p(__dat) { }
3351 static const size_type
npos =
static_cast<size_type
>(-1);
3355 mutable _Alloc_hider _M_dataplus;
3358 _M_data() const _GLIBCXX_NOEXCEPT
3359 {
return _M_dataplus._M_p; }
3362 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3363 {
return (_M_dataplus._M_p = __p); }
3366 _M_rep() const _GLIBCXX_NOEXCEPT
3367 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3372 _M_ibegin() const _GLIBCXX_NOEXCEPT
3373 {
return iterator(_M_data()); }
3376 _M_iend() const _GLIBCXX_NOEXCEPT
3377 {
return iterator(_M_data() + this->
size()); }
3382 if (!_M_rep()->_M_is_leaked())
3387 _M_check(size_type __pos,
const char* __s)
const
3389 if (__pos > this->
size())
3390 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3391 "this->size() (which is %zu)"),
3392 __s, __pos, this->
size());
3397 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3400 __throw_length_error(__N(__s));
3405 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3407 const bool __testoff = __off < this->
size() - __pos;
3408 return __testoff ? __off : this->
size() - __pos;
3413 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3415 return (less<const _CharT*>()(__s, _M_data())
3416 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3422 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3425 traits_type::assign(*__d, *__s);
3427 traits_type::copy(__d, __s, __n);
3431 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3434 traits_type::assign(*__d, *__s);
3436 traits_type::move(__d, __s, __n);
3440 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3443 traits_type::assign(*__d, __c);
3445 traits_type::assign(__d, __n, __c);
3450 template<
class _Iterator>
3452 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3454 for (; __k1 != __k2; ++__k1, (void)++__p)
3455 traits_type::assign(*__p, *__k1);
3459 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3460 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3463 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3465 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3468 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3469 { _M_copy(__p, __k1, __k2 - __k1); }
3472 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3474 { _M_copy(__p, __k1, __k2 - __k1); }
3477 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3479 const difference_type __d = difference_type(__n1 - __n2);
3481 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3482 return __gnu_cxx::__numeric_traits<int>::__max;
3483 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3484 return __gnu_cxx::__numeric_traits<int>::__min;
3490 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3496 _S_empty_rep() _GLIBCXX_NOEXCEPT
3497 {
return _Rep::_S_empty_rep(); }
3499 #if __cplusplus >= 201703L
3501 typedef basic_string_view<_CharT, _Traits> __sv_type;
3503 template<
typename _Tp,
typename _Res>
3505 __and_<is_convertible<const _Tp&, __sv_type>,
3506 __not_<is_convertible<const _Tp*, const basic_string*>>,
3507 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3512 _S_to_string_view(__sv_type __svt) noexcept
3521 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3545 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3547 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3549 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3575 const _Alloc& __a = _Alloc());
3593 size_type __n,
const _Alloc& __a);
3605 const _Alloc& __a = _Alloc());
3611 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3618 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3620 #if __cplusplus >= 201103L
3629 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3632 : _M_dataplus(std::move(__str._M_dataplus))
3634 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3635 __str._M_data(_S_empty_rep()._M_refdata());
3637 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3649 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3653 : _M_dataplus(__str._M_data(), __a)
3655 if (__a == __str.get_allocator())
3657 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3658 __str._M_data(_S_empty_rep()._M_refdata());
3660 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3664 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3674 template<
class _InputIterator>
3675 basic_string(_InputIterator __beg, _InputIterator __end,
3676 const _Alloc& __a = _Alloc());
3678 #if __cplusplus >= 201703L
3686 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3687 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3688 const _Alloc& __a = _Alloc())
3696 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3698 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3699 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3714 {
return this->
assign(__str); }
3722 {
return this->
assign(__s); }
3738 #if __cplusplus >= 201103L
3762 this->
assign(__l.begin(), __l.size());
3767 #if __cplusplus >= 201703L
3772 template<
typename _Tp>
3773 _If_sv<_Tp, basic_string&>
3775 {
return this->
assign(__svt); }
3781 operator __sv_type() const noexcept
3782 {
return __sv_type(
data(),
size()); }
3794 return iterator(_M_data());
3803 {
return const_iterator(_M_data()); }
3813 return iterator(_M_data() + this->
size());
3822 {
return const_iterator(_M_data() + this->
size()); }
3838 const_reverse_iterator
3856 const_reverse_iterator
3860 #if __cplusplus >= 201103L
3867 {
return const_iterator(this->_M_data()); }
3875 {
return const_iterator(this->_M_data() + this->
size()); }
3882 const_reverse_iterator
3891 const_reverse_iterator
3902 {
return _M_rep()->_M_length; }
3908 {
return _M_rep()->_M_length; }
3913 {
return _Rep::_S_max_size; }
3926 resize(size_type __n, _CharT __c);
3940 { this->
resize(__n, _CharT()); }
3942 #if __cplusplus >= 201103L
3947 #if __cpp_exceptions
3965 {
return _M_rep()->_M_capacity; }
3985 reserve(size_type __res_arg = 0);
3990 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3994 if (_M_rep()->_M_is_shared())
3997 _M_data(_S_empty_rep()._M_refdata());
4000 _M_rep()->_M_set_length_and_sharable(0);
4006 { _M_mutate(0, this->
size(), 0); }
4013 _GLIBCXX_NODISCARD
bool
4015 {
return this->
size() == 0; }
4031 __glibcxx_assert(__pos <=
size());
4032 return _M_data()[__pos];
4050 __glibcxx_assert(__pos <=
size());
4052 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4054 return _M_data()[__pos];
4070 if (__n >= this->
size())
4071 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4072 "(which is %zu) >= this->size() "
4075 return _M_data()[__n];
4093 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4094 "(which is %zu) >= this->size() "
4098 return _M_data()[__n];
4101 #if __cplusplus >= 201103L
4109 __glibcxx_assert(!
empty());
4120 __glibcxx_assert(!
empty());
4131 __glibcxx_assert(!
empty());
4142 __glibcxx_assert(!
empty());
4155 {
return this->
append(__str); }
4164 {
return this->
append(__s); }
4178 #if __cplusplus >= 201103L
4186 {
return this->
append(__l.begin(), __l.size()); }
4189 #if __cplusplus >= 201703L
4195 template<
typename _Tp>
4196 _If_sv<_Tp, basic_string&>
4198 {
return this->
append(__svt); }
4232 append(
const _CharT* __s, size_type __n);
4242 __glibcxx_requires_string(__s);
4243 return this->
append(__s, traits_type::length(__s));
4255 append(size_type __n, _CharT __c);
4257 #if __cplusplus >= 201103L
4265 {
return this->
append(__l.begin(), __l.size()); }
4276 template<
class _InputIterator>
4278 append(_InputIterator __first, _InputIterator __last)
4279 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4281 #if __cplusplus >= 201703L
4287 template<
typename _Tp>
4288 _If_sv<_Tp, basic_string&>
4291 __sv_type __sv = __svt;
4292 return this->
append(__sv.data(), __sv.size());
4303 template<
typename _Tp>
4304 _If_sv<_Tp, basic_string&>
4305 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4307 __sv_type __sv = __svt;
4308 return append(__sv.data()
4309 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4310 std::__sv_limit(__sv.size(), __pos, __n));
4321 const size_type __len = 1 + this->
size();
4322 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4324 traits_type::assign(_M_data()[this->
size()], __c);
4325 _M_rep()->_M_set_length_and_sharable(__len);
4336 #if __cplusplus >= 201103L
4369 {
return this->
assign(__str._M_data()
4370 + __str._M_check(__pos,
"basic_string::assign"),
4371 __str._M_limit(__pos, __n)); }
4384 assign(
const _CharT* __s, size_type __n);
4398 __glibcxx_requires_string(__s);
4399 return this->
assign(__s, traits_type::length(__s));
4413 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4423 template<
class _InputIterator>
4425 assign(_InputIterator __first, _InputIterator __last)
4426 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4428 #if __cplusplus >= 201103L
4436 {
return this->
assign(__l.begin(), __l.size()); }
4439 #if __cplusplus >= 201703L
4445 template<
typename _Tp>
4446 _If_sv<_Tp, basic_string&>
4449 __sv_type __sv = __svt;
4450 return this->
assign(__sv.data(), __sv.size());
4460 template<
typename _Tp>
4461 _If_sv<_Tp, basic_string&>
4462 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4464 __sv_type __sv = __svt;
4465 return assign(__sv.data()
4466 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4467 std::__sv_limit(__sv.size(), __pos, __n));
4485 insert(iterator __p, size_type __n, _CharT __c)
4486 { this->
replace(__p, __p, __n, __c); }
4500 template<
class _InputIterator>
4502 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4503 { this->
replace(__p, __p, __beg, __end); }
4505 #if __cplusplus >= 201103L
4515 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4516 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4534 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4556 size_type __pos2, size_type __n =
npos)
4557 {
return this->
insert(__pos1, __str._M_data()
4558 + __str._M_check(__pos2,
"basic_string::insert"),
4559 __str._M_limit(__pos2, __n)); }
4578 insert(size_type __pos,
const _CharT* __s, size_type __n);
4598 __glibcxx_requires_string(__s);
4599 return this->
insert(__pos, __s, traits_type::length(__s));
4619 insert(size_type __pos, size_type __n, _CharT __c)
4620 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4621 size_type(0), __n, __c); }
4639 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4640 const size_type __pos = __p - _M_ibegin();
4641 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4642 _M_rep()->_M_set_leaked();
4643 return iterator(_M_data() + __pos);
4646 #if __cplusplus >= 201703L
4653 template<
typename _Tp>
4654 _If_sv<_Tp, basic_string&>
4655 insert(size_type __pos,
const _Tp& __svt)
4657 __sv_type __sv = __svt;
4658 return this->
insert(__pos, __sv.data(), __sv.size());
4669 template<
typename _Tp>
4670 _If_sv<_Tp, basic_string&>
4671 insert(size_type __pos1,
const _Tp& __svt,
4672 size_type __pos2, size_type __n =
npos)
4674 __sv_type __sv = __svt;
4675 return this->
replace(__pos1, size_type(0), __sv.data()
4676 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4677 std::__sv_limit(__sv.size(), __pos2, __n));
4699 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4700 _M_limit(__pos, __n), size_type(0));
4715 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4716 && __position < _M_iend());
4717 const size_type __pos = __position - _M_ibegin();
4718 _M_mutate(__pos, size_type(1), size_type(0));
4719 _M_rep()->_M_set_leaked();
4720 return iterator(_M_data() + __pos);
4735 #if __cplusplus >= 201103L
4744 __glibcxx_assert(!
empty());
4768 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4790 size_type __pos2, size_type __n2 =
npos)
4791 {
return this->
replace(__pos1, __n1, __str._M_data()
4792 + __str._M_check(__pos2,
"basic_string::replace"),
4793 __str._M_limit(__pos2, __n2)); }
4814 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4834 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4836 __glibcxx_requires_string(__s);
4837 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4858 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4859 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4860 _M_limit(__pos, __n1), __n2, __c); }
4877 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4895 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4897 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4898 && __i2 <= _M_iend());
4899 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4916 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4918 __glibcxx_requires_string(__s);
4919 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4937 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4939 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4940 && __i2 <= _M_iend());
4941 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4959 template<
class _InputIterator>
4962 _InputIterator __k1, _InputIterator __k2)
4964 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4965 && __i2 <= _M_iend());
4966 __glibcxx_requires_valid_range(__k1, __k2);
4967 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4968 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4976 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4977 && __i2 <= _M_iend());
4978 __glibcxx_requires_valid_range(__k1, __k2);
4979 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4984 replace(iterator __i1, iterator __i2,
4985 const _CharT* __k1,
const _CharT* __k2)
4987 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4988 && __i2 <= _M_iend());
4989 __glibcxx_requires_valid_range(__k1, __k2);
4990 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4995 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4997 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4998 && __i2 <= _M_iend());
4999 __glibcxx_requires_valid_range(__k1, __k2);
5000 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5001 __k1.base(), __k2 - __k1);
5005 replace(iterator __i1, iterator __i2,
5006 const_iterator __k1, const_iterator __k2)
5008 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5009 && __i2 <= _M_iend());
5010 __glibcxx_requires_valid_range(__k1, __k2);
5011 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5012 __k1.base(), __k2 - __k1);
5015 #if __cplusplus >= 201103L
5032 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5035 #if __cplusplus >= 201703L
5043 template<
typename _Tp>
5044 _If_sv<_Tp, basic_string&>
5045 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5047 __sv_type __sv = __svt;
5048 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5060 template<
typename _Tp>
5061 _If_sv<_Tp, basic_string&>
5062 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5063 size_type __pos2, size_type __n2 =
npos)
5065 __sv_type __sv = __svt;
5066 return this->
replace(__pos1, __n1,
5068 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5069 std::__sv_limit(__sv.size(), __pos2, __n2));
5081 template<
typename _Tp>
5082 _If_sv<_Tp, basic_string&>
5083 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5085 __sv_type __sv = __svt;
5086 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5091 template<
class _Integer>
5093 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5094 _Integer __val, __true_type)
5095 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5097 template<
class _InputIterator>
5099 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5100 _InputIterator __k2, __false_type);
5103 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5107 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5112 template<
class _InIterator>
5114 _S_construct_aux(_InIterator __beg, _InIterator __end,
5115 const _Alloc& __a, __false_type)
5117 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5118 return _S_construct(__beg, __end, __a, _Tag());
5123 template<
class _Integer>
5125 _S_construct_aux(_Integer __beg, _Integer __end,
5126 const _Alloc& __a, __true_type)
5127 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5131 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5132 {
return _S_construct(__req, __c, __a); }
5134 template<
class _InIterator>
5136 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5138 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5139 return _S_construct_aux(__beg, __end, __a, _Integral());
5143 template<
class _InIterator>
5145 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5146 input_iterator_tag);
5150 template<
class _FwdIterator>
5152 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5153 forward_iterator_tag);
5156 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5173 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5184 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5195 {
return _M_data(); }
5207 {
return _M_data(); }
5209 #if __cplusplus >= 201703L
5229 {
return _M_dataplus; }
5244 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5260 {
return this->
find(__str.data(), __pos, __str.size()); }
5273 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5275 __glibcxx_requires_string(__s);
5276 return this->
find(__s, __pos, traits_type::length(__s));
5290 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5292 #if __cplusplus >= 201703L
5299 template<
typename _Tp>
5300 _If_sv<_Tp, size_type>
5301 find(
const _Tp& __svt, size_type __pos = 0) const
5302 noexcept(
is_same<_Tp, __sv_type>::value)
5304 __sv_type __sv = __svt;
5305 return this->
find(__sv.data(), __pos, __sv.size());
5322 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5337 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5351 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5353 __glibcxx_requires_string(__s);
5354 return this->
rfind(__s, __pos, traits_type::length(__s));
5368 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5370 #if __cplusplus >= 201703L
5377 template<
typename _Tp>
5378 _If_sv<_Tp, size_type>
5379 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
5382 __sv_type __sv = __svt;
5383 return this->
rfind(__sv.data(), __pos, __sv.size());
5401 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5416 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5433 __glibcxx_requires_string(__s);
5434 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5451 {
return this->
find(__c, __pos); }
5453 #if __cplusplus >= 201703L
5461 template<
typename _Tp>
5462 _If_sv<_Tp, size_type>
5464 noexcept(
is_same<_Tp, __sv_type>::value)
5466 __sv_type __sv = __svt;
5467 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5485 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5500 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5517 __glibcxx_requires_string(__s);
5518 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5535 {
return this->
rfind(__c, __pos); }
5537 #if __cplusplus >= 201703L
5545 template<
typename _Tp>
5546 _If_sv<_Tp, size_type>
5550 __sv_type __sv = __svt;
5551 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5584 size_type __n)
const _GLIBCXX_NOEXCEPT;
5600 __glibcxx_requires_string(__s);
5618 #if __cplusplus >= 201703L
5626 template<
typename _Tp>
5627 _If_sv<_Tp, size_type>
5629 noexcept(
is_same<_Tp, __sv_type>::value)
5631 __sv_type __sv = __svt;
5666 size_type __n)
const _GLIBCXX_NOEXCEPT;
5682 __glibcxx_requires_string(__s);
5700 #if __cplusplus >= 201703L
5708 template<
typename _Tp>
5709 _If_sv<_Tp, size_type>
5713 __sv_type __sv = __svt;
5733 _M_check(__pos,
"basic_string::substr"), __n); }
5752 const size_type __size = this->
size();
5753 const size_type __osize = __str.size();
5754 const size_type __len =
std::min(__size, __osize);
5756 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5758 __r = _S_compare(__size, __osize);
5762 #if __cplusplus >= 201703L
5768 template<
typename _Tp>
5770 compare(
const _Tp& __svt)
const
5773 __sv_type __sv = __svt;
5774 const size_type __size = this->
size();
5775 const size_type __osize = __sv.size();
5776 const size_type __len =
std::min(__size, __osize);
5778 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5780 __r = _S_compare(__size, __osize);
5792 template<
typename _Tp>
5794 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5795 noexcept(is_same<_Tp, __sv_type>::value)
5797 __sv_type __sv = __svt;
5798 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5811 template<
typename _Tp>
5813 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5814 size_type __pos2, size_type __n2 =
npos)
const
5815 noexcept(is_same<_Tp, __sv_type>::value)
5817 __sv_type __sv = __svt;
5818 return __sv_type(*
this)
5819 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5870 size_type __pos2, size_type __n2 =
npos)
const;
5887 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5911 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5938 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5939 size_type __n2)
const;
5941 #if __cplusplus > 201703L
5943 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5944 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5947 starts_with(_CharT __x)
const noexcept
5948 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5951 starts_with(
const _CharT* __x)
const noexcept
5952 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5955 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5956 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5959 ends_with(_CharT __x)
const noexcept
5960 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5963 ends_with(
const _CharT* __x)
const noexcept
5964 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5967 # ifdef _GLIBCXX_TM_TS_INTERNAL
5969 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5972 ::_txnal_cow_string_c_str(
const void *that);
5974 ::_txnal_cow_string_D1(
void *that);
5976 ::_txnal_cow_string_D1_commit(
void *that);
5981 #if __cpp_deduction_guides >= 201606
5982 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5983 template<
typename _InputIterator,
typename _CharT
5984 =
typename iterator_traits<_InputIterator>::value_type,
5985 typename _Allocator = allocator<_CharT>,
5986 typename = _RequireInputIter<_InputIterator>,
5987 typename = _RequireAllocator<_Allocator>>
5988 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5989 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5993 template<
typename _CharT,
typename _Traits,
5994 typename _Allocator = allocator<_CharT>,
5995 typename = _RequireAllocator<_Allocator>>
5996 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5997 -> basic_string<_CharT, _Traits, _Allocator>;
5999 template<
typename _CharT,
typename _Traits,
6000 typename _Allocator = allocator<_CharT>,
6001 typename = _RequireAllocator<_Allocator>>
6002 basic_string(basic_string_view<_CharT, _Traits>,
6003 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6004 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6005 const _Allocator& = _Allocator())
6006 -> basic_string<_CharT, _Traits, _Allocator>;
6007 _GLIBCXX_END_NAMESPACE_CXX11
6017 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6018 basic_string<_CharT, _Traits, _Alloc>
6023 __str.append(__rhs);
6033 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6034 basic_string<_CharT,_Traits,_Alloc>
6036 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6044 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6045 basic_string<_CharT,_Traits,_Alloc>
6046 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6054 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6055 inline basic_string<_CharT, _Traits, _Alloc>
6057 const _CharT* __rhs)
6060 __str.append(__rhs);
6070 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6071 inline basic_string<_CharT, _Traits, _Alloc>
6075 typedef typename __string_type::size_type __size_type;
6076 __string_type __str(__lhs);
6077 __str.append(__size_type(1), __rhs);
6081 #if __cplusplus >= 201103L
6082 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6083 inline basic_string<_CharT, _Traits, _Alloc>
6084 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6085 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6086 {
return std::move(__lhs.append(__rhs)); }
6088 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6089 inline basic_string<_CharT, _Traits, _Alloc>
6090 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6091 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6092 {
return std::move(__rhs.insert(0, __lhs)); }
6094 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6095 inline basic_string<_CharT, _Traits, _Alloc>
6096 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6097 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6099 const auto __size = __lhs.size() + __rhs.size();
6100 const bool __cond = (__size > __lhs.capacity()
6101 && __size <= __rhs.capacity());
6102 return __cond ? std::move(__rhs.insert(0, __lhs))
6103 :
std::move(__lhs.append(__rhs));
6106 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6107 inline basic_string<_CharT, _Traits, _Alloc>
6109 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6110 {
return std::move(__rhs.insert(0, __lhs)); }
6112 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6113 inline basic_string<_CharT, _Traits, _Alloc>
6115 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6116 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6118 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6119 inline basic_string<_CharT, _Traits, _Alloc>
6120 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6121 const _CharT* __rhs)
6122 {
return std::move(__lhs.append(__rhs)); }
6124 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6125 inline basic_string<_CharT, _Traits, _Alloc>
6126 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6128 {
return std::move(__lhs.append(1, __rhs)); }
6138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6143 {
return __lhs.compare(__rhs) == 0; }
6145 template<
typename _CharT>
6147 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6148 operator==(
const basic_string<_CharT>& __lhs,
6149 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6150 {
return (__lhs.size() == __rhs.size()
6160 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6162 operator==(
const _CharT* __lhs,
6164 {
return __rhs.compare(__lhs) == 0; }
6172 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6175 const _CharT* __rhs)
6176 {
return __lhs.compare(__rhs) == 0; }
6185 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6190 {
return !(__lhs == __rhs); }
6198 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6200 operator!=(
const _CharT* __lhs,
6202 {
return !(__lhs == __rhs); }
6210 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6213 const _CharT* __rhs)
6214 {
return !(__lhs == __rhs); }
6223 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6228 {
return __lhs.compare(__rhs) < 0; }
6236 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6239 const _CharT* __rhs)
6240 {
return __lhs.compare(__rhs) < 0; }
6248 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6250 operator<(
const _CharT* __lhs,
6252 {
return __rhs.compare(__lhs) > 0; }
6261 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6266 {
return __lhs.compare(__rhs) > 0; }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6277 const _CharT* __rhs)
6278 {
return __lhs.compare(__rhs) > 0; }
6286 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6288 operator>(
const _CharT* __lhs,
6290 {
return __rhs.compare(__lhs) < 0; }
6299 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6304 {
return __lhs.compare(__rhs) <= 0; }
6312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6315 const _CharT* __rhs)
6316 {
return __lhs.compare(__rhs) <= 0; }
6324 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6326 operator<=(
const _CharT* __lhs,
6328 {
return __rhs.compare(__lhs) >= 0; }
6337 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6342 {
return __lhs.compare(__rhs) >= 0; }
6350 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6353 const _CharT* __rhs)
6354 {
return __lhs.compare(__rhs) >= 0; }
6362 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6364 operator>=(
const _CharT* __lhs,
6366 {
return __rhs.compare(__lhs) <= 0; }
6375 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6379 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6380 { __lhs.swap(__rhs); }
6395 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6396 basic_istream<_CharT, _Traits>&
6397 operator>>(basic_istream<_CharT, _Traits>& __is,
6398 basic_string<_CharT, _Traits, _Alloc>& __str);
6401 basic_istream<char>&
6413 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6420 return __ostream_insert(__os, __str.data(), __str.size());
6436 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6437 basic_istream<_CharT, _Traits>&
6438 getline(basic_istream<_CharT, _Traits>& __is,
6439 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6453 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6454 inline basic_istream<_CharT, _Traits>&
6459 #if __cplusplus >= 201103L
6461 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6462 inline basic_istream<_CharT, _Traits>&
6468 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6469 inline basic_istream<_CharT, _Traits>&
6476 basic_istream<char>&
6477 getline(basic_istream<char>& __in, basic_string<char>& __str,
6480 #ifdef _GLIBCXX_USE_WCHAR_T
6482 basic_istream<wchar_t>&
6483 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6487 _GLIBCXX_END_NAMESPACE_VERSION
6490 #if __cplusplus >= 201103L
6494 namespace std _GLIBCXX_VISIBILITY(default)
6496 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6497 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6499 #if _GLIBCXX_USE_C99_STDLIB
6502 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6503 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6507 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6508 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6511 inline unsigned long
6512 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6513 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6517 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6518 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6521 inline unsigned long long
6522 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6523 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6528 stof(
const string& __str,
size_t* __idx = 0)
6529 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6532 stod(
const string& __str,
size_t* __idx = 0)
6533 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6536 stold(
const string& __str,
size_t* __idx = 0)
6537 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6540 #if _GLIBCXX_USE_C99_STDIO
6545 to_string(
int __val)
6546 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
int),
6550 to_string(
unsigned __val)
6551 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6552 4 *
sizeof(
unsigned),
6556 to_string(
long __val)
6557 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
long),
6561 to_string(
unsigned long __val)
6562 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6563 4 *
sizeof(
unsigned long),
6567 to_string(
long long __val)
6568 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6569 4 *
sizeof(
long long),
6573 to_string(
unsigned long long __val)
6574 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6575 4 *
sizeof(
unsigned long long),
6579 to_string(
float __val)
6582 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6583 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6588 to_string(
double __val)
6591 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6592 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6597 to_string(
long double __val)
6600 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6601 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6606 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6608 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6609 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6613 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6614 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6617 inline unsigned long
6618 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6619 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6623 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6624 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6627 inline unsigned long long
6628 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6629 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6634 stof(
const wstring& __str,
size_t* __idx = 0)
6635 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6638 stod(
const wstring& __str,
size_t* __idx = 0)
6639 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6642 stold(
const wstring& __str,
size_t* __idx = 0)
6643 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6645 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6648 to_wstring(
int __val)
6649 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6653 to_wstring(
unsigned __val)
6654 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6655 4 *
sizeof(
unsigned),
6659 to_wstring(
long __val)
6660 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6664 to_wstring(
unsigned long __val)
6665 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6666 4 *
sizeof(
unsigned long),
6670 to_wstring(
long long __val)
6671 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6672 4 *
sizeof(
long long),
6676 to_wstring(
unsigned long long __val)
6677 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6678 4 *
sizeof(
unsigned long long),
6682 to_wstring(
float __val)
6685 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6686 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6691 to_wstring(
double __val)
6694 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6695 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6700 to_wstring(
long double __val)
6703 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6704 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6710 _GLIBCXX_END_NAMESPACE_CXX11
6711 _GLIBCXX_END_NAMESPACE_VERSION
6716 #if __cplusplus >= 201103L
6720 namespace std _GLIBCXX_VISIBILITY(default)
6722 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6726 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6730 :
public __hash_base<size_t, string>
6733 operator()(
const string& __s)
const noexcept
6734 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6741 #ifdef _GLIBCXX_USE_WCHAR_T
6745 :
public __hash_base<size_t, wstring>
6748 operator()(
const wstring& __s)
const noexcept
6749 {
return std::_Hash_impl::hash(__s.
data(),
6750 __s.
length() *
sizeof(
wchar_t)); }
6759 #ifdef _GLIBCXX_USE_CHAR8_T
6762 struct hash<u8string>
6763 :
public __hash_base<size_t, u8string>
6766 operator()(
const u8string& __s)
const noexcept
6767 {
return std::_Hash_impl::hash(__s.data(),
6768 __s.length() *
sizeof(char8_t)); }
6779 :
public __hash_base<size_t, u16string>
6782 operator()(
const u16string& __s)
const noexcept
6783 {
return std::_Hash_impl::hash(__s.
data(),
6784 __s.
length() *
sizeof(char16_t)); }
6794 :
public __hash_base<size_t, u32string>
6797 operator()(
const u32string& __s)
const noexcept
6798 {
return std::_Hash_impl::hash(__s.
data(),
6799 __s.
length() *
sizeof(char32_t)); }
6806 #if __cplusplus >= 201402L
6808 #define __cpp_lib_string_udls 201304
6810 inline namespace literals
6812 inline namespace string_literals
6814 #pragma GCC diagnostic push
6815 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6816 _GLIBCXX_DEFAULT_ABI_TAG
6817 inline basic_string<char>
6818 operator""s(
const char* __str,
size_t __len)
6819 {
return basic_string<char>{__str, __len}; }
6821 #ifdef _GLIBCXX_USE_WCHAR_T
6822 _GLIBCXX_DEFAULT_ABI_TAG
6823 inline basic_string<wchar_t>
6824 operator""s(
const wchar_t* __str,
size_t __len)
6825 {
return basic_string<wchar_t>{__str, __len}; }
6828 #ifdef _GLIBCXX_USE_CHAR8_T
6829 _GLIBCXX_DEFAULT_ABI_TAG
6830 inline basic_string<char8_t>
6831 operator""s(
const char8_t* __str,
size_t __len)
6832 {
return basic_string<char8_t>{__str, __len}; }
6835 _GLIBCXX_DEFAULT_ABI_TAG
6836 inline basic_string<char16_t>
6837 operator""s(
const char16_t* __str,
size_t __len)
6838 {
return basic_string<char16_t>{__str, __len}; }
6840 _GLIBCXX_DEFAULT_ABI_TAG
6841 inline basic_string<char32_t>
6842 operator""s(
const char32_t* __str,
size_t __len)
6843 {
return basic_string<char32_t>{__str, __len}; }
6845 #pragma GCC diagnostic pop
6849 #if __cplusplus >= 201703L
6850 namespace __detail::__variant
6852 template<
typename>
struct _Never_valueless_alt;
6856 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6857 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6859 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6860 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6867 _GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX20_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.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
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.
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.
_Iterator __base(_Iterator __it)
char_type widen(char __c) const
Widens characters.
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.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
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 & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this 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.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C 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 & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
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 & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
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 & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
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
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
const_reverse_iterator crend() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
_GLIBCXX_NODISCARD bool empty() const noexcept
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
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 & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_iterator cbegin() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string & operator+=(const _CharT *__s)
Append a C string.
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.
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.
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 & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
basic_string & append(const _CharT *__s)
Append a C 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.