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
3074 #else // !_GLIBCXX_USE_CXX11_ABI 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());
4670 template<
typename _Tp>
4671 _If_sv<_Tp, basic_string&>
4672 insert(size_type __pos1,
const _Tp& __svt,
4673 size_type __pos2, size_type __n =
npos)
4675 __sv_type __sv = __svt;
4676 return this->
replace(__pos1, size_type(0), __sv.data()
4677 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4678 std::__sv_limit(__sv.size(), __pos2, __n));
4700 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4701 _M_limit(__pos, __n), size_type(0));
4716 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4717 && __position < _M_iend());
4718 const size_type __pos = __position - _M_ibegin();
4719 _M_mutate(__pos, size_type(1), size_type(0));
4720 _M_rep()->_M_set_leaked();
4721 return iterator(_M_data() + __pos);
4736 #if __cplusplus >= 201103L 4745 __glibcxx_assert(!
empty());
4769 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4791 size_type __pos2, size_type __n2 =
npos)
4792 {
return this->
replace(__pos1, __n1, __str._M_data()
4793 + __str._M_check(__pos2,
"basic_string::replace"),
4794 __str._M_limit(__pos2, __n2)); }
4815 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4835 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4837 __glibcxx_requires_string(__s);
4838 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4859 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4860 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4861 _M_limit(__pos, __n1), __n2, __c); }
4878 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4896 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4898 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4899 && __i2 <= _M_iend());
4900 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4917 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4919 __glibcxx_requires_string(__s);
4920 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4938 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4940 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4941 && __i2 <= _M_iend());
4942 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4960 template<
class _InputIterator>
4963 _InputIterator __k1, _InputIterator __k2)
4965 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4966 && __i2 <= _M_iend());
4967 __glibcxx_requires_valid_range(__k1, __k2);
4968 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4969 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4977 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4978 && __i2 <= _M_iend());
4979 __glibcxx_requires_valid_range(__k1, __k2);
4980 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4985 replace(iterator __i1, iterator __i2,
4986 const _CharT* __k1,
const _CharT* __k2)
4988 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4989 && __i2 <= _M_iend());
4990 __glibcxx_requires_valid_range(__k1, __k2);
4991 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4996 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4998 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4999 && __i2 <= _M_iend());
5000 __glibcxx_requires_valid_range(__k1, __k2);
5001 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5002 __k1.base(), __k2 - __k1);
5006 replace(iterator __i1, iterator __i2,
5007 const_iterator __k1, const_iterator __k2)
5009 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5010 && __i2 <= _M_iend());
5011 __glibcxx_requires_valid_range(__k1, __k2);
5012 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5013 __k1.base(), __k2 - __k1);
5016 #if __cplusplus >= 201103L 5033 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5036 #if __cplusplus >= 201703L 5044 template<
typename _Tp>
5045 _If_sv<_Tp, basic_string&>
5046 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5048 __sv_type __sv = __svt;
5049 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5061 template<
typename _Tp>
5062 _If_sv<_Tp, basic_string&>
5063 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5064 size_type __pos2, size_type __n2 =
npos)
5066 __sv_type __sv = __svt;
5067 return this->
replace(__pos1, __n1,
5069 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5070 std::__sv_limit(__sv.size(), __pos2, __n2));
5082 template<
typename _Tp>
5083 _If_sv<_Tp, basic_string&>
5084 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5086 __sv_type __sv = __svt;
5087 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5092 template<
class _Integer>
5094 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5095 _Integer __val, __true_type)
5096 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5098 template<
class _InputIterator>
5100 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5101 _InputIterator __k2, __false_type);
5104 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5108 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5113 template<
class _InIterator>
5115 _S_construct_aux(_InIterator __beg, _InIterator __end,
5116 const _Alloc& __a, __false_type)
5118 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5119 return _S_construct(__beg, __end, __a, _Tag());
5124 template<
class _Integer>
5126 _S_construct_aux(_Integer __beg, _Integer __end,
5127 const _Alloc& __a, __true_type)
5128 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5132 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5133 {
return _S_construct(__req, __c, __a); }
5135 template<
class _InIterator>
5137 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5139 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5140 return _S_construct_aux(__beg, __end, __a, _Integral());
5144 template<
class _InIterator>
5146 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5147 input_iterator_tag);
5151 template<
class _FwdIterator>
5153 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5154 forward_iterator_tag);
5157 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5174 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5185 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5196 {
return _M_data(); }
5208 {
return _M_data(); }
5210 #if __cplusplus >= 201703L 5230 {
return _M_dataplus; }
5245 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5261 {
return this->
find(__str.data(), __pos, __str.size()); }
5274 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5276 __glibcxx_requires_string(__s);
5277 return this->
find(__s, __pos, traits_type::length(__s));
5291 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5293 #if __cplusplus >= 201703L 5300 template<
typename _Tp>
5301 _If_sv<_Tp, size_type>
5302 find(
const _Tp& __svt, size_type __pos = 0) const
5303 noexcept(
is_same<_Tp, __sv_type>::value)
5305 __sv_type __sv = __svt;
5306 return this->
find(__sv.data(), __pos, __sv.size());
5323 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5338 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5352 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5354 __glibcxx_requires_string(__s);
5355 return this->
rfind(__s, __pos, traits_type::length(__s));
5369 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5371 #if __cplusplus >= 201703L 5378 template<
typename _Tp>
5379 _If_sv<_Tp, size_type>
5380 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 5383 __sv_type __sv = __svt;
5384 return this->
rfind(__sv.data(), __pos, __sv.size());
5402 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5417 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5434 __glibcxx_requires_string(__s);
5435 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5452 {
return this->
find(__c, __pos); }
5454 #if __cplusplus >= 201703L 5462 template<
typename _Tp>
5463 _If_sv<_Tp, size_type>
5465 noexcept(
is_same<_Tp, __sv_type>::value)
5467 __sv_type __sv = __svt;
5468 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5486 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5501 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5518 __glibcxx_requires_string(__s);
5519 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5536 {
return this->
rfind(__c, __pos); }
5538 #if __cplusplus >= 201703L 5546 template<
typename _Tp>
5547 _If_sv<_Tp, size_type>
5551 __sv_type __sv = __svt;
5552 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5585 size_type __n)
const _GLIBCXX_NOEXCEPT;
5601 __glibcxx_requires_string(__s);
5619 #if __cplusplus >= 201703L 5627 template<
typename _Tp>
5628 _If_sv<_Tp, size_type>
5630 noexcept(
is_same<_Tp, __sv_type>::value)
5632 __sv_type __sv = __svt;
5667 size_type __n)
const _GLIBCXX_NOEXCEPT;
5683 __glibcxx_requires_string(__s);
5701 #if __cplusplus >= 201703L 5709 template<
typename _Tp>
5710 _If_sv<_Tp, size_type>
5714 __sv_type __sv = __svt;
5734 _M_check(__pos,
"basic_string::substr"), __n); }
5753 const size_type __size = this->
size();
5754 const size_type __osize = __str.size();
5755 const size_type __len =
std::min(__size, __osize);
5757 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5759 __r = _S_compare(__size, __osize);
5763 #if __cplusplus >= 201703L 5769 template<
typename _Tp>
5771 compare(
const _Tp& __svt)
const 5774 __sv_type __sv = __svt;
5775 const size_type __size = this->
size();
5776 const size_type __osize = __sv.size();
5777 const size_type __len =
std::min(__size, __osize);
5779 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5781 __r = _S_compare(__size, __osize);
5793 template<
typename _Tp>
5795 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5796 noexcept(is_same<_Tp, __sv_type>::value)
5798 __sv_type __sv = __svt;
5799 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5812 template<
typename _Tp>
5814 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5815 size_type __pos2, size_type __n2 =
npos)
const 5816 noexcept(is_same<_Tp, __sv_type>::value)
5818 __sv_type __sv = __svt;
5819 return __sv_type(*
this)
5820 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5871 size_type __pos2, size_type __n2 =
npos)
const;
5888 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5912 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5939 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5940 size_type __n2)
const;
5942 #if __cplusplus > 201703L 5944 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5945 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5948 starts_with(_CharT __x)
const noexcept
5949 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5952 starts_with(
const _CharT* __x)
const noexcept
5953 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5956 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5957 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5960 ends_with(_CharT __x)
const noexcept
5961 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5964 ends_with(
const _CharT* __x)
const noexcept
5965 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5968 # ifdef _GLIBCXX_TM_TS_INTERNAL 5970 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5973 ::_txnal_cow_string_c_str(
const void *that);
5975 ::_txnal_cow_string_D1(
void *that);
5977 ::_txnal_cow_string_D1_commit(
void *that);
5980 #endif // !_GLIBCXX_USE_CXX11_ABI 5982 #if __cpp_deduction_guides >= 201606 5983 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5984 template<
typename _InputIterator,
typename _CharT
5985 =
typename iterator_traits<_InputIterator>::value_type,
5986 typename _Allocator = allocator<_CharT>,
5987 typename = _RequireInputIter<_InputIterator>,
5988 typename = _RequireAllocator<_Allocator>>
5989 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5990 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5994 template<
typename _CharT,
typename _Traits,
5995 typename _Allocator = allocator<_CharT>,
5996 typename = _RequireAllocator<_Allocator>>
5997 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5998 -> basic_string<_CharT, _Traits, _Allocator>;
6000 template<
typename _CharT,
typename _Traits,
6001 typename _Allocator = allocator<_CharT>,
6002 typename = _RequireAllocator<_Allocator>>
6003 basic_string(basic_string_view<_CharT, _Traits>,
6004 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6005 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6006 const _Allocator& = _Allocator())
6007 -> basic_string<_CharT, _Traits, _Allocator>;
6008 _GLIBCXX_END_NAMESPACE_CXX11
6018 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6019 basic_string<_CharT, _Traits, _Alloc>
6024 __str.append(__rhs);
6034 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6035 basic_string<_CharT,_Traits,_Alloc>
6037 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6045 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6046 basic_string<_CharT,_Traits,_Alloc>
6047 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6055 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6056 inline basic_string<_CharT, _Traits, _Alloc>
6058 const _CharT* __rhs)
6061 __str.append(__rhs);
6071 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6072 inline basic_string<_CharT, _Traits, _Alloc>
6076 typedef typename __string_type::size_type __size_type;
6077 __string_type __str(__lhs);
6078 __str.append(__size_type(1), __rhs);
6082 #if __cplusplus >= 201103L 6083 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6084 inline basic_string<_CharT, _Traits, _Alloc>
6085 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6086 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6087 {
return std::move(__lhs.append(__rhs)); }
6089 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6090 inline basic_string<_CharT, _Traits, _Alloc>
6091 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6092 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6093 {
return std::move(__rhs.insert(0, __lhs)); }
6095 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6096 inline basic_string<_CharT, _Traits, _Alloc>
6097 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6098 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6100 const auto __size = __lhs.size() + __rhs.size();
6101 const bool __cond = (__size > __lhs.capacity()
6102 && __size <= __rhs.capacity());
6103 return __cond ? std::move(__rhs.insert(0, __lhs))
6104 : std::move(__lhs.append(__rhs));
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 inline basic_string<_CharT, _Traits, _Alloc>
6110 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6111 {
return std::move(__rhs.insert(0, __lhs)); }
6113 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6114 inline basic_string<_CharT, _Traits, _Alloc>
6116 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6117 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6119 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6120 inline basic_string<_CharT, _Traits, _Alloc>
6121 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6122 const _CharT* __rhs)
6123 {
return std::move(__lhs.append(__rhs)); }
6125 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6126 inline basic_string<_CharT, _Traits, _Alloc>
6127 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6129 {
return std::move(__lhs.append(1, __rhs)); }
6139 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6144 {
return __lhs.compare(__rhs) == 0; }
6146 template<
typename _CharT>
6148 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6149 operator==(
const basic_string<_CharT>& __lhs,
6150 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6151 {
return (__lhs.size() == __rhs.size()
6161 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6163 operator==(
const _CharT* __lhs,
6165 {
return __rhs.compare(__lhs) == 0; }
6173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6176 const _CharT* __rhs)
6177 {
return __lhs.compare(__rhs) == 0; }
6186 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6191 {
return !(__lhs == __rhs); }
6199 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6201 operator!=(
const _CharT* __lhs,
6203 {
return !(__lhs == __rhs); }
6211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6214 const _CharT* __rhs)
6215 {
return !(__lhs == __rhs); }
6224 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6226 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6229 {
return __lhs.
compare(__rhs) < 0; }
6237 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6239 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6240 const _CharT* __rhs)
6241 {
return __lhs.compare(__rhs) < 0; }
6249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6251 operator<(
const _CharT* __lhs,
6253 {
return __rhs.compare(__lhs) > 0; }
6262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6267 {
return __lhs.compare(__rhs) > 0; }
6275 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6278 const _CharT* __rhs)
6279 {
return __lhs.compare(__rhs) > 0; }
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>
6302 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6305 {
return __lhs.
compare(__rhs) <= 0; }
6313 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6315 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6316 const _CharT* __rhs)
6317 {
return __lhs.compare(__rhs) <= 0; }
6325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6327 operator<=(
const _CharT* __lhs,
6329 {
return __rhs.compare(__lhs) >= 0; }
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>
6380 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6381 { __lhs.swap(__rhs); }
6396 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6397 basic_istream<_CharT, _Traits>&
6398 operator>>(basic_istream<_CharT, _Traits>& __is,
6399 basic_string<_CharT, _Traits, _Alloc>& __str);
6402 basic_istream<char>&
6403 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6415 inline basic_ostream<_CharT, _Traits>&
6416 operator<<(basic_ostream<_CharT, _Traits>& __os,
6421 return __ostream_insert(__os, __str.data(), __str.size());
6437 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6438 basic_istream<_CharT, _Traits>&
6439 getline(basic_istream<_CharT, _Traits>& __is,
6440 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6454 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6455 inline basic_istream<_CharT, _Traits>&
6460 #if __cplusplus >= 201103L 6462 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6463 inline basic_istream<_CharT, _Traits>&
6469 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6470 inline basic_istream<_CharT, _Traits>&
6477 basic_istream<char>&
6478 getline(basic_istream<char>& __in, basic_string<char>& __str,
6481 #ifdef _GLIBCXX_USE_WCHAR_T 6483 basic_istream<wchar_t>&
6484 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6488 _GLIBCXX_END_NAMESPACE_VERSION
6491 #if __cplusplus >= 201103L 6495 namespace std _GLIBCXX_VISIBILITY(default)
6497 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6498 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6500 #if _GLIBCXX_USE_C99_STDLIB 6503 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6504 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6508 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6509 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6512 inline unsigned long 6513 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6514 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6518 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6519 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6522 inline unsigned long long 6523 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6524 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6529 stof(
const string& __str,
size_t* __idx = 0)
6530 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6533 stod(
const string& __str,
size_t* __idx = 0)
6534 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6537 stold(
const string& __str,
size_t* __idx = 0)
6538 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6539 #endif // _GLIBCXX_USE_C99_STDLIB 6541 #if _GLIBCXX_USE_C99_STDIO 6546 to_string(
int __val)
6547 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6551 to_string(
unsigned __val)
6552 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6553 4 *
sizeof(unsigned),
6557 to_string(
long __val)
6558 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6562 to_string(
unsigned long __val)
6563 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6564 4 *
sizeof(
unsigned long),
6568 to_string(
long long __val)
6569 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6570 4 *
sizeof(
long long),
6574 to_string(
unsigned long long __val)
6575 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6576 4 *
sizeof(
unsigned long long),
6580 to_string(
float __val)
6583 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6584 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6589 to_string(
double __val)
6592 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6593 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6598 to_string(
long double __val)
6601 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6602 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6605 #endif // _GLIBCXX_USE_C99_STDIO 6607 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6609 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6610 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6614 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6615 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6618 inline unsigned long 6619 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6620 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6624 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6625 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6628 inline unsigned long long 6629 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6630 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6635 stof(
const wstring& __str,
size_t* __idx = 0)
6636 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6639 stod(
const wstring& __str,
size_t* __idx = 0)
6640 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6643 stold(
const wstring& __str,
size_t* __idx = 0)
6644 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6646 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6649 to_wstring(
int __val)
6650 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6654 to_wstring(
unsigned __val)
6655 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6656 4 *
sizeof(unsigned),
6660 to_wstring(
long __val)
6661 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6665 to_wstring(
unsigned long __val)
6666 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6667 4 *
sizeof(
unsigned long),
6671 to_wstring(
long long __val)
6672 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6673 4 *
sizeof(
long long),
6677 to_wstring(
unsigned long long __val)
6678 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6679 4 *
sizeof(
unsigned long long),
6683 to_wstring(
float __val)
6686 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6687 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6692 to_wstring(
double __val)
6695 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6696 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6701 to_wstring(
long double __val)
6704 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6705 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6708 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6709 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6711 _GLIBCXX_END_NAMESPACE_CXX11
6712 _GLIBCXX_END_NAMESPACE_VERSION
6717 #if __cplusplus >= 201103L 6721 namespace std _GLIBCXX_VISIBILITY(default)
6723 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6727 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6731 :
public __hash_base<size_t, string>
6734 operator()(
const string& __s)
const noexcept
6735 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6742 #ifdef _GLIBCXX_USE_WCHAR_T 6746 :
public __hash_base<size_t, wstring>
6749 operator()(
const wstring& __s)
const noexcept
6750 {
return std::_Hash_impl::hash(__s.
data(),
6751 __s.
length() *
sizeof(wchar_t)); }
6760 #ifdef _GLIBCXX_USE_CHAR8_T 6763 struct hash<u8string>
6764 :
public __hash_base<size_t, u8string>
6767 operator()(
const u8string& __s)
const noexcept
6768 {
return std::_Hash_impl::hash(__s.data(),
6769 __s.length() *
sizeof(char8_t)); }
6780 :
public __hash_base<size_t, u16string>
6783 operator()(
const u16string& __s)
const noexcept
6784 {
return std::_Hash_impl::hash(__s.
data(),
6785 __s.
length() *
sizeof(char16_t)); }
6795 :
public __hash_base<size_t, u32string>
6798 operator()(
const u32string& __s)
const noexcept
6799 {
return std::_Hash_impl::hash(__s.
data(),
6800 __s.
length() *
sizeof(char32_t)); }
6807 #if __cplusplus >= 201402L 6809 #define __cpp_lib_string_udls 201304 6811 inline namespace literals
6813 inline namespace string_literals
6815 #pragma GCC diagnostic push 6816 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6817 _GLIBCXX_DEFAULT_ABI_TAG
6818 inline basic_string<char>
6819 operator""s(
const char* __str,
size_t __len)
6820 {
return basic_string<char>{__str, __len}; }
6822 #ifdef _GLIBCXX_USE_WCHAR_T 6823 _GLIBCXX_DEFAULT_ABI_TAG
6824 inline basic_string<wchar_t>
6825 operator""s(
const wchar_t* __str,
size_t __len)
6826 {
return basic_string<wchar_t>{__str, __len}; }
6829 #ifdef _GLIBCXX_USE_CHAR8_T 6830 _GLIBCXX_DEFAULT_ABI_TAG
6831 inline basic_string<char8_t>
6832 operator""s(
const char8_t* __str,
size_t __len)
6833 {
return basic_string<char8_t>{__str, __len}; }
6836 _GLIBCXX_DEFAULT_ABI_TAG
6837 inline basic_string<char16_t>
6838 operator""s(
const char16_t* __str,
size_t __len)
6839 {
return basic_string<char16_t>{__str, __len}; }
6841 _GLIBCXX_DEFAULT_ABI_TAG
6842 inline basic_string<char32_t>
6843 operator""s(
const char32_t* __str,
size_t __len)
6844 {
return basic_string<char32_t>{__str, __len}; }
6846 #pragma GCC diagnostic pop 6850 #if __cplusplus >= 201703L 6851 namespace __detail::__variant
6853 template<
typename>
struct _Never_valueless_alt;
6857 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6858 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6860 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6861 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6868 _GLIBCXX_END_NAMESPACE_VERSION
reference at(size_type __n)
Provides access to the data contained in the string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
static const size_type npos
Value returned by various member functions when they fail.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
const_reverse_iterator crbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
ISO C++ entities toplevel namespace is std.
const_reference front() const noexcept
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
const_iterator begin() const noexcept
basic_string & operator=(_CharT __c)
Set value to string of length 1.
Forward iterators support a superset of input iterator operations.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & append(const _CharT *__s)
Append a C string.
_GLIBCXX20_CONSTEXPR complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_reference back() const noexcept
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
const_iterator end() const noexcept
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
const _CharT * data() const noexcept
Return const pointer to contents.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
const_reverse_iterator rend() const noexcept
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 basic_string &__str)
Append a string to this string.
basic_string() noexcept
Default constructor creates an empty string.
const_iterator cbegin() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
basic_string & operator+=(_CharT __c)
Append a character.
reverse_iterator rbegin()
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append 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 & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
void push_back(_CharT __c)
Append a single character.
iterator erase(iterator __position)
Remove one character.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
_GLIBCXX_NODISCARD bool empty() const noexcept
Template class basic_istream.
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
Primary class template hash.
Uniform interface to all allocator types.
char_type widen(char __c) const
Widens characters.
~basic_string() noexcept
Destroy the string instance.
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.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Uniform interface to all pointer-like types.
basic_string & operator+=(const _CharT *__s)
Append a C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
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.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
const_iterator cend() const noexcept
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
size_type capacity() const noexcept
const_reverse_iterator rbegin() const noexcept
Uniform interface to C++98 and C++11 allocators.
int compare(const basic_string &__str) const
Compare to a string.
const_reverse_iterator crend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string< wchar_t > wstring
A string of wchar_t.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Basis for explicit traits specializations.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
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 insert(iterator __p, _CharT __c)
Insert one character.
Managing sequences of characters and character-like objects.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
_Iterator __base(_Iterator __it)
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 & assign(const basic_string &__str)
Set value to contents of another string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.