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 + __sv._M_check(__pos,
"basic_string::append"),
1340 __sv._M_limit(__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(), __sv.data()
1511 + __sv._M_check(__pos,
"basic_string::assign"),
1512 __sv._M_limit(__pos, __n));
1516 #if __cplusplus >= 201103L 1533 insert(const_iterator __p, size_type __n, _CharT __c)
1535 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1536 const size_type __pos = __p -
begin();
1537 this->
replace(__p, __p, __n, __c);
1538 return iterator(this->_M_data() + __pos);
1555 insert(iterator __p, size_type __n, _CharT __c)
1556 { this->
replace(__p, __p, __n, __c); }
1559 #if __cplusplus >= 201103L 1574 template<
class _InputIterator,
1575 typename = std::_RequireInputIter<_InputIterator>>
1577 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1579 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1580 const size_type __pos = __p -
begin();
1581 this->
replace(__p, __p, __beg, __end);
1582 return iterator(this->_M_data() + __pos);
1597 template<
class _InputIterator>
1599 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1600 { this->
replace(__p, __p, __beg, __end); }
1603 #if __cplusplus >= 201103L 1611 insert(const_iterator __p, initializer_list<_CharT> __l)
1612 {
return this->
insert(__p, __l.begin(), __l.end()); }
1614 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 1617 insert(iterator __p, initializer_list<_CharT> __l)
1619 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1620 this->
insert(__p -
begin(), __l.begin(), __l.size());
1639 {
return this->
replace(__pos1, size_type(0),
1640 __str._M_data(), __str.size()); }
1662 size_type __pos2, size_type __n =
npos)
1663 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1664 + __str._M_check(__pos2,
"basic_string::insert"),
1665 __str._M_limit(__pos2, __n)); }
1684 insert(size_type __pos,
const _CharT* __s, size_type __n)
1685 {
return this->
replace(__pos, size_type(0), __s, __n); }
1703 insert(size_type __pos,
const _CharT* __s)
1705 __glibcxx_requires_string(__s);
1706 return this->
replace(__pos, size_type(0), __s,
1707 traits_type::length(__s));
1727 insert(size_type __pos, size_type __n, _CharT __c)
1728 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1729 size_type(0), __n, __c); }
1745 insert(__const_iterator __p, _CharT __c)
1747 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1748 const size_type __pos = __p -
begin();
1749 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1750 return iterator(_M_data() + __pos);
1753 #if __cplusplus >= 201703L 1760 template<
typename _Tp>
1761 _If_sv<_Tp, basic_string&>
1762 insert(size_type __pos,
const _Tp& __svt)
1764 __sv_type __sv = __svt;
1765 return this->
insert(__pos, __sv.data(), __sv.size());
1777 template<
typename _Tp>
1778 _If_sv<_Tp, basic_string&>
1779 insert(size_type __pos1,
const _Tp& __svt,
1780 size_type __pos2, size_type __n =
npos)
1782 __sv_type __sv = __svt;
1783 return this->
replace(__pos1, size_type(0), __sv.data()
1784 + __sv._M_check(__pos2,
"basic_string::insert"),
1785 __sv._M_limit(__pos2, __n));
1805 erase(size_type __pos = 0, size_type __n =
npos)
1807 _M_check(__pos,
"basic_string::erase");
1809 this->_M_set_length(__pos);
1811 this->_M_erase(__pos, _M_limit(__pos, __n));
1824 erase(__const_iterator __position)
1826 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1827 && __position <
end());
1828 const size_type __pos = __position -
begin();
1829 this->_M_erase(__pos, size_type(1));
1830 return iterator(_M_data() + __pos);
1843 erase(__const_iterator __first, __const_iterator __last)
1845 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1846 && __last <=
end());
1847 const size_type __pos = __first -
begin();
1848 if (__last ==
end())
1849 this->_M_set_length(__pos);
1851 this->_M_erase(__pos, __last - __first);
1852 return iterator(this->_M_data() + __pos);
1855 #if __cplusplus >= 201103L 1864 __glibcxx_assert(!
empty());
1865 _M_erase(
size() - 1, 1);
1888 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1910 size_type __pos2, size_type __n2 =
npos)
1911 {
return this->
replace(__pos1, __n1, __str._M_data()
1912 + __str._M_check(__pos2,
"basic_string::replace"),
1913 __str._M_limit(__pos2, __n2)); }
1934 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1937 __glibcxx_requires_string_len(__s, __n2);
1938 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1939 _M_limit(__pos, __n1), __s, __n2);
1959 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1961 __glibcxx_requires_string(__s);
1962 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1983 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1984 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1985 _M_limit(__pos, __n1), __n2, __c); }
2001 replace(__const_iterator __i1, __const_iterator __i2,
2003 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2021 replace(__const_iterator __i1, __const_iterator __i2,
2022 const _CharT* __s, size_type __n)
2024 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2026 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2043 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2045 __glibcxx_requires_string(__s);
2046 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2064 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2067 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2069 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2087 #if __cplusplus >= 201103L 2088 template<
class _InputIterator,
2089 typename = std::_RequireInputIter<_InputIterator>>
2091 replace(const_iterator __i1, const_iterator __i2,
2092 _InputIterator __k1, _InputIterator __k2)
2094 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2096 __glibcxx_requires_valid_range(__k1, __k2);
2097 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2098 std::__false_type());
2101 template<
class _InputIterator>
2102 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2103 typename __enable_if_not_native_iterator<_InputIterator>::__type
2107 replace(iterator __i1, iterator __i2,
2108 _InputIterator __k1, _InputIterator __k2)
2110 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2112 __glibcxx_requires_valid_range(__k1, __k2);
2113 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2114 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2121 replace(__const_iterator __i1, __const_iterator __i2,
2122 _CharT* __k1, _CharT* __k2)
2124 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2126 __glibcxx_requires_valid_range(__k1, __k2);
2132 replace(__const_iterator __i1, __const_iterator __i2,
2133 const _CharT* __k1,
const _CharT* __k2)
2135 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2137 __glibcxx_requires_valid_range(__k1, __k2);
2143 replace(__const_iterator __i1, __const_iterator __i2,
2144 iterator __k1, iterator __k2)
2146 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2148 __glibcxx_requires_valid_range(__k1, __k2);
2150 __k1.base(), __k2 - __k1);
2154 replace(__const_iterator __i1, __const_iterator __i2,
2155 const_iterator __k1, const_iterator __k2)
2157 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2159 __glibcxx_requires_valid_range(__k1, __k2);
2161 __k1.base(), __k2 - __k1);
2164 #if __cplusplus >= 201103L 2180 initializer_list<_CharT> __l)
2181 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2184 #if __cplusplus >= 201703L 2192 template<
typename _Tp>
2193 _If_sv<_Tp, basic_string&>
2194 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2196 __sv_type __sv = __svt;
2197 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2209 template<
typename _Tp>
2210 _If_sv<_Tp, basic_string&>
2211 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2212 size_type __pos2, size_type __n2 =
npos)
2214 __sv_type __sv = __svt;
2215 return this->
replace(__pos1, __n1, __sv.data()
2216 + __sv._M_check(__pos2,
"basic_string::replace"),
2217 __sv._M_limit(__pos2, __n2));
2229 template<
typename _Tp>
2230 _If_sv<_Tp, basic_string&>
2231 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2233 __sv_type __sv = __svt;
2234 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2239 template<
class _Integer>
2241 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2242 _Integer __n, _Integer __val, __true_type)
2243 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2245 template<
class _InputIterator>
2247 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2248 _InputIterator __k1, _InputIterator __k2,
2252 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2256 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2257 const size_type __len2);
2260 _M_append(
const _CharT* __s, size_type __n);
2277 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2297 c_str() const _GLIBCXX_NOEXCEPT
2298 {
return _M_data(); }
2309 data() const _GLIBCXX_NOEXCEPT
2310 {
return _M_data(); }
2312 #if __cplusplus >= 201703L 2321 {
return _M_data(); }
2329 {
return _M_get_allocator(); }
2344 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2360 {
return this->
find(__str.data(), __pos, __str.size()); }
2362 #if __cplusplus >= 201703L 2369 template<
typename _Tp>
2370 _If_sv<_Tp, size_type>
2371 find(
const _Tp& __svt, size_type __pos = 0) const
2372 noexcept(is_same<_Tp, __sv_type>::value)
2374 __sv_type __sv = __svt;
2375 return this->
find(__sv.data(), __pos, __sv.size());
2390 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2392 __glibcxx_requires_string(__s);
2393 return this->
find(__s, __pos, traits_type::length(__s));
2407 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2422 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2424 #if __cplusplus >= 201703L 2431 template<
typename _Tp>
2432 _If_sv<_Tp, size_type>
2433 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 2434 noexcept(is_same<_Tp, __sv_type>::value)
2436 __sv_type __sv = __svt;
2437 return this->
rfind(__sv.data(), __pos, __sv.size());
2454 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2468 rfind(
const _CharT* __s, size_type __pos =
npos)
const 2470 __glibcxx_requires_string(__s);
2471 return this->
rfind(__s, __pos, traits_type::length(__s));
2485 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2501 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2503 #if __cplusplus >= 201703L 2511 template<
typename _Tp>
2512 _If_sv<_Tp, size_type>
2514 noexcept(is_same<_Tp, __sv_type>::value)
2516 __sv_type __sv = __svt;
2517 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2534 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2551 __glibcxx_requires_string(__s);
2552 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2568 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2569 {
return this->
find(__c, __pos); }
2585 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2587 #if __cplusplus >= 201703L 2595 template<
typename _Tp>
2596 _If_sv<_Tp, size_type>
2598 noexcept(is_same<_Tp, __sv_type>::value)
2600 __sv_type __sv = __svt;
2601 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2618 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2635 __glibcxx_requires_string(__s);
2636 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2653 {
return this->
rfind(__c, __pos); }
2670 #if __cplusplus >= 201703L 2678 template<
typename _Tp>
2679 _If_sv<_Tp, size_type>
2681 noexcept(is_same<_Tp, __sv_type>::value)
2683 __sv_type __sv = __svt;
2702 size_type __n)
const _GLIBCXX_NOEXCEPT;
2718 __glibcxx_requires_string(__s);
2752 #if __cplusplus >= 201703L 2760 template<
typename _Tp>
2761 _If_sv<_Tp, size_type>
2763 noexcept(is_same<_Tp, __sv_type>::value)
2765 __sv_type __sv = __svt;
2784 size_type __n)
const _GLIBCXX_NOEXCEPT;
2800 __glibcxx_requires_string(__s);
2831 substr(size_type __pos = 0, size_type __n =
npos)
const 2833 _M_check(__pos,
"basic_string::substr"), __n); }
2852 const size_type __size = this->
size();
2853 const size_type __osize = __str.size();
2854 const size_type __len =
std::min(__size, __osize);
2856 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2858 __r = _S_compare(__size, __osize);
2862 #if __cplusplus >= 201703L 2868 template<
typename _Tp>
2870 compare(
const _Tp& __svt)
const 2871 noexcept(is_same<_Tp, __sv_type>::value)
2873 __sv_type __sv = __svt;
2874 const size_type __size = this->
size();
2875 const size_type __osize = __sv.size();
2876 const size_type __len =
std::min(__size, __osize);
2878 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2880 __r = _S_compare(__size, __osize);
2892 template<
typename _Tp>
2894 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 2895 noexcept(is_same<_Tp, __sv_type>::value)
2897 __sv_type __sv = __svt;
2898 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2911 template<
typename _Tp>
2913 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2914 size_type __pos2, size_type __n2 =
npos)
const 2915 noexcept(is_same<_Tp, __sv_type>::value)
2917 __sv_type __sv = __svt;
2918 return __sv_type(*
this)
2919 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2970 size_type __pos2, size_type __n2 =
npos)
const;
2987 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3011 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3038 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3039 size_type __n2)
const;
3041 #if __cplusplus > 201703L 3043 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3044 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3047 starts_with(_CharT __x)
const noexcept
3048 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3051 starts_with(
const _CharT* __x)
const noexcept
3052 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3055 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3056 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3059 ends_with(_CharT __x)
const noexcept
3060 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3063 ends_with(
const _CharT* __x)
const noexcept
3064 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3068 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3070 _GLIBCXX_END_NAMESPACE_CXX11
3071 #else // !_GLIBCXX_USE_CXX11_ABI 3136 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3139 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3143 typedef _Traits traits_type;
3144 typedef typename _Traits::char_type value_type;
3145 typedef _Alloc allocator_type;
3146 typedef typename _CharT_alloc_type::size_type size_type;
3147 typedef typename _CharT_alloc_type::difference_type difference_type;
3148 #if __cplusplus < 201103L 3149 typedef typename _CharT_alloc_type::reference reference;
3150 typedef typename _CharT_alloc_type::const_reference const_reference;
3152 typedef value_type& reference;
3153 typedef const value_type& const_reference;
3155 typedef typename _CharT_alloc_type::pointer pointer;
3156 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3157 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3158 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3165 typedef iterator __const_iterator;
3184 size_type _M_length;
3185 size_type _M_capacity;
3186 _Atomic_word _M_refcount;
3189 struct _Rep : _Rep_base
3192 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3207 static const size_type _S_max_size;
3208 static const _CharT _S_terminal;
3212 static size_type _S_empty_rep_storage[];
3215 _S_empty_rep() _GLIBCXX_NOEXCEPT
3220 void* __p = reinterpret_cast<void*>(&_S_empty_rep_storage);
3221 return *reinterpret_cast<_Rep*>(__p);
3225 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3227 #if defined(__GTHREADS) 3232 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3234 return this->_M_refcount < 0;
3239 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3241 #if defined(__GTHREADS) 3247 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3249 return this->_M_refcount > 0;
3254 _M_set_leaked() _GLIBCXX_NOEXCEPT
3255 { this->_M_refcount = -1; }
3258 _M_set_sharable() _GLIBCXX_NOEXCEPT
3259 { this->_M_refcount = 0; }
3262 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3264 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3265 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3268 this->_M_set_sharable();
3269 this->_M_length = __n;
3270 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3277 _M_refdata()
throw()
3278 {
return reinterpret_cast<_CharT*>(
this + 1); }
3281 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3283 return (!_M_is_leaked() && __alloc1 == __alloc2)
3284 ? _M_refcopy() : _M_clone(__alloc1);
3289 _S_create(size_type, size_type,
const _Alloc&);
3292 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3294 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3295 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3299 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3308 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3311 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3318 _M_destroy(
const _Alloc&)
throw();
3321 _M_refcopy()
throw()
3323 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3324 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3326 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3327 return _M_refdata();
3331 _M_clone(
const _Alloc&, size_type __res = 0);
3335 struct _Alloc_hider : _Alloc
3337 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3338 : _Alloc(__a), _M_p(__dat) { }
3348 static const size_type
npos = static_cast<size_type>(-1);
3352 mutable _Alloc_hider _M_dataplus;
3355 _M_data() const _GLIBCXX_NOEXCEPT
3356 {
return _M_dataplus._M_p; }
3359 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3360 {
return (_M_dataplus._M_p = __p); }
3363 _M_rep() const _GLIBCXX_NOEXCEPT
3364 {
return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); }
3369 _M_ibegin() const _GLIBCXX_NOEXCEPT
3370 {
return iterator(_M_data()); }
3373 _M_iend() const _GLIBCXX_NOEXCEPT
3374 {
return iterator(_M_data() + this->
size()); }
3379 if (!_M_rep()->_M_is_leaked())
3384 _M_check(size_type __pos,
const char* __s)
const 3386 if (__pos > this->
size())
3387 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3388 "this->size() (which is %zu)"),
3389 __s, __pos, this->
size());
3394 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3397 __throw_length_error(__N(__s));
3402 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3404 const bool __testoff = __off < this->
size() - __pos;
3405 return __testoff ? __off : this->
size() - __pos;
3410 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3412 return (less<const _CharT*>()(__s, _M_data())
3413 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3419 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3422 traits_type::assign(*__d, *__s);
3424 traits_type::copy(__d, __s, __n);
3428 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3431 traits_type::assign(*__d, *__s);
3433 traits_type::move(__d, __s, __n);
3437 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3440 traits_type::assign(*__d, __c);
3442 traits_type::assign(__d, __n, __c);
3447 template<
class _Iterator>
3449 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3451 for (; __k1 != __k2; ++__k1, (void)++__p)
3452 traits_type::assign(*__p, *__k1);
3456 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3457 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3460 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3462 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3465 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3466 { _M_copy(__p, __k1, __k2 - __k1); }
3469 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3471 { _M_copy(__p, __k1, __k2 - __k1); }
3474 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3476 const difference_type __d = difference_type(__n1 - __n2);
3478 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3479 return __gnu_cxx::__numeric_traits<int>::__max;
3480 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3481 return __gnu_cxx::__numeric_traits<int>::__min;
3487 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3493 _S_empty_rep() _GLIBCXX_NOEXCEPT
3494 {
return _Rep::_S_empty_rep(); }
3496 #if __cplusplus >= 201703L 3498 typedef basic_string_view<_CharT, _Traits> __sv_type;
3500 template<
typename _Tp,
typename _Res>
3502 __and_<is_convertible<const _Tp&, __sv_type>,
3503 __not_<is_convertible<const _Tp*, const basic_string*>>,
3504 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3509 _S_to_string_view(__sv_type __svt) noexcept
3518 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3542 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3544 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3546 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3572 const _Alloc& __a = _Alloc());
3590 size_type __n,
const _Alloc& __a);
3602 const _Alloc& __a = _Alloc());
3608 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3615 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3617 #if __cplusplus >= 201103L 3626 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3629 : _M_dataplus(std::move(__str._M_dataplus))
3631 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3632 __str._M_data(_S_empty_rep()._M_refdata());
3634 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3646 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3650 : _M_dataplus(__str._M_data(), __a)
3652 if (__a == __str.get_allocator())
3654 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3655 __str._M_data(_S_empty_rep()._M_refdata());
3657 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3661 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3671 template<
class _InputIterator>
3672 basic_string(_InputIterator __beg, _InputIterator __end,
3673 const _Alloc& __a = _Alloc());
3675 #if __cplusplus >= 201703L 3683 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3684 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3685 const _Alloc& __a = _Alloc())
3693 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3695 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3696 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3711 {
return this->
assign(__str); }
3719 {
return this->
assign(__s); }
3735 #if __cplusplus >= 201103L 3759 this->
assign(__l.begin(), __l.size());
3764 #if __cplusplus >= 201703L 3769 template<
typename _Tp>
3770 _If_sv<_Tp, basic_string&>
3772 {
return this->
assign(__svt); }
3778 operator __sv_type() const noexcept
3779 {
return __sv_type(
data(),
size()); }
3791 return iterator(_M_data());
3800 {
return const_iterator(_M_data()); }
3810 return iterator(_M_data() + this->
size());
3819 {
return const_iterator(_M_data() + this->
size()); }
3835 const_reverse_iterator
3853 const_reverse_iterator
3857 #if __cplusplus >= 201103L 3864 {
return const_iterator(this->_M_data()); }
3872 {
return const_iterator(this->_M_data() + this->
size()); }
3879 const_reverse_iterator
3888 const_reverse_iterator
3899 {
return _M_rep()->_M_length; }
3905 {
return _M_rep()->_M_length; }
3910 {
return _Rep::_S_max_size; }
3923 resize(size_type __n, _CharT __c);
3937 { this->
resize(__n, _CharT()); }
3939 #if __cplusplus >= 201103L 3944 #if __cpp_exceptions 3962 {
return _M_rep()->_M_capacity; }
3982 reserve(size_type __res_arg = 0);
3987 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3991 if (_M_rep()->_M_is_shared())
3994 _M_data(_S_empty_rep()._M_refdata());
3997 _M_rep()->_M_set_length_and_sharable(0);
4003 { _M_mutate(0, this->
size(), 0); }
4010 _GLIBCXX_NODISCARD
bool 4012 {
return this->
size() == 0; }
4028 __glibcxx_assert(__pos <=
size());
4029 return _M_data()[__pos];
4047 __glibcxx_assert(__pos <=
size());
4049 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4051 return _M_data()[__pos];
4067 if (__n >= this->
size())
4068 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4069 "(which is %zu) >= this->size() " 4072 return _M_data()[__n];
4090 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4091 "(which is %zu) >= this->size() " 4095 return _M_data()[__n];
4098 #if __cplusplus >= 201103L 4106 __glibcxx_assert(!
empty());
4117 __glibcxx_assert(!
empty());
4128 __glibcxx_assert(!
empty());
4139 __glibcxx_assert(!
empty());
4152 {
return this->
append(__str); }
4161 {
return this->
append(__s); }
4175 #if __cplusplus >= 201103L 4183 {
return this->
append(__l.begin(), __l.size()); }
4186 #if __cplusplus >= 201703L 4192 template<
typename _Tp>
4193 _If_sv<_Tp, basic_string&>
4195 {
return this->
append(__svt); }
4229 append(
const _CharT* __s, size_type __n);
4239 __glibcxx_requires_string(__s);
4240 return this->
append(__s, traits_type::length(__s));
4252 append(size_type __n, _CharT __c);
4254 #if __cplusplus >= 201103L 4262 {
return this->
append(__l.begin(), __l.size()); }
4273 template<
class _InputIterator>
4275 append(_InputIterator __first, _InputIterator __last)
4276 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4278 #if __cplusplus >= 201703L 4284 template<
typename _Tp>
4285 _If_sv<_Tp, basic_string&>
4288 __sv_type __sv = __svt;
4289 return this->
append(__sv.data(), __sv.size());
4300 template<
typename _Tp>
4301 _If_sv<_Tp, basic_string&>
4302 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4304 __sv_type __sv = __svt;
4305 return append(__sv.data()
4306 + __sv._M_check(__pos,
"basic_string::append"),
4307 __sv._M_limit(__pos, __n));
4318 const size_type __len = 1 + this->
size();
4319 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4321 traits_type::assign(_M_data()[this->
size()], __c);
4322 _M_rep()->_M_set_length_and_sharable(__len);
4333 #if __cplusplus >= 201103L 4366 {
return this->
assign(__str._M_data()
4367 + __str._M_check(__pos,
"basic_string::assign"),
4368 __str._M_limit(__pos, __n)); }
4381 assign(
const _CharT* __s, size_type __n);
4395 __glibcxx_requires_string(__s);
4396 return this->
assign(__s, traits_type::length(__s));
4410 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4420 template<
class _InputIterator>
4422 assign(_InputIterator __first, _InputIterator __last)
4423 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4425 #if __cplusplus >= 201103L 4433 {
return this->
assign(__l.begin(), __l.size()); }
4436 #if __cplusplus >= 201703L 4442 template<
typename _Tp>
4443 _If_sv<_Tp, basic_string&>
4446 __sv_type __sv = __svt;
4447 return this->
assign(__sv.data(), __sv.size());
4457 template<
typename _Tp>
4458 _If_sv<_Tp, basic_string&>
4459 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4461 __sv_type __sv = __svt;
4462 return assign(__sv.data()
4463 + __sv._M_check(__pos,
"basic_string::assign"),
4464 __sv._M_limit(__pos, __n));
4482 insert(iterator __p, size_type __n, _CharT __c)
4483 { this->
replace(__p, __p, __n, __c); }
4497 template<
class _InputIterator>
4499 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4500 { this->
replace(__p, __p, __beg, __end); }
4502 #if __cplusplus >= 201103L 4512 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4513 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4531 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4553 size_type __pos2, size_type __n =
npos)
4554 {
return this->
insert(__pos1, __str._M_data()
4555 + __str._M_check(__pos2,
"basic_string::insert"),
4556 __str._M_limit(__pos2, __n)); }
4575 insert(size_type __pos,
const _CharT* __s, size_type __n);
4595 __glibcxx_requires_string(__s);
4596 return this->
insert(__pos, __s, traits_type::length(__s));
4616 insert(size_type __pos, size_type __n, _CharT __c)
4617 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4618 size_type(0), __n, __c); }
4636 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4637 const size_type __pos = __p - _M_ibegin();
4638 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4639 _M_rep()->_M_set_leaked();
4640 return iterator(_M_data() + __pos);
4643 #if __cplusplus >= 201703L 4650 template<
typename _Tp>
4651 _If_sv<_Tp, basic_string&>
4652 insert(size_type __pos,
const _Tp& __svt)
4654 __sv_type __sv = __svt;
4655 return this->
insert(__pos, __sv.data(), __sv.size());
4667 template<
typename _Tp>
4668 _If_sv<_Tp, basic_string&>
4669 insert(size_type __pos1,
const _Tp& __svt,
4670 size_type __pos2, size_type __n =
npos)
4672 __sv_type __sv = __svt;
4673 return this->
replace(__pos1, size_type(0), __sv.data()
4674 + __sv._M_check(__pos2,
"basic_string::insert"),
4675 __sv._M_limit(__pos2, __n));
4697 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4698 _M_limit(__pos, __n), size_type(0));
4713 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4714 && __position < _M_iend());
4715 const size_type __pos = __position - _M_ibegin();
4716 _M_mutate(__pos, size_type(1), size_type(0));
4717 _M_rep()->_M_set_leaked();
4718 return iterator(_M_data() + __pos);
4733 #if __cplusplus >= 201103L 4742 __glibcxx_assert(!
empty());
4766 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4788 size_type __pos2, size_type __n2 =
npos)
4789 {
return this->
replace(__pos1, __n1, __str._M_data()
4790 + __str._M_check(__pos2,
"basic_string::replace"),
4791 __str._M_limit(__pos2, __n2)); }
4812 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4832 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4834 __glibcxx_requires_string(__s);
4835 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4856 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4857 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4858 _M_limit(__pos, __n1), __n2, __c); }
4875 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4893 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4895 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4896 && __i2 <= _M_iend());
4897 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4914 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4916 __glibcxx_requires_string(__s);
4917 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4935 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4937 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4938 && __i2 <= _M_iend());
4939 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4957 template<
class _InputIterator>
4960 _InputIterator __k1, _InputIterator __k2)
4962 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4963 && __i2 <= _M_iend());
4964 __glibcxx_requires_valid_range(__k1, __k2);
4965 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4966 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4974 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4975 && __i2 <= _M_iend());
4976 __glibcxx_requires_valid_range(__k1, __k2);
4977 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4982 replace(iterator __i1, iterator __i2,
4983 const _CharT* __k1,
const _CharT* __k2)
4985 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4986 && __i2 <= _M_iend());
4987 __glibcxx_requires_valid_range(__k1, __k2);
4988 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4993 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4995 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4996 && __i2 <= _M_iend());
4997 __glibcxx_requires_valid_range(__k1, __k2);
4998 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4999 __k1.base(), __k2 - __k1);
5003 replace(iterator __i1, iterator __i2,
5004 const_iterator __k1, const_iterator __k2)
5006 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5007 && __i2 <= _M_iend());
5008 __glibcxx_requires_valid_range(__k1, __k2);
5009 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5010 __k1.base(), __k2 - __k1);
5013 #if __cplusplus >= 201103L 5030 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5033 #if __cplusplus >= 201703L 5041 template<
typename _Tp>
5042 _If_sv<_Tp, basic_string&>
5043 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5045 __sv_type __sv = __svt;
5046 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5058 template<
typename _Tp>
5059 _If_sv<_Tp, basic_string&>
5060 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5061 size_type __pos2, size_type __n2 =
npos)
5063 __sv_type __sv = __svt;
5064 return this->
replace(__pos1, __n1,
5065 __sv.data() + __sv._M_check(__pos2,
"basic_string::replace"),
5066 __sv._M_limit(__pos2, __n2));
5078 template<
typename _Tp>
5079 _If_sv<_Tp, basic_string&>
5080 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5082 __sv_type __sv = __svt;
5083 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5088 template<
class _Integer>
5090 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5091 _Integer __val, __true_type)
5092 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5094 template<
class _InputIterator>
5096 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5097 _InputIterator __k2, __false_type);
5100 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5104 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5109 template<
class _InIterator>
5111 _S_construct_aux(_InIterator __beg, _InIterator __end,
5112 const _Alloc& __a, __false_type)
5114 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5115 return _S_construct(__beg, __end, __a, _Tag());
5120 template<
class _Integer>
5122 _S_construct_aux(_Integer __beg, _Integer __end,
5123 const _Alloc& __a, __true_type)
5124 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5128 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5129 {
return _S_construct(__req, __c, __a); }
5131 template<
class _InIterator>
5133 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5135 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5136 return _S_construct_aux(__beg, __end, __a, _Integral());
5140 template<
class _InIterator>
5142 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5143 input_iterator_tag);
5147 template<
class _FwdIterator>
5149 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5150 forward_iterator_tag);
5153 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5170 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5181 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5192 {
return _M_data(); }
5204 {
return _M_data(); }
5206 #if __cplusplus >= 201703L 5226 {
return _M_dataplus; }
5241 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5257 {
return this->
find(__str.data(), __pos, __str.size()); }
5270 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5272 __glibcxx_requires_string(__s);
5273 return this->
find(__s, __pos, traits_type::length(__s));
5287 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5289 #if __cplusplus >= 201703L 5296 template<
typename _Tp>
5297 _If_sv<_Tp, size_type>
5298 find(
const _Tp& __svt, size_type __pos = 0) const
5299 noexcept(
is_same<_Tp, __sv_type>::value)
5301 __sv_type __sv = __svt;
5302 return this->
find(__sv.data(), __pos, __sv.size());
5319 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5334 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5348 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5350 __glibcxx_requires_string(__s);
5351 return this->
rfind(__s, __pos, traits_type::length(__s));
5365 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5367 #if __cplusplus >= 201703L 5374 template<
typename _Tp>
5375 _If_sv<_Tp, size_type>
5376 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 5379 __sv_type __sv = __svt;
5380 return this->
rfind(__sv.data(), __pos, __sv.size());
5398 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5413 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5430 __glibcxx_requires_string(__s);
5431 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5448 {
return this->
find(__c, __pos); }
5450 #if __cplusplus >= 201703L 5458 template<
typename _Tp>
5459 _If_sv<_Tp, size_type>
5461 noexcept(
is_same<_Tp, __sv_type>::value)
5463 __sv_type __sv = __svt;
5464 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5482 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5497 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5514 __glibcxx_requires_string(__s);
5515 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5532 {
return this->
rfind(__c, __pos); }
5534 #if __cplusplus >= 201703L 5542 template<
typename _Tp>
5543 _If_sv<_Tp, size_type>
5547 __sv_type __sv = __svt;
5548 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5581 size_type __n)
const _GLIBCXX_NOEXCEPT;
5597 __glibcxx_requires_string(__s);
5615 #if __cplusplus >= 201703L 5623 template<
typename _Tp>
5624 _If_sv<_Tp, size_type>
5626 noexcept(
is_same<_Tp, __sv_type>::value)
5628 __sv_type __sv = __svt;
5663 size_type __n)
const _GLIBCXX_NOEXCEPT;
5679 __glibcxx_requires_string(__s);
5697 #if __cplusplus >= 201703L 5705 template<
typename _Tp>
5706 _If_sv<_Tp, size_type>
5710 __sv_type __sv = __svt;
5730 _M_check(__pos,
"basic_string::substr"), __n); }
5749 const size_type __size = this->
size();
5750 const size_type __osize = __str.size();
5751 const size_type __len =
std::min(__size, __osize);
5753 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5755 __r = _S_compare(__size, __osize);
5759 #if __cplusplus >= 201703L 5765 template<
typename _Tp>
5767 compare(
const _Tp& __svt)
const 5770 __sv_type __sv = __svt;
5771 const size_type __size = this->
size();
5772 const size_type __osize = __sv.size();
5773 const size_type __len =
std::min(__size, __osize);
5775 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5777 __r = _S_compare(__size, __osize);
5789 template<
typename _Tp>
5791 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5792 noexcept(is_same<_Tp, __sv_type>::value)
5794 __sv_type __sv = __svt;
5795 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5808 template<
typename _Tp>
5810 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5811 size_type __pos2, size_type __n2 =
npos)
const 5812 noexcept(is_same<_Tp, __sv_type>::value)
5814 __sv_type __sv = __svt;
5815 return __sv_type(*
this)
5816 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5867 size_type __pos2, size_type __n2 =
npos)
const;
5884 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5908 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5935 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5936 size_type __n2)
const;
5938 #if __cplusplus > 201703L 5940 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5941 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5944 starts_with(_CharT __x)
const noexcept
5945 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5948 starts_with(
const _CharT* __x)
const noexcept
5949 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5952 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5953 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5956 ends_with(_CharT __x)
const noexcept
5957 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5960 ends_with(
const _CharT* __x)
const noexcept
5961 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5964 # ifdef _GLIBCXX_TM_TS_INTERNAL 5966 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5969 ::_txnal_cow_string_c_str(
const void *that);
5971 ::_txnal_cow_string_D1(
void *that);
5973 ::_txnal_cow_string_D1_commit(
void *that);
5976 #endif // !_GLIBCXX_USE_CXX11_ABI 5978 #if __cpp_deduction_guides >= 201606 5979 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5980 template<
typename _InputIterator,
typename _CharT
5981 =
typename iterator_traits<_InputIterator>::value_type,
5982 typename _Allocator = allocator<_CharT>,
5983 typename = _RequireInputIter<_InputIterator>,
5984 typename = _RequireAllocator<_Allocator>>
5985 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5986 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5990 template<
typename _CharT,
typename _Traits,
5991 typename _Allocator = allocator<_CharT>,
5992 typename = _RequireAllocator<_Allocator>>
5993 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5994 -> basic_string<_CharT, _Traits, _Allocator>;
5996 template<
typename _CharT,
typename _Traits,
5997 typename _Allocator = allocator<_CharT>,
5998 typename = _RequireAllocator<_Allocator>>
5999 basic_string(basic_string_view<_CharT, _Traits>,
6000 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6001 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6002 const _Allocator& = _Allocator())
6003 -> basic_string<_CharT, _Traits, _Allocator>;
6004 _GLIBCXX_END_NAMESPACE_CXX11
6014 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6015 basic_string<_CharT, _Traits, _Alloc>
6020 __str.append(__rhs);
6030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6031 basic_string<_CharT,_Traits,_Alloc>
6033 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6041 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6042 basic_string<_CharT,_Traits,_Alloc>
6043 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6051 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6052 inline basic_string<_CharT, _Traits, _Alloc>
6054 const _CharT* __rhs)
6057 __str.append(__rhs);
6067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6068 inline basic_string<_CharT, _Traits, _Alloc>
6072 typedef typename __string_type::size_type __size_type;
6073 __string_type __str(__lhs);
6074 __str.append(__size_type(1), __rhs);
6078 #if __cplusplus >= 201103L 6079 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6080 inline basic_string<_CharT, _Traits, _Alloc>
6081 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6082 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6083 {
return std::move(__lhs.append(__rhs)); }
6085 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6086 inline basic_string<_CharT, _Traits, _Alloc>
6087 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6088 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6089 {
return std::move(__rhs.insert(0, __lhs)); }
6091 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6092 inline basic_string<_CharT, _Traits, _Alloc>
6093 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6094 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6096 const auto __size = __lhs.size() + __rhs.size();
6097 const bool __cond = (__size > __lhs.capacity()
6098 && __size <= __rhs.capacity());
6099 return __cond ? std::move(__rhs.insert(0, __lhs))
6100 : std::move(__lhs.append(__rhs));
6103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6104 inline basic_string<_CharT, _Traits, _Alloc>
6106 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6107 {
return std::move(__rhs.insert(0, __lhs)); }
6109 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6110 inline basic_string<_CharT, _Traits, _Alloc>
6112 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6113 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6116 inline basic_string<_CharT, _Traits, _Alloc>
6117 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6118 const _CharT* __rhs)
6119 {
return std::move(__lhs.append(__rhs)); }
6121 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6122 inline basic_string<_CharT, _Traits, _Alloc>
6123 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6125 {
return std::move(__lhs.append(1, __rhs)); }
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6140 {
return __lhs.compare(__rhs) == 0; }
6142 template<
typename _CharT>
6144 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6145 operator==(
const basic_string<_CharT>& __lhs,
6146 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6147 {
return (__lhs.size() == __rhs.size()
6157 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6159 operator==(
const _CharT* __lhs,
6161 {
return __rhs.compare(__lhs) == 0; }
6169 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6172 const _CharT* __rhs)
6173 {
return __lhs.compare(__rhs) == 0; }
6182 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6187 {
return !(__lhs == __rhs); }
6195 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6197 operator!=(
const _CharT* __lhs,
6199 {
return !(__lhs == __rhs); }
6207 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6210 const _CharT* __rhs)
6211 {
return !(__lhs == __rhs); }
6220 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6225 {
return __lhs.compare(__rhs) < 0; }
6233 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6236 const _CharT* __rhs)
6237 {
return __lhs.compare(__rhs) < 0; }
6245 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6247 operator<(
const _CharT* __lhs,
6249 {
return __rhs.compare(__lhs) > 0; }
6258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6263 {
return __lhs.compare(__rhs) > 0; }
6271 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6274 const _CharT* __rhs)
6275 {
return __lhs.compare(__rhs) > 0; }
6283 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6285 operator>(
const _CharT* __lhs,
6287 {
return __rhs.compare(__lhs) < 0; }
6296 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6301 {
return __lhs.compare(__rhs) <= 0; }
6309 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6312 const _CharT* __rhs)
6313 {
return __lhs.compare(__rhs) <= 0; }
6321 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6323 operator<=(
const _CharT* __lhs,
6325 {
return __rhs.compare(__lhs) >= 0; }
6334 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6339 {
return __lhs.compare(__rhs) >= 0; }
6347 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6350 const _CharT* __rhs)
6351 {
return __lhs.compare(__rhs) >= 0; }
6359 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6361 operator>=(
const _CharT* __lhs,
6363 {
return __rhs.compare(__lhs) <= 0; }
6372 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6376 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6377 { __lhs.swap(__rhs); }
6392 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6393 basic_istream<_CharT, _Traits>&
6394 operator>>(basic_istream<_CharT, _Traits>& __is,
6395 basic_string<_CharT, _Traits, _Alloc>& __str);
6398 basic_istream<char>&
6399 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6410 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6411 inline basic_ostream<_CharT, _Traits>&
6417 return __ostream_insert(__os, __str.data(), __str.size());
6433 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6434 basic_istream<_CharT, _Traits>&
6435 getline(basic_istream<_CharT, _Traits>& __is,
6436 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6450 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6451 inline basic_istream<_CharT, _Traits>&
6456 #if __cplusplus >= 201103L 6458 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6459 inline basic_istream<_CharT, _Traits>&
6465 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6466 inline basic_istream<_CharT, _Traits>&
6473 basic_istream<char>&
6474 getline(basic_istream<char>& __in, basic_string<char>& __str,
6477 #ifdef _GLIBCXX_USE_WCHAR_T 6479 basic_istream<wchar_t>&
6480 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6484 _GLIBCXX_END_NAMESPACE_VERSION
6487 #if __cplusplus >= 201103L 6491 namespace std _GLIBCXX_VISIBILITY(default)
6493 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6494 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6496 #if _GLIBCXX_USE_C99_STDLIB 6499 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6500 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6504 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6505 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6508 inline unsigned long 6509 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6510 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6514 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6515 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6518 inline unsigned long long 6519 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6520 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6525 stof(
const string& __str,
size_t* __idx = 0)
6526 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6529 stod(
const string& __str,
size_t* __idx = 0)
6530 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6533 stold(
const string& __str,
size_t* __idx = 0)
6534 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6535 #endif // _GLIBCXX_USE_C99_STDLIB 6537 #if _GLIBCXX_USE_C99_STDIO 6542 to_string(
int __val)
6543 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
int),
6547 to_string(
unsigned __val)
6548 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6549 4 *
sizeof(
unsigned),
6553 to_string(
long __val)
6554 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
long),
6558 to_string(
unsigned long __val)
6559 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6560 4 *
sizeof(
unsigned long),
6564 to_string(
long long __val)
6565 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6566 4 *
sizeof(
long long),
6570 to_string(
unsigned long long __val)
6571 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6572 4 *
sizeof(
unsigned long long),
6576 to_string(
float __val)
6579 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6580 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6585 to_string(
double __val)
6588 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6589 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6594 to_string(
long double __val)
6597 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6598 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6601 #endif // _GLIBCXX_USE_C99_STDIO 6603 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6605 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6606 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6610 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6611 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6614 inline unsigned long 6615 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6616 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6620 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6621 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6624 inline unsigned long long 6625 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6626 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6631 stof(
const wstring& __str,
size_t* __idx = 0)
6632 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6635 stod(
const wstring& __str,
size_t* __idx = 0)
6636 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6639 stold(
const wstring& __str,
size_t* __idx = 0)
6640 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6642 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6645 to_wstring(
int __val)
6646 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6650 to_wstring(
unsigned __val)
6651 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6652 4 *
sizeof(
unsigned),
6656 to_wstring(
long __val)
6657 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6661 to_wstring(
unsigned long __val)
6662 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6663 4 *
sizeof(
unsigned long),
6667 to_wstring(
long long __val)
6668 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6669 4 *
sizeof(
long long),
6673 to_wstring(
unsigned long long __val)
6674 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6675 4 *
sizeof(
unsigned long long),
6679 to_wstring(
float __val)
6682 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6683 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6688 to_wstring(
double __val)
6691 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6692 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6697 to_wstring(
long double __val)
6700 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6701 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6704 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6705 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6707 _GLIBCXX_END_NAMESPACE_CXX11
6708 _GLIBCXX_END_NAMESPACE_VERSION
6713 #if __cplusplus >= 201103L 6717 namespace std _GLIBCXX_VISIBILITY(default)
6719 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6723 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6727 :
public __hash_base<size_t, string>
6730 operator()(
const string& __s)
const noexcept
6731 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6738 #ifdef _GLIBCXX_USE_WCHAR_T 6742 :
public __hash_base<size_t, wstring>
6745 operator()(
const wstring& __s)
const noexcept
6746 {
return std::_Hash_impl::hash(__s.
data(),
6747 __s.
length() *
sizeof(wchar_t)); }
6756 #ifdef _GLIBCXX_USE_CHAR8_T 6759 struct hash<u8string>
6760 :
public __hash_base<size_t, u8string>
6763 operator()(
const u8string& __s)
const noexcept
6764 {
return std::_Hash_impl::hash(__s.data(),
6765 __s.length() *
sizeof(char8_t)); }
6776 :
public __hash_base<size_t, u16string>
6779 operator()(
const u16string& __s)
const noexcept
6780 {
return std::_Hash_impl::hash(__s.
data(),
6781 __s.
length() *
sizeof(char16_t)); }
6791 :
public __hash_base<size_t, u32string>
6794 operator()(
const u32string& __s)
const noexcept
6795 {
return std::_Hash_impl::hash(__s.
data(),
6796 __s.
length() *
sizeof(char32_t)); }
6803 #if __cplusplus > 201103L 6805 #define __cpp_lib_string_udls 201304 6807 inline namespace literals
6809 inline namespace string_literals
6811 #pragma GCC diagnostic push 6812 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6813 _GLIBCXX_DEFAULT_ABI_TAG
6814 inline basic_string<char>
6815 operator""s(
const char* __str,
size_t __len)
6816 {
return basic_string<char>{__str, __len}; }
6818 #ifdef _GLIBCXX_USE_WCHAR_T 6819 _GLIBCXX_DEFAULT_ABI_TAG
6820 inline basic_string<wchar_t>
6821 operator""s(
const wchar_t* __str,
size_t __len)
6822 {
return basic_string<wchar_t>{__str, __len}; }
6825 #ifdef _GLIBCXX_USE_CHAR8_T 6826 _GLIBCXX_DEFAULT_ABI_TAG
6827 inline basic_string<char8_t>
6828 operator""s(
const char8_t* __str,
size_t __len)
6829 {
return basic_string<char8_t>{__str, __len}; }
6832 _GLIBCXX_DEFAULT_ABI_TAG
6833 inline basic_string<char16_t>
6834 operator""s(
const char16_t* __str,
size_t __len)
6835 {
return basic_string<char16_t>{__str, __len}; }
6837 _GLIBCXX_DEFAULT_ABI_TAG
6838 inline basic_string<char32_t>
6839 operator""s(
const char32_t* __str,
size_t __len)
6840 {
return basic_string<char32_t>{__str, __len}; }
6842 #pragma GCC diagnostic pop 6846 #endif // __cplusplus > 201103L 6848 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
const_reference front() const noexcept
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
const_reverse_iterator crend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
Template class basic_istream.
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 find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
char_type widen(char __c) const
Widens characters.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string() noexcept
Default constructor creates an empty string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
Basis for explicit traits specializations.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
Primary class template hash.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
reverse_iterator rbegin()
basic_string & append(const _CharT *__s)
Append a C string.
ISO C++ entities toplevel namespace is std.
basic_string(basic_string &&__str) noexcept
Move construct string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string< wchar_t > wstring
A string of wchar_t.
const_reverse_iterator rbegin() const noexcept
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
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.
Managing sequences of characters and character-like objects.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
const _CharT * data() const noexcept
Return const pointer to contents.
reference at(size_type __n)
Provides access to the data contained in the string.
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.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
Template class basic_ostream.
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.
const_iterator begin() const noexcept
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
const_iterator cend() const noexcept
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_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
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
size_type capacity() const noexcept
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
~basic_string() noexcept
Destroy the string instance.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
Uniform interface to all allocator types.
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.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_reverse_iterator rend() const noexcept
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
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.
Uniform interface to C++98 and C++11 allocators.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
const_iterator cbegin() const noexcept
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_reverse_iterator crbegin() const noexcept
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
_GLIBCXX20_CONSTEXPR complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
_Iterator __base(_Iterator __it)
void push_back(_CharT __c)
Append a single character.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
iterator erase(iterator __position)
Remove one character.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
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.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
const_iterator end() const noexcept
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
void pop_back()
Remove the last character.
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.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Forward iterators support a superset of input iterator operations.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
static const size_type npos
Value returned by various member functions when they fail.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Uniform interface to all pointer-like types.
basic_string & operator+=(_CharT __c)
Append a character.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.