34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 #if __cplusplus > 201402L 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 > 201402L 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) { }
140 struct _Alloc_hider : allocator_type
142 #if __cplusplus < 201103L 143 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
144 : allocator_type(__a), _M_p(__dat) { }
146 _Alloc_hider(pointer __dat,
const _Alloc& __a)
147 : allocator_type(__a), _M_p(__dat) { }
149 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
150 : allocator_type(
std::move(__a)), _M_p(__dat) { }
156 _Alloc_hider _M_dataplus;
157 size_type _M_string_length;
159 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
163 _CharT _M_local_buf[_S_local_capacity + 1];
164 size_type _M_allocated_capacity;
169 { _M_dataplus._M_p = __p; }
172 _M_length(size_type __length)
173 { _M_string_length = __length; }
177 {
return _M_dataplus._M_p; }
182 #if __cplusplus >= 201103L 185 return pointer(_M_local_buf);
190 _M_local_data()
const 192 #if __cplusplus >= 201103L 195 return const_pointer(_M_local_buf);
200 _M_capacity(size_type __capacity)
201 { _M_allocated_capacity = __capacity; }
204 _M_set_length(size_type __n)
207 traits_type::assign(_M_data()[__n], _CharT());
212 {
return _M_data() == _M_local_data(); }
216 _M_create(size_type&, size_type);
222 _M_destroy(_M_allocated_capacity);
226 _M_destroy(size_type __size)
throw()
227 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
231 template<
typename _InIterator>
233 _M_construct_aux(_InIterator __beg, _InIterator __end,
236 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
237 _M_construct(__beg, __end, _Tag());
242 template<
typename _Integer>
244 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
245 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
248 _M_construct_aux_2(size_type __req, _CharT __c)
249 { _M_construct(__req, __c); }
251 template<
typename _InIterator>
253 _M_construct(_InIterator __beg, _InIterator __end)
255 typedef typename std::__is_integer<_InIterator>::__type _Integral;
256 _M_construct_aux(__beg, __end, _Integral());
260 template<
typename _InIterator>
262 _M_construct(_InIterator __beg, _InIterator __end,
267 template<
typename _FwdIterator>
269 _M_construct(_FwdIterator __beg, _FwdIterator __end,
273 _M_construct(size_type __req, _CharT __c);
277 {
return _M_dataplus; }
279 const allocator_type&
280 _M_get_allocator()
const 281 {
return _M_dataplus; }
285 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 288 template<
typename _Tp,
bool _Requires =
289 !__are_same<_Tp, _CharT*>::__value
290 && !__are_same<_Tp, const _CharT*>::__value
291 && !__are_same<_Tp, iterator>::__value
292 && !__are_same<_Tp, const_iterator>::__value>
293 struct __enable_if_not_native_iterator
295 template<
typename _Tp>
296 struct __enable_if_not_native_iterator<_Tp, false> { };
300 _M_check(size_type __pos,
const char* __s)
const 302 if (__pos > this->
size())
303 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 304 "this->size() (which is %zu)"),
305 __s, __pos, this->
size());
310 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 313 __throw_length_error(__N(__s));
319 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
321 const bool __testoff = __off < this->
size() - __pos;
322 return __testoff ? __off : this->
size() - __pos;
327 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
329 return (less<const _CharT*>()(__s, _M_data())
330 || less<const _CharT*>()(_M_data() + this->
size(), __s));
336 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
339 traits_type::assign(*__d, *__s);
341 traits_type::copy(__d, __s, __n);
345 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
348 traits_type::assign(*__d, *__s);
350 traits_type::move(__d, __s, __n);
354 _S_assign(_CharT* __d, size_type __n, _CharT __c)
357 traits_type::assign(*__d, __c);
359 traits_type::assign(__d, __n, __c);
364 template<
class _Iterator>
366 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
368 for (; __k1 != __k2; ++__k1, (void)++__p)
369 traits_type::assign(*__p, *__k1);
373 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
374 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
377 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
379 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
382 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
383 { _S_copy(__p, __k1, __k2 - __k1); }
386 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
388 { _S_copy(__p, __k1, __k2 - __k1); }
391 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
393 const difference_type __d = difference_type(__n1 - __n2);
395 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
396 return __gnu_cxx::__numeric_traits<int>::__max;
397 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
398 return __gnu_cxx::__numeric_traits<int>::__min;
407 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
411 _M_erase(size_type __pos, size_type __n);
422 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
423 : _M_dataplus(_M_local_data())
424 { _M_set_length(0); }
431 : _M_dataplus(_M_local_data(), __a)
432 { _M_set_length(0); }
439 : _M_dataplus(_M_local_data(),
440 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
441 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
452 const _Alloc& __a = _Alloc())
453 : _M_dataplus(_M_local_data(), __a)
455 const _CharT* __start = __str._M_data()
456 + __str._M_check(__pos,
"basic_string::basic_string");
457 _M_construct(__start, __start + __str._M_limit(__pos, npos));
466 basic_string(
const basic_string& __str, size_type __pos,
468 : _M_dataplus(_M_local_data())
470 const _CharT* __start = __str._M_data()
471 + __str._M_check(__pos,
"basic_string::basic_string");
472 _M_construct(__start, __start + __str._M_limit(__pos, __n));
482 basic_string(
const basic_string& __str, size_type __pos,
483 size_type __n,
const _Alloc& __a)
484 : _M_dataplus(_M_local_data(), __a)
486 const _CharT* __start
487 = __str._M_data() + __str._M_check(__pos,
"string::string");
488 _M_construct(__start, __start + __str._M_limit(__pos, __n));
501 const _Alloc& __a = _Alloc())
502 : _M_dataplus(_M_local_data(), __a)
503 { _M_construct(__s, __s + __n); }
510 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 513 template<
typename = _RequireAllocator<_Alloc>>
515 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
516 : _M_dataplus(_M_local_data(), __a)
517 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
525 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 528 template<
typename = _RequireAllocator<_Alloc>>
530 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
531 : _M_dataplus(_M_local_data(), __a)
532 { _M_construct(__n, __c); }
534 #if __cplusplus >= 201103L 543 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
545 if (__str._M_is_local())
547 traits_type::copy(_M_local_buf, __str._M_local_buf,
548 _S_local_capacity + 1);
552 _M_data(__str._M_data());
553 _M_capacity(__str._M_allocated_capacity);
559 _M_length(__str.length());
560 __str._M_data(__str._M_local_data());
561 __str._M_set_length(0);
569 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
570 : _M_dataplus(_M_local_data(), __a)
571 { _M_construct(__l.begin(), __l.end()); }
573 basic_string(
const basic_string& __str,
const _Alloc& __a)
574 : _M_dataplus(_M_local_data(), __a)
575 { _M_construct(__str.begin(), __str.end()); }
578 noexcept(_Alloc_traits::_S_always_equal())
579 : _M_dataplus(_M_local_data(), __a)
581 if (__str._M_is_local())
583 traits_type::copy(_M_local_buf, __str._M_local_buf,
584 _S_local_capacity + 1);
585 _M_length(__str.length());
586 __str._M_set_length(0);
588 else if (_Alloc_traits::_S_always_equal()
589 || __str.get_allocator() == __a)
591 _M_data(__str._M_data());
592 _M_length(__str.length());
593 _M_capacity(__str._M_allocated_capacity);
594 __str._M_data(__str._M_local_buf);
595 __str._M_set_length(0);
598 _M_construct(__str.begin(), __str.end());
609 #if __cplusplus >= 201103L 610 template<
typename _InputIterator,
611 typename = std::_RequireInputIter<_InputIterator>>
613 template<
typename _InputIterator>
615 basic_string(_InputIterator __beg, _InputIterator __end,
616 const _Alloc& __a = _Alloc())
617 : _M_dataplus(_M_local_data(), __a)
618 { _M_construct(__beg, __end); }
620 #if __cplusplus > 201402L 628 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
629 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
630 const _Alloc& __a = _Alloc())
631 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
638 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
640 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
641 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
651 : basic_string(__svw._M_sv.
data(), __svw._M_sv.
size(), __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 > 201402L 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); }
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 > 201402L 1209 template<
typename _Tp>
1210 _If_sv<_Tp, basic_string&>
1212 {
return this->
append(__svt); }
1221 append(
const basic_string& __str)
1222 {
return _M_append(__str._M_data(), __str.size()); }
1238 append(
const basic_string& __str, size_type __pos, size_type __n = npos)
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 > 201402L 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);
1364 assign(
const basic_string& __str)
1366 this->_M_assign(__str);
1370 #if __cplusplus >= 201103L 1380 assign(basic_string&& __str)
1381 noexcept(_Alloc_traits::_S_nothrow_move())
1385 return *
this = std::move(__str);
1403 assign(
const basic_string& __str, size_type __pos, size_type __n = npos)
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 > 201402L 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());
1638 insert(size_type __pos1,
const basic_string& __str)
1639 {
return this->
replace(__pos1, size_type(0),
1640 __str._M_data(), __str.size()); }
1661 insert(size_type __pos1,
const basic_string& __str,
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 > 201402L 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);
1887 replace(size_type __pos, size_type __n,
const basic_string& __str)
1888 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1909 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
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,
2002 const basic_string& __str)
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 2179 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2180 initializer_list<_CharT> __l)
2181 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2184 #if __cplusplus > 201402L 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;
2287 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2297 c_str() const _GLIBCXX_NOEXCEPT
2298 {
return _M_data(); }
2309 data() const _GLIBCXX_NOEXCEPT
2310 {
return _M_data(); }
2312 #if __cplusplus > 201402L 2321 {
return _M_data(); }
2329 {
return _M_get_allocator(); }
2344 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2358 find(
const basic_string& __str, size_type __pos = 0) const
2360 {
return this->
find(__str.data(), __pos, __str.size()); }
2362 #if __cplusplus > 201402L 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;
2420 rfind(const basic_string& __str, size_type __pos = npos) const
2422 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2424 #if __cplusplus > 201402L 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;
2499 find_first_of(
const basic_string& __str, size_type __pos = 0) const
2501 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2503 #if __cplusplus > 201402L 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); }
2583 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 2585 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2587 #if __cplusplus > 201402L 2595 template<
typename _Tp>
2596 _If_sv<_Tp, size_type>
2597 find_last_of(
const _Tp& __svt, size_type __pos = npos)
const 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 2632 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2635 __glibcxx_requires_string(__s);
2636 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2652 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
2653 {
return this->
rfind(__c, __pos); }
2670 #if __cplusplus > 201402L 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 > 201402L 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); }
2850 compare(
const basic_string& __str)
const 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 > 201402L 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));
2943 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2969 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
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 typedef typename _CharT_alloc_type::reference reference;
3149 typedef typename _CharT_alloc_type::const_reference const_reference;
3150 typedef typename _CharT_alloc_type::pointer pointer;
3151 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3152 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3153 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3160 typedef iterator __const_iterator;
3179 size_type _M_length;
3180 size_type _M_capacity;
3181 _Atomic_word _M_refcount;
3184 struct _Rep : _Rep_base
3187 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3202 static const size_type _S_max_size;
3203 static const _CharT _S_terminal;
3207 static size_type _S_empty_rep_storage[];
3210 _S_empty_rep() _GLIBCXX_NOEXCEPT
3215 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3216 return *
reinterpret_cast<_Rep*
>(__p);
3220 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3222 #if defined(__GTHREADS) 3227 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3229 return this->_M_refcount < 0;
3234 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3236 #if defined(__GTHREADS) 3242 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3244 return this->_M_refcount > 0;
3249 _M_set_leaked() _GLIBCXX_NOEXCEPT
3250 { this->_M_refcount = -1; }
3253 _M_set_sharable() _GLIBCXX_NOEXCEPT
3254 { this->_M_refcount = 0; }
3257 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3259 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3260 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3263 this->_M_set_sharable();
3264 this->_M_length = __n;
3265 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3272 _M_refdata()
throw()
3273 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3276 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3278 return (!_M_is_leaked() && __alloc1 == __alloc2)
3279 ? _M_refcopy() : _M_clone(__alloc1);
3284 _S_create(size_type, size_type,
const _Alloc&);
3287 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3289 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3290 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3294 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3303 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3306 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3313 _M_destroy(
const _Alloc&)
throw();
3316 _M_refcopy()
throw()
3318 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3319 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3321 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3322 return _M_refdata();
3326 _M_clone(
const _Alloc&, size_type __res = 0);
3330 struct _Alloc_hider : _Alloc
3332 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3333 : _Alloc(__a), _M_p(__dat) { }
3343 static const size_type npos =
static_cast<size_type
>(-1);
3347 mutable _Alloc_hider _M_dataplus;
3350 _M_data() const _GLIBCXX_NOEXCEPT
3351 {
return _M_dataplus._M_p; }
3354 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3355 {
return (_M_dataplus._M_p = __p); }
3358 _M_rep()
const _GLIBCXX_NOEXCEPT
3359 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3364 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3365 {
return iterator(_M_data()); }
3368 _M_iend()
const _GLIBCXX_NOEXCEPT
3369 {
return iterator(_M_data() + this->
size()); }
3374 if (!_M_rep()->_M_is_leaked())
3379 _M_check(size_type __pos,
const char* __s)
const 3381 if (__pos > this->
size())
3382 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3383 "this->size() (which is %zu)"),
3384 __s, __pos, this->
size());
3389 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3392 __throw_length_error(__N(__s));
3397 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3399 const bool __testoff = __off < this->
size() - __pos;
3400 return __testoff ? __off : this->
size() - __pos;
3405 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3414 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3417 traits_type::assign(*__d, *__s);
3419 traits_type::copy(__d, __s, __n);
3423 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3426 traits_type::assign(*__d, *__s);
3428 traits_type::move(__d, __s, __n);
3432 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3435 traits_type::assign(*__d, __c);
3437 traits_type::assign(__d, __n, __c);
3442 template<
class _Iterator>
3444 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3446 for (; __k1 != __k2; ++__k1, (void)++__p)
3447 traits_type::assign(*__p, *__k1);
3451 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3452 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3455 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3457 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3460 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3461 { _M_copy(__p, __k1, __k2 - __k1); }
3464 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3466 { _M_copy(__p, __k1, __k2 - __k1); }
3469 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3471 const difference_type __d = difference_type(__n1 - __n2);
3473 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3474 return __gnu_cxx::__numeric_traits<int>::__max;
3475 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3476 return __gnu_cxx::__numeric_traits<int>::__min;
3482 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3488 _S_empty_rep() _GLIBCXX_NOEXCEPT
3489 {
return _Rep::_S_empty_rep(); }
3491 #if __cplusplus > 201402L 3493 typedef basic_string_view<_CharT, _Traits> __sv_type;
3495 template<
typename _Tp,
typename _Res>
3497 __and_<is_convertible<const _Tp&, __sv_type>,
3498 __not_<is_convertible<const _Tp*, const basic_string*>>,
3499 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3504 _S_to_string_view(__sv_type __svt) noexcept
3513 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3527 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3529 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3531 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3555 basic_string(
const basic_string& __str, size_type __pos,
3556 const _Alloc& __a = _Alloc());
3564 basic_string(
const basic_string& __str, size_type __pos,
3573 basic_string(
const basic_string& __str, size_type __pos,
3574 size_type __n,
const _Alloc& __a);
3586 const _Alloc& __a = _Alloc());
3592 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3599 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3601 #if __cplusplus >= 201103L 3610 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3613 : _M_dataplus(__str._M_dataplus)
3615 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3616 __str._M_data(_S_empty_rep()._M_refdata());
3618 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3636 template<
class _InputIterator>
3637 basic_string(_InputIterator __beg, _InputIterator __end,
3638 const _Alloc& __a = _Alloc());
3640 #if __cplusplus > 201402L 3648 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3649 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3650 const _Alloc& __a = _Alloc())
3658 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3660 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3661 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3671 :
basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { }
3686 {
return this->
assign(__str); }
3694 {
return this->
assign(__s); }
3710 #if __cplusplus >= 201103L 3734 this->
assign(__l.begin(), __l.size());
3739 #if __cplusplus > 201402L 3744 template<
typename _Tp>
3745 _If_sv<_Tp, basic_string&>
3747 {
return this->
assign(__svt); }
3753 operator __sv_type()
const noexcept
3754 {
return __sv_type(
data(),
size()); }
3766 return iterator(_M_data());
3775 {
return const_iterator(_M_data()); }
3785 return iterator(_M_data() + this->
size());
3794 {
return const_iterator(_M_data() + this->
size()); }
3803 {
return reverse_iterator(this->
end()); }
3810 const_reverse_iterator
3812 {
return const_reverse_iterator(this->
end()); }
3821 {
return reverse_iterator(this->
begin()); }
3828 const_reverse_iterator
3830 {
return const_reverse_iterator(this->
begin()); }
3832 #if __cplusplus >= 201103L 3839 {
return const_iterator(this->_M_data()); }
3847 {
return const_iterator(this->_M_data() + this->
size()); }
3854 const_reverse_iterator
3856 {
return const_reverse_iterator(this->
end()); }
3863 const_reverse_iterator
3865 {
return const_reverse_iterator(this->
begin()); }
3874 {
return _M_rep()->_M_length; }
3880 {
return _M_rep()->_M_length; }
3885 {
return _Rep::_S_max_size; }
3898 resize(size_type __n, _CharT __c);
3912 { this->
resize(__n, _CharT()); }
3914 #if __cplusplus >= 201103L 3919 #if __cpp_exceptions 3937 {
return _M_rep()->_M_capacity; }
3957 reserve(size_type __res_arg = 0);
3962 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3966 if (_M_rep()->_M_is_shared())
3969 _M_data(_S_empty_rep()._M_refdata());
3972 _M_rep()->_M_set_length_and_sharable(0);
3978 { _M_mutate(0, this->
size(), 0); }
3987 {
return this->
size() == 0; }
4003 __glibcxx_assert(__pos <=
size());
4004 return _M_data()[__pos];
4022 __glibcxx_assert(__pos <=
size());
4024 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4026 return _M_data()[__pos];
4042 if (__n >= this->
size())
4043 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4044 "(which is %zu) >= this->size() " 4047 return _M_data()[__n];
4065 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4066 "(which is %zu) >= this->size() " 4070 return _M_data()[__n];
4073 #if __cplusplus >= 201103L 4081 __glibcxx_assert(!
empty());
4092 __glibcxx_assert(!
empty());
4103 __glibcxx_assert(!
empty());
4114 __glibcxx_assert(!
empty());
4127 {
return this->
append(__str); }
4136 {
return this->
append(__s); }
4150 #if __cplusplus >= 201103L 4158 {
return this->
append(__l.begin(), __l.size()); }
4161 #if __cplusplus > 201402L 4167 template<
typename _Tp>
4168 _If_sv<_Tp, basic_string&>
4170 {
return this->
append(__svt); }
4179 append(
const basic_string& __str);
4195 append(
const basic_string& __str, size_type __pos, size_type __n = npos);
4204 append(
const _CharT* __s, size_type __n);
4214 __glibcxx_requires_string(__s);
4215 return this->
append(__s, traits_type::length(__s));
4227 append(size_type __n, _CharT __c);
4229 #if __cplusplus >= 201103L 4237 {
return this->
append(__l.begin(), __l.size()); }
4248 template<
class _InputIterator>
4250 append(_InputIterator __first, _InputIterator __last)
4251 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4253 #if __cplusplus > 201402L 4259 template<
typename _Tp>
4260 _If_sv<_Tp, basic_string&>
4263 __sv_type __sv = __svt;
4264 return this->
append(__sv.data(), __sv.size());
4275 template<
typename _Tp>
4276 _If_sv<_Tp, basic_string&>
4277 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4279 __sv_type __sv = __svt;
4280 return append(__sv.data()
4281 + __sv._M_check(__pos,
"basic_string::append"),
4282 __sv._M_limit(__pos, __n));
4293 const size_type __len = 1 + this->
size();
4294 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4296 traits_type::assign(_M_data()[this->
size()], __c);
4297 _M_rep()->_M_set_length_and_sharable(__len);
4306 assign(
const basic_string& __str);
4308 #if __cplusplus >= 201103L 4340 assign(
const basic_string& __str, size_type __pos, size_type __n = npos)
4341 {
return this->
assign(__str._M_data()
4342 + __str._M_check(__pos,
"basic_string::assign"),
4343 __str._M_limit(__pos, __n)); }
4356 assign(
const _CharT* __s, size_type __n);
4370 __glibcxx_requires_string(__s);
4371 return this->
assign(__s, traits_type::length(__s));
4385 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4395 template<
class _InputIterator>
4397 assign(_InputIterator __first, _InputIterator __last)
4398 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4400 #if __cplusplus >= 201103L 4408 {
return this->
assign(__l.begin(), __l.size()); }
4411 #if __cplusplus > 201402L 4417 template<
typename _Tp>
4418 _If_sv<_Tp, basic_string&>
4421 __sv_type __sv = __svt;
4422 return this->
assign(__sv.data(), __sv.size());
4432 template<
typename _Tp>
4433 _If_sv<_Tp, basic_string&>
4434 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4436 __sv_type __sv = __svt;
4437 return assign(__sv.data()
4438 + __sv._M_check(__pos,
"basic_string::assign"),
4439 __sv._M_limit(__pos, __n));
4457 insert(iterator __p, size_type __n, _CharT __c)
4458 { this->
replace(__p, __p, __n, __c); }
4472 template<
class _InputIterator>
4474 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4475 { this->
replace(__p, __p, __beg, __end); }
4477 #if __cplusplus >= 201103L 4487 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4488 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4505 insert(size_type __pos1,
const basic_string& __str)
4506 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4527 insert(size_type __pos1,
const basic_string& __str,
4528 size_type __pos2, size_type __n = npos)
4529 {
return this->
insert(__pos1, __str._M_data()
4530 + __str._M_check(__pos2,
"basic_string::insert"),
4531 __str._M_limit(__pos2, __n)); }
4550 insert(size_type __pos,
const _CharT* __s, size_type __n);
4570 __glibcxx_requires_string(__s);
4571 return this->
insert(__pos, __s, traits_type::length(__s));
4591 insert(size_type __pos, size_type __n, _CharT __c)
4592 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4593 size_type(0), __n, __c); }
4611 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4612 const size_type __pos = __p - _M_ibegin();
4613 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4614 _M_rep()->_M_set_leaked();
4615 return iterator(_M_data() + __pos);
4618 #if __cplusplus > 201402L 4625 template<
typename _Tp>
4626 _If_sv<_Tp, basic_string&>
4627 insert(size_type __pos,
const _Tp& __svt)
4629 __sv_type __sv = __svt;
4630 return this->
insert(__pos, __sv.data(), __sv.size());
4642 template<
typename _Tp>
4643 _If_sv<_Tp, basic_string&>
4644 insert(size_type __pos1,
const _Tp& __svt,
4645 size_type __pos2, size_type __n = npos)
4647 __sv_type __sv = __svt;
4648 return this->
replace(__pos1, size_type(0), __sv.data()
4649 + __sv._M_check(__pos2,
"basic_string::insert"),
4650 __sv._M_limit(__pos2, __n));
4670 erase(size_type __pos = 0, size_type __n = npos)
4672 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4673 _M_limit(__pos, __n), size_type(0));
4688 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4689 && __position < _M_iend());
4690 const size_type __pos = __position - _M_ibegin();
4691 _M_mutate(__pos, size_type(1), size_type(0));
4692 _M_rep()->_M_set_leaked();
4693 return iterator(_M_data() + __pos);
4706 erase(iterator __first, iterator __last);
4708 #if __cplusplus >= 201103L 4717 __glibcxx_assert(!
empty());
4740 replace(size_type __pos, size_type __n,
const basic_string& __str)
4741 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4762 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4763 size_type __pos2, size_type __n2 = npos)
4764 {
return this->
replace(__pos1, __n1, __str._M_data()
4765 + __str._M_check(__pos2,
"basic_string::replace"),
4766 __str._M_limit(__pos2, __n2)); }
4787 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4807 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4809 __glibcxx_requires_string(__s);
4810 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4831 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4832 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4833 _M_limit(__pos, __n1), __n2, __c); }
4849 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4850 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4868 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4870 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4871 && __i2 <= _M_iend());
4872 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4889 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4891 __glibcxx_requires_string(__s);
4892 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4910 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4912 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4913 && __i2 <= _M_iend());
4914 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4932 template<
class _InputIterator>
4935 _InputIterator __k1, _InputIterator __k2)
4937 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4938 && __i2 <= _M_iend());
4939 __glibcxx_requires_valid_range(__k1, __k2);
4940 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4941 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4947 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4949 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4950 && __i2 <= _M_iend());
4951 __glibcxx_requires_valid_range(__k1, __k2);
4952 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4957 replace(iterator __i1, iterator __i2,
4958 const _CharT* __k1,
const _CharT* __k2)
4960 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4961 && __i2 <= _M_iend());
4962 __glibcxx_requires_valid_range(__k1, __k2);
4963 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4968 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4970 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4971 && __i2 <= _M_iend());
4972 __glibcxx_requires_valid_range(__k1, __k2);
4973 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4974 __k1.base(), __k2 - __k1);
4978 replace(iterator __i1, iterator __i2,
4979 const_iterator __k1, const_iterator __k2)
4981 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4982 && __i2 <= _M_iend());
4983 __glibcxx_requires_valid_range(__k1, __k2);
4984 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4985 __k1.base(), __k2 - __k1);
4988 #if __cplusplus >= 201103L 5003 basic_string&
replace(iterator __i1, iterator __i2,
5005 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5008 #if __cplusplus > 201402L 5016 template<
typename _Tp>
5017 _If_sv<_Tp, basic_string&>
5018 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5020 __sv_type __sv = __svt;
5021 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5033 template<
typename _Tp>
5034 _If_sv<_Tp, basic_string&>
5035 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5036 size_type __pos2, size_type __n2 = npos)
5038 __sv_type __sv = __svt;
5039 return this->
replace(__pos1, __n1,
5040 __sv.data() + __sv._M_check(__pos2,
"basic_string::replace"),
5041 __sv._M_limit(__pos2, __n2));
5053 template<
typename _Tp>
5054 _If_sv<_Tp, basic_string&>
5055 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5057 __sv_type __sv = __svt;
5058 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5063 template<
class _Integer>
5065 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5066 _Integer __val, __true_type)
5067 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5069 template<
class _InputIterator>
5071 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5072 _InputIterator __k2, __false_type);
5075 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5079 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5084 template<
class _InIterator>
5086 _S_construct_aux(_InIterator __beg, _InIterator __end,
5087 const _Alloc& __a, __false_type)
5089 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5090 return _S_construct(__beg, __end, __a, _Tag());
5095 template<
class _Integer>
5097 _S_construct_aux(_Integer __beg, _Integer __end,
5098 const _Alloc& __a, __true_type)
5099 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5103 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5104 {
return _S_construct(__req, __c, __a); }
5106 template<
class _InIterator>
5108 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5110 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5111 return _S_construct_aux(__beg, __end, __a, _Integral());
5115 template<
class _InIterator>
5117 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5122 template<
class _FwdIterator>
5124 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5128 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5145 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5155 swap(basic_string& __s)
5167 {
return _M_data(); }
5179 {
return _M_data(); }
5181 #if __cplusplus > 201402L 5201 {
return _M_dataplus; }
5216 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5230 find(
const basic_string& __str, size_type __pos = 0) const
5232 {
return this->
find(__str.data(), __pos, __str.size()); }
5245 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5247 __glibcxx_requires_string(__s);
5248 return this->
find(__s, __pos, traits_type::length(__s));
5262 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5264 #if __cplusplus > 201402L 5271 template<
typename _Tp>
5272 _If_sv<_Tp, size_type>
5273 find(
const _Tp& __svt, size_type __pos = 0)
const 5276 __sv_type __sv = __svt;
5277 return this->
find(__sv.data(), __pos, __sv.size());
5292 rfind(
const basic_string& __str, size_type __pos = npos)
const 5294 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5309 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5323 rfind(
const _CharT* __s, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
5325 __glibcxx_requires_string(__s);
5326 return this->
rfind(__s, __pos, traits_type::length(__s));
5340 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5342 #if __cplusplus > 201402L 5349 template<
typename _Tp>
5350 _If_sv<_Tp, size_type>
5351 rfind(
const _Tp& __svt, size_type __pos = npos)
const 5354 __sv_type __sv = __svt;
5355 return this->
rfind(__sv.data(), __pos, __sv.size());
5373 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5388 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5405 __glibcxx_requires_string(__s);
5406 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5423 {
return this->
find(__c, __pos); }
5425 #if __cplusplus > 201402L 5433 template<
typename _Tp>
5434 _If_sv<_Tp, size_type>
5438 __sv_type __sv = __svt;
5439 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5457 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5472 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5489 __glibcxx_requires_string(__s);
5490 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5507 {
return this->
rfind(__c, __pos); }
5509 #if __cplusplus > 201402L 5517 template<
typename _Tp>
5518 _If_sv<_Tp, size_type>
5519 find_last_of(
const _Tp& __svt, size_type __pos = npos)
const 5522 __sv_type __sv = __svt;
5523 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5556 size_type __n)
const _GLIBCXX_NOEXCEPT;
5572 __glibcxx_requires_string(__s);
5590 #if __cplusplus > 201402L 5598 template<
typename _Tp>
5599 _If_sv<_Tp, size_type>
5603 __sv_type __sv = __svt;
5638 size_type __n)
const _GLIBCXX_NOEXCEPT;
5654 __glibcxx_requires_string(__s);
5672 #if __cplusplus > 201402L 5680 template<
typename _Tp>
5681 _If_sv<_Tp, size_type>
5685 __sv_type __sv = __svt;
5703 substr(size_type __pos = 0, size_type __n = npos)
const 5705 _M_check(__pos,
"basic_string::substr"), __n); }
5724 const size_type __size = this->
size();
5725 const size_type __osize = __str.size();
5726 const size_type __len =
std::min(__size, __osize);
5728 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5730 __r = _S_compare(__size, __osize);
5734 #if __cplusplus > 201402L 5740 template<
typename _Tp>
5742 compare(
const _Tp& __svt)
const 5745 __sv_type __sv = __svt;
5746 const size_type __size = this->
size();
5747 const size_type __osize = __sv.size();
5748 const size_type __len =
std::min(__size, __osize);
5750 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5752 __r = _S_compare(__size, __osize);
5764 template<
typename _Tp>
5766 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5769 __sv_type __sv = __svt;
5770 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5783 template<
typename _Tp>
5785 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5786 size_type __pos2, size_type __n2 = npos)
const 5789 __sv_type __sv = __svt;
5790 return __sv_type(*
this)
5791 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5815 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5841 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5842 size_type __pos2, size_type __n2 = npos)
const;
5859 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5883 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5910 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5911 size_type __n2)
const;
5913 #if __cplusplus > 201703L 5915 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5916 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5919 starts_with(_CharT __x)
const noexcept
5920 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5923 starts_with(
const _CharT* __x)
const noexcept
5924 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5927 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5928 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5931 ends_with(_CharT __x)
const noexcept
5932 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5935 ends_with(
const _CharT* __x)
const noexcept
5936 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5939 # ifdef _GLIBCXX_TM_TS_INTERNAL 5941 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5944 ::_txnal_cow_string_c_str(
const void *that);
5946 ::_txnal_cow_string_D1(
void *that);
5948 ::_txnal_cow_string_D1_commit(
void *that);
5951 #endif // !_GLIBCXX_USE_CXX11_ABI 5953 #if __cpp_deduction_guides >= 201606 5954 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5955 template<
typename _InputIterator,
typename _CharT
5956 =
typename iterator_traits<_InputIterator>::value_type,
5958 typename = _RequireInputIter<_InputIterator>,
5959 typename = _RequireAllocator<_Allocator>>
5960 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5965 template<
typename _CharT,
typename _Traits,
5967 typename = _RequireAllocator<_Allocator>>
5968 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5971 template<
typename _CharT,
typename _Traits,
5973 typename = _RequireAllocator<_Allocator>>
5977 const _Allocator& = _Allocator())
5979 _GLIBCXX_END_NAMESPACE_CXX11
5989 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5995 __str.append(__rhs);
6005 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6016 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6026 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6029 const _CharT* __rhs)
6032 __str.append(__rhs);
6042 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6047 typedef typename __string_type::size_type __size_type;
6048 __string_type __str(__lhs);
6049 __str.append(__size_type(1), __rhs);
6053 #if __cplusplus >= 201103L 6054 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6058 {
return std::move(__lhs.append(__rhs)); }
6060 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6064 {
return std::move(__rhs.insert(0, __lhs)); }
6066 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6071 const auto __size = __lhs.size() + __rhs.size();
6072 const bool __cond = (__size > __lhs.capacity()
6073 && __size <= __rhs.capacity());
6074 return __cond ? std::move(__rhs.insert(0, __lhs))
6075 : std::move(__lhs.append(__rhs));
6078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6082 {
return std::move(__rhs.insert(0, __lhs)); }
6084 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6088 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6090 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6093 const _CharT* __rhs)
6094 {
return std::move(__lhs.append(__rhs)); }
6096 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6100 {
return std::move(__lhs.append(1, __rhs)); }
6110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6115 {
return __lhs.compare(__rhs) == 0; }
6117 template<
typename _CharT>
6119 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6122 {
return (__lhs.
size() == __rhs.
size()
6132 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6134 operator==(
const _CharT* __lhs,
6136 {
return __rhs.compare(__lhs) == 0; }
6144 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6147 const _CharT* __rhs)
6148 {
return __lhs.compare(__rhs) == 0; }
6157 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6162 {
return !(__lhs == __rhs); }
6170 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6172 operator!=(
const _CharT* __lhs,
6174 {
return !(__lhs == __rhs); }
6182 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6185 const _CharT* __rhs)
6186 {
return !(__lhs == __rhs); }
6195 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6197 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6200 {
return __lhs.
compare(__rhs) < 0; }
6208 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6210 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6211 const _CharT* __rhs)
6212 {
return __lhs.
compare(__rhs) < 0; }
6220 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6222 operator<(
const _CharT* __lhs,
6224 {
return __rhs.compare(__lhs) > 0; }
6233 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6238 {
return __lhs.compare(__rhs) > 0; }
6246 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6249 const _CharT* __rhs)
6250 {
return __lhs.compare(__rhs) > 0; }
6258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6260 operator>(
const _CharT* __lhs,
6262 {
return __rhs.compare(__lhs) < 0; }
6271 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6273 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6276 {
return __lhs.
compare(__rhs) <= 0; }
6284 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6286 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6287 const _CharT* __rhs)
6288 {
return __lhs.
compare(__rhs) <= 0; }
6296 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6298 operator<=(
const _CharT* __lhs,
6300 {
return __rhs.compare(__lhs) >= 0; }
6309 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6314 {
return __lhs.compare(__rhs) >= 0; }
6322 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6325 const _CharT* __rhs)
6326 {
return __lhs.compare(__rhs) >= 0; }
6334 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6336 operator>=(
const _CharT* __lhs,
6338 {
return __rhs.compare(__lhs) <= 0; }
6347 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6351 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6352 { __lhs.swap(__rhs); }
6367 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6385 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6387 operator<<(basic_ostream<_CharT, _Traits>& __os,
6392 return __ostream_insert(__os, __str.
data(), __str.
size());
6408 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6425 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6431 #if __cplusplus >= 201103L 6433 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6440 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6452 #ifdef _GLIBCXX_USE_WCHAR_T 6459 _GLIBCXX_END_NAMESPACE_VERSION
6462 #if __cplusplus >= 201103L 6466 namespace std _GLIBCXX_VISIBILITY(default)
6468 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6469 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6471 #if _GLIBCXX_USE_C99_STDLIB 6474 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6475 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6479 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6480 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6483 inline unsigned long 6484 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6485 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6489 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6490 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6493 inline unsigned long long 6494 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6495 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6500 stof(
const string& __str,
size_t* __idx = 0)
6501 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6504 stod(
const string& __str,
size_t* __idx = 0)
6505 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6508 stold(
const string& __str,
size_t* __idx = 0)
6509 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6510 #endif // _GLIBCXX_USE_C99_STDLIB 6512 #if _GLIBCXX_USE_C99_STDIO 6517 to_string(
int __val)
6518 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6522 to_string(
unsigned __val)
6523 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6524 4 *
sizeof(unsigned),
6528 to_string(
long __val)
6529 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6533 to_string(
unsigned long __val)
6534 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6535 4 *
sizeof(
unsigned long),
6539 to_string(
long long __val)
6540 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6541 4 *
sizeof(
long long),
6545 to_string(
unsigned long long __val)
6546 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6547 4 *
sizeof(
unsigned long long),
6551 to_string(
float __val)
6554 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6555 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6560 to_string(
double __val)
6563 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6564 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6569 to_string(
long double __val)
6572 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6573 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6576 #endif // _GLIBCXX_USE_C99_STDIO 6578 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6580 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6581 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6585 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6586 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6589 inline unsigned long 6590 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6591 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6595 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6596 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6599 inline unsigned long long 6600 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6601 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6606 stof(
const wstring& __str,
size_t* __idx = 0)
6607 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6610 stod(
const wstring& __str,
size_t* __idx = 0)
6611 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6614 stold(
const wstring& __str,
size_t* __idx = 0)
6615 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6617 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6620 to_wstring(
int __val)
6621 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6625 to_wstring(
unsigned __val)
6626 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6627 4 *
sizeof(unsigned),
6631 to_wstring(
long __val)
6632 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6636 to_wstring(
unsigned long __val)
6637 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6638 4 *
sizeof(
unsigned long),
6642 to_wstring(
long long __val)
6643 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6644 4 *
sizeof(
long long),
6648 to_wstring(
unsigned long long __val)
6649 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6650 4 *
sizeof(
unsigned long long),
6654 to_wstring(
float __val)
6657 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6658 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6663 to_wstring(
double __val)
6666 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6667 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6672 to_wstring(
long double __val)
6675 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6676 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6679 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6680 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6682 _GLIBCXX_END_NAMESPACE_CXX11
6683 _GLIBCXX_END_NAMESPACE_VERSION
6688 #if __cplusplus >= 201103L 6692 namespace std _GLIBCXX_VISIBILITY(default)
6694 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6698 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6702 :
public __hash_base<size_t, string>
6705 operator()(
const string& __s)
const noexcept
6706 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6713 #ifdef _GLIBCXX_USE_WCHAR_T 6717 :
public __hash_base<size_t, wstring>
6720 operator()(
const wstring& __s)
const noexcept
6721 {
return std::_Hash_impl::hash(__s.
data(),
6722 __s.
length() *
sizeof(wchar_t)); }
6734 :
public __hash_base<size_t, u16string>
6737 operator()(
const u16string& __s)
const noexcept
6738 {
return std::_Hash_impl::hash(__s.
data(),
6739 __s.
length() *
sizeof(char16_t)); }
6749 :
public __hash_base<size_t, u32string>
6752 operator()(
const u32string& __s)
const noexcept
6753 {
return std::_Hash_impl::hash(__s.
data(),
6754 __s.
length() *
sizeof(char32_t)); }
6761 #if __cplusplus > 201103L 6763 #define __cpp_lib_string_udls 201304 6765 inline namespace literals
6767 inline namespace string_literals
6769 #pragma GCC diagnostic push 6770 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6771 _GLIBCXX_DEFAULT_ABI_TAG
6773 operator""s(
const char* __str,
size_t __len)
6776 #ifdef _GLIBCXX_USE_WCHAR_T 6777 _GLIBCXX_DEFAULT_ABI_TAG
6779 operator""s(
const wchar_t* __str,
size_t __len)
6783 _GLIBCXX_DEFAULT_ABI_TAG
6785 operator""s(
const char16_t* __str,
size_t __len)
6788 _GLIBCXX_DEFAULT_ABI_TAG
6790 operator""s(
const char32_t* __str,
size_t __len)
6793 #pragma GCC diagnostic pop 6797 #endif // __cplusplus > 201103L 6799 _GLIBCXX_END_NAMESPACE_VERSION
const_reference back() const noexcept
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
const_iterator cend() const noexcept
Forward iterators support a superset of input iterator operations.
Template class basic_istream.
const_reverse_iterator crbegin() const noexcept
void pop_back()
Remove the last character.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
const_iterator cbegin() const noexcept
basic_string & operator+=(const _CharT *__s)
Append a C string.
size_type capacity() const noexcept
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
char_type widen(char __c) const
Widens characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
Uniform interface to all allocator types.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
Primary class template hash.
bool empty() const noexcept
Basis for explicit traits specializations.
ISO C++ entities toplevel namespace is std.
const_reverse_iterator rbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
One of the comparison functors.
The standard allocator, as per [20.4].
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
Managing sequences of characters and character-like objects.
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another 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.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
static const size_type npos
Value returned by various member functions when they fail.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
reverse_iterator rbegin()
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Template class basic_ostream.
iterator erase(iterator __position)
Remove one character.
int compare(const basic_string &__str) const
Compare to a string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
const_reverse_iterator crend() const noexcept
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
~basic_string() noexcept
Destroy the string instance.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & append(const _CharT *__s)
Append a C string.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Uniform interface to C++98 and C++11 allocators.
const_iterator begin() const noexcept
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 find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
_GLIBCXX20_CONSTEXPR complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
_Iterator __base(_Iterator __it)
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
const_reverse_iterator rend() const noexcept
const_reference front() const noexcept
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
const _CharT * data() const noexcept
Return const pointer to contents.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
basic_string & operator+=(_CharT __c)
Append a character.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
reference at(size_type __n)
Provides access to the data contained in the string.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
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.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
Uniform interface to all pointer-like types.
void push_back(_CharT __c)
Append a single character.