34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
48 # include <string_view>
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);
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())
641 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
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 return this->
assign(__str);
676 {
return this->
assign(__s); }
692 #if __cplusplus >= 201103L
704 noexcept(_Alloc_traits::_S_nothrow_move())
706 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
707 && !_Alloc_traits::_S_always_equal()
708 && _M_get_allocator() != __str._M_get_allocator())
711 _M_destroy(_M_allocated_capacity);
712 _M_data(_M_local_data());
716 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
718 if (__str._M_is_local())
722 this->_S_copy(_M_data(), __str._M_data(), __str.size());
723 _M_set_length(__str.size());
725 else if (_Alloc_traits::_S_propagate_on_move_assign()
726 || _Alloc_traits::_S_always_equal()
727 || _M_get_allocator() == __str._M_get_allocator())
730 pointer __data =
nullptr;
731 size_type __capacity;
734 if (_Alloc_traits::_S_always_equal())
738 __capacity = _M_allocated_capacity;
741 _M_destroy(_M_allocated_capacity);
744 _M_data(__str._M_data());
745 _M_length(__str.length());
746 _M_capacity(__str._M_allocated_capacity);
749 __str._M_data(__data);
750 __str._M_capacity(__capacity);
753 __str._M_data(__str._M_local_buf);
768 this->
assign(__l.begin(), __l.size());
773 #if __cplusplus >= 201703L
778 template<
typename _Tp>
779 _If_sv<_Tp, basic_string&>
781 {
return this->
assign(__svt); }
788 {
return __sv_type(
data(),
size()); }
797 begin() _GLIBCXX_NOEXCEPT
798 {
return iterator(_M_data()); }
805 begin() const _GLIBCXX_NOEXCEPT
806 {
return const_iterator(_M_data()); }
813 end() _GLIBCXX_NOEXCEPT
814 {
return iterator(_M_data() + this->
size()); }
821 end() const _GLIBCXX_NOEXCEPT
822 {
return const_iterator(_M_data() + this->
size()); }
830 rbegin() _GLIBCXX_NOEXCEPT
831 {
return reverse_iterator(this->
end()); }
838 const_reverse_iterator
839 rbegin() const _GLIBCXX_NOEXCEPT
840 {
return const_reverse_iterator(this->
end()); }
848 rend() _GLIBCXX_NOEXCEPT
849 {
return reverse_iterator(this->
begin()); }
856 const_reverse_iterator
857 rend() const _GLIBCXX_NOEXCEPT
858 {
return const_reverse_iterator(this->
begin()); }
860 #if __cplusplus >= 201103L
867 {
return const_iterator(this->_M_data()); }
875 {
return const_iterator(this->_M_data() + this->
size()); }
882 const_reverse_iterator
884 {
return const_reverse_iterator(this->
end()); }
891 const_reverse_iterator
893 {
return const_reverse_iterator(this->
begin()); }
901 size() const _GLIBCXX_NOEXCEPT
902 {
return _M_string_length; }
907 length() const _GLIBCXX_NOEXCEPT
908 {
return _M_string_length; }
913 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
926 resize(size_type __n, _CharT __c);
940 { this->
resize(__n, _CharT()); }
942 #if __cplusplus >= 201103L
966 return _M_is_local() ? size_type(_S_local_capacity)
967 : _M_allocated_capacity;
988 reserve(size_type __res_arg = 0);
994 clear() _GLIBCXX_NOEXCEPT
995 { _M_set_length(0); }
1001 _GLIBCXX_NODISCARD
bool
1002 empty() const _GLIBCXX_NOEXCEPT
1003 {
return this->
size() == 0; }
1017 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1019 __glibcxx_assert(__pos <=
size());
1020 return _M_data()[__pos];
1038 __glibcxx_assert(__pos <=
size());
1040 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1041 return _M_data()[__pos];
1055 at(size_type __n)
const
1057 if (__n >= this->
size())
1058 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1059 "(which is %zu) >= this->size() "
1062 return _M_data()[__n];
1079 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1080 "(which is %zu) >= this->size() "
1083 return _M_data()[__n];
1086 #if __cplusplus >= 201103L
1094 __glibcxx_assert(!
empty());
1105 __glibcxx_assert(!
empty());
1116 __glibcxx_assert(!
empty());
1127 __glibcxx_assert(!
empty());
1140 {
return this->
append(__str); }
1149 {
return this->
append(__s); }
1163 #if __cplusplus >= 201103L
1171 {
return this->
append(__l.begin(), __l.size()); }
1174 #if __cplusplus >= 201703L
1180 template<
typename _Tp>
1181 _If_sv<_Tp, basic_string&>
1183 {
return this->
append(__svt); }
1193 {
return _M_append(__str._M_data(), __str.size()); }
1210 {
return _M_append(__str._M_data()
1211 + __str._M_check(__pos,
"basic_string::append"),
1212 __str._M_limit(__pos, __n)); }
1221 append(
const _CharT* __s, size_type __n)
1223 __glibcxx_requires_string_len(__s, __n);
1224 _M_check_length(size_type(0), __n,
"basic_string::append");
1225 return _M_append(__s, __n);
1234 append(
const _CharT* __s)
1236 __glibcxx_requires_string(__s);
1237 const size_type __n = traits_type::length(__s);
1238 _M_check_length(size_type(0), __n,
"basic_string::append");
1239 return _M_append(__s, __n);
1251 append(size_type __n, _CharT __c)
1252 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1254 #if __cplusplus >= 201103L
1261 append(initializer_list<_CharT> __l)
1262 {
return this->
append(__l.begin(), __l.size()); }
1273 #if __cplusplus >= 201103L
1274 template<
class _InputIterator,
1275 typename = std::_RequireInputIter<_InputIterator>>
1277 template<
class _InputIterator>
1280 append(_InputIterator __first, _InputIterator __last)
1283 #if __cplusplus >= 201703L
1289 template<
typename _Tp>
1290 _If_sv<_Tp, basic_string&>
1293 __sv_type __sv = __svt;
1294 return this->
append(__sv.data(), __sv.size());
1304 template<
typename _Tp>
1305 _If_sv<_Tp, basic_string&>
1306 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1308 __sv_type __sv = __svt;
1309 return _M_append(__sv.data()
1310 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1311 std::__sv_limit(__sv.size(), __pos, __n));
1322 const size_type __size = this->
size();
1324 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1325 traits_type::assign(this->_M_data()[__size], __c);
1326 this->_M_set_length(__size + 1);
1337 #if __cplusplus >= 201103L
1338 if (_Alloc_traits::_S_propagate_on_copy_assign())
1340 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1341 && _M_get_allocator() != __str._M_get_allocator())
1345 if (__str.size() <= _S_local_capacity)
1347 _M_destroy(_M_allocated_capacity);
1348 _M_data(_M_local_data());
1353 const auto __len = __str.size();
1354 auto __alloc = __str._M_get_allocator();
1356 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1357 _M_destroy(_M_allocated_capacity);
1360 _M_set_length(__len);
1363 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1366 this->_M_assign(__str);
1370 #if __cplusplus >= 201103L
1381 noexcept(_Alloc_traits::_S_nothrow_move())
1404 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1405 + __str._M_check(__pos,
"basic_string::assign"),
1406 __str._M_limit(__pos, __n)); }
1419 assign(
const _CharT* __s, size_type __n)
1421 __glibcxx_requires_string_len(__s, __n);
1422 return _M_replace(size_type(0), this->
size(), __s, __n);
1435 assign(
const _CharT* __s)
1437 __glibcxx_requires_string(__s);
1438 return _M_replace(size_type(0), this->
size(), __s,
1439 traits_type::length(__s));
1452 assign(size_type __n, _CharT __c)
1453 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1463 #if __cplusplus >= 201103L
1464 template<
class _InputIterator,
1465 typename = std::_RequireInputIter<_InputIterator>>
1467 template<
class _InputIterator>
1470 assign(_InputIterator __first, _InputIterator __last)
1473 #if __cplusplus >= 201103L
1480 assign(initializer_list<_CharT> __l)
1481 {
return this->
assign(__l.begin(), __l.size()); }
1484 #if __cplusplus >= 201703L
1490 template<
typename _Tp>
1491 _If_sv<_Tp, basic_string&>
1494 __sv_type __sv = __svt;
1495 return this->
assign(__sv.data(), __sv.size());
1505 template<
typename _Tp>
1506 _If_sv<_Tp, basic_string&>
1507 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1509 __sv_type __sv = __svt;
1510 return _M_replace(size_type(0), this->
size(),
1512 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1513 std::__sv_limit(__sv.size(), __pos, __n));
1517 #if __cplusplus >= 201103L
1534 insert(const_iterator __p, size_type __n, _CharT __c)
1536 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1537 const size_type __pos = __p -
begin();
1538 this->
replace(__p, __p, __n, __c);
1539 return iterator(this->_M_data() + __pos);
1556 insert(iterator __p, size_type __n, _CharT __c)
1557 { this->
replace(__p, __p, __n, __c); }
1560 #if __cplusplus >= 201103L
1575 template<
class _InputIterator,
1576 typename = std::_RequireInputIter<_InputIterator>>
1578 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1580 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1581 const size_type __pos = __p -
begin();
1582 this->
replace(__p, __p, __beg, __end);
1583 return iterator(this->_M_data() + __pos);
1598 template<
class _InputIterator>
1600 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1601 { this->
replace(__p, __p, __beg, __end); }
1604 #if __cplusplus >= 201103L
1612 insert(const_iterator __p, initializer_list<_CharT> __l)
1613 {
return this->
insert(__p, __l.begin(), __l.end()); }
1615 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1618 insert(iterator __p, initializer_list<_CharT> __l)
1620 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1621 this->
insert(__p -
begin(), __l.begin(), __l.size());
1640 {
return this->
replace(__pos1, size_type(0),
1641 __str._M_data(), __str.size()); }
1663 size_type __pos2, size_type __n =
npos)
1664 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1665 + __str._M_check(__pos2,
"basic_string::insert"),
1666 __str._M_limit(__pos2, __n)); }
1685 insert(size_type __pos,
const _CharT* __s, size_type __n)
1686 {
return this->
replace(__pos, size_type(0), __s, __n); }
1704 insert(size_type __pos,
const _CharT* __s)
1706 __glibcxx_requires_string(__s);
1707 return this->
replace(__pos, size_type(0), __s,
1708 traits_type::length(__s));
1728 insert(size_type __pos, size_type __n, _CharT __c)
1729 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1730 size_type(0), __n, __c); }
1746 insert(__const_iterator __p, _CharT __c)
1748 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1749 const size_type __pos = __p -
begin();
1750 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1751 return iterator(_M_data() + __pos);
1754 #if __cplusplus >= 201703L
1761 template<
typename _Tp>
1762 _If_sv<_Tp, basic_string&>
1763 insert(size_type __pos,
const _Tp& __svt)
1765 __sv_type __sv = __svt;
1766 return this->
insert(__pos, __sv.data(), __sv.size());
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),
1785 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1786 std::__sv_limit(__sv.size(), __pos2, __n));
1806 erase(size_type __pos = 0, size_type __n =
npos)
1808 _M_check(__pos,
"basic_string::erase");
1810 this->_M_set_length(__pos);
1812 this->_M_erase(__pos, _M_limit(__pos, __n));
1825 erase(__const_iterator __position)
1827 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1828 && __position <
end());
1829 const size_type __pos = __position -
begin();
1830 this->_M_erase(__pos, size_type(1));
1831 return iterator(_M_data() + __pos);
1844 erase(__const_iterator __first, __const_iterator __last)
1846 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1847 && __last <=
end());
1848 const size_type __pos = __first -
begin();
1849 if (__last ==
end())
1850 this->_M_set_length(__pos);
1852 this->_M_erase(__pos, __last - __first);
1853 return iterator(this->_M_data() + __pos);
1856 #if __cplusplus >= 201103L
1865 __glibcxx_assert(!
empty());
1866 _M_erase(
size() - 1, 1);
1889 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1911 size_type __pos2, size_type __n2 =
npos)
1912 {
return this->
replace(__pos1, __n1, __str._M_data()
1913 + __str._M_check(__pos2,
"basic_string::replace"),
1914 __str._M_limit(__pos2, __n2)); }
1935 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1938 __glibcxx_requires_string_len(__s, __n2);
1939 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1940 _M_limit(__pos, __n1), __s, __n2);
1960 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1962 __glibcxx_requires_string(__s);
1963 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1984 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1985 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1986 _M_limit(__pos, __n1), __n2, __c); }
2002 replace(__const_iterator __i1, __const_iterator __i2,
2004 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2022 replace(__const_iterator __i1, __const_iterator __i2,
2023 const _CharT* __s, size_type __n)
2025 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2027 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2044 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2046 __glibcxx_requires_string(__s);
2047 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2065 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2068 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2070 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2088 #if __cplusplus >= 201103L
2089 template<
class _InputIterator,
2090 typename = std::_RequireInputIter<_InputIterator>>
2092 replace(const_iterator __i1, const_iterator __i2,
2093 _InputIterator __k1, _InputIterator __k2)
2095 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2097 __glibcxx_requires_valid_range(__k1, __k2);
2098 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2099 std::__false_type());
2102 template<
class _InputIterator>
2103 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2104 typename __enable_if_not_native_iterator<_InputIterator>::__type
2108 replace(iterator __i1, iterator __i2,
2109 _InputIterator __k1, _InputIterator __k2)
2111 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2113 __glibcxx_requires_valid_range(__k1, __k2);
2114 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2115 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2122 replace(__const_iterator __i1, __const_iterator __i2,
2123 _CharT* __k1, _CharT* __k2)
2125 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2127 __glibcxx_requires_valid_range(__k1, __k2);
2133 replace(__const_iterator __i1, __const_iterator __i2,
2134 const _CharT* __k1,
const _CharT* __k2)
2136 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2138 __glibcxx_requires_valid_range(__k1, __k2);
2144 replace(__const_iterator __i1, __const_iterator __i2,
2145 iterator __k1, iterator __k2)
2147 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2149 __glibcxx_requires_valid_range(__k1, __k2);
2151 __k1.base(), __k2 - __k1);
2155 replace(__const_iterator __i1, __const_iterator __i2,
2156 const_iterator __k1, const_iterator __k2)
2158 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2160 __glibcxx_requires_valid_range(__k1, __k2);
2162 __k1.base(), __k2 - __k1);
2165 #if __cplusplus >= 201103L
2181 initializer_list<_CharT> __l)
2182 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2185 #if __cplusplus >= 201703L
2193 template<
typename _Tp>
2194 _If_sv<_Tp, basic_string&>
2195 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2197 __sv_type __sv = __svt;
2198 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2210 template<
typename _Tp>
2211 _If_sv<_Tp, basic_string&>
2212 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2213 size_type __pos2, size_type __n2 =
npos)
2215 __sv_type __sv = __svt;
2216 return this->
replace(__pos1, __n1,
2218 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2219 std::__sv_limit(__sv.size(), __pos2, __n2));
2231 template<
typename _Tp>
2232 _If_sv<_Tp, basic_string&>
2233 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2235 __sv_type __sv = __svt;
2236 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2241 template<
class _Integer>
2243 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2244 _Integer __n, _Integer __val, __true_type)
2245 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2247 template<
class _InputIterator>
2249 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2250 _InputIterator __k1, _InputIterator __k2,
2254 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2258 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2259 const size_type __len2);
2262 _M_append(
const _CharT* __s, size_type __n);
2279 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2299 c_str() const _GLIBCXX_NOEXCEPT
2300 {
return _M_data(); }
2311 data() const _GLIBCXX_NOEXCEPT
2312 {
return _M_data(); }
2314 #if __cplusplus >= 201703L
2323 {
return _M_data(); }
2331 {
return _M_get_allocator(); }
2346 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2362 {
return this->
find(__str.data(), __pos, __str.size()); }
2364 #if __cplusplus >= 201703L
2371 template<
typename _Tp>
2372 _If_sv<_Tp, size_type>
2373 find(
const _Tp& __svt, size_type __pos = 0) const
2374 noexcept(is_same<_Tp, __sv_type>::value)
2376 __sv_type __sv = __svt;
2377 return this->
find(__sv.data(), __pos, __sv.size());
2392 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2394 __glibcxx_requires_string(__s);
2395 return this->
find(__s, __pos, traits_type::length(__s));
2409 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2424 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2426 #if __cplusplus >= 201703L
2433 template<
typename _Tp>
2434 _If_sv<_Tp, size_type>
2435 rfind(
const _Tp& __svt, size_type __pos =
npos) const
2436 noexcept(is_same<_Tp, __sv_type>::value)
2438 __sv_type __sv = __svt;
2439 return this->
rfind(__sv.data(), __pos, __sv.size());
2456 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2470 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2472 __glibcxx_requires_string(__s);
2473 return this->
rfind(__s, __pos, traits_type::length(__s));
2487 rfind(_CharT __c, size_type __pos =
npos) const _GLIBCXX_NOEXCEPT;
2503 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2505 #if __cplusplus >= 201703L
2513 template<
typename _Tp>
2514 _If_sv<_Tp, size_type>
2516 noexcept(is_same<_Tp, __sv_type>::value)
2518 __sv_type __sv = __svt;
2519 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2536 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2553 __glibcxx_requires_string(__s);
2554 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2570 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2571 {
return this->
find(__c, __pos); }
2587 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2589 #if __cplusplus >= 201703L
2597 template<
typename _Tp>
2598 _If_sv<_Tp, size_type>
2600 noexcept(is_same<_Tp, __sv_type>::value)
2602 __sv_type __sv = __svt;
2603 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2620 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2637 __glibcxx_requires_string(__s);
2638 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2655 {
return this->
rfind(__c, __pos); }
2672 #if __cplusplus >= 201703L
2680 template<
typename _Tp>
2681 _If_sv<_Tp, size_type>
2683 noexcept(is_same<_Tp, __sv_type>::value)
2685 __sv_type __sv = __svt;
2704 size_type __n)
const _GLIBCXX_NOEXCEPT;
2720 __glibcxx_requires_string(__s);
2754 #if __cplusplus >= 201703L
2762 template<
typename _Tp>
2763 _If_sv<_Tp, size_type>
2765 noexcept(is_same<_Tp, __sv_type>::value)
2767 __sv_type __sv = __svt;
2786 size_type __n)
const _GLIBCXX_NOEXCEPT;
2802 __glibcxx_requires_string(__s);
2833 substr(size_type __pos = 0, size_type __n =
npos)
const
2835 _M_check(__pos,
"basic_string::substr"), __n); }
2854 const size_type __size = this->
size();
2855 const size_type __osize = __str.size();
2856 const size_type __len =
std::min(__size, __osize);
2858 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2860 __r = _S_compare(__size, __osize);
2864 #if __cplusplus >= 201703L
2870 template<
typename _Tp>
2872 compare(
const _Tp& __svt)
const
2873 noexcept(is_same<_Tp, __sv_type>::value)
2875 __sv_type __sv = __svt;
2876 const size_type __size = this->
size();
2877 const size_type __osize = __sv.size();
2878 const size_type __len =
std::min(__size, __osize);
2880 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2882 __r = _S_compare(__size, __osize);
2894 template<
typename _Tp>
2896 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2897 noexcept(is_same<_Tp, __sv_type>::value)
2899 __sv_type __sv = __svt;
2900 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2913 template<
typename _Tp>
2915 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2916 size_type __pos2, size_type __n2 = npos) const
2917 noexcept(is_same<_Tp, __sv_type>::value)
2919 __sv_type __sv = __svt;
2920 return __sv_type(*
this)
2921 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2972 size_type __pos2, size_type __n2 = npos)
const;
2989 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3013 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3040 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3041 size_type __n2)
const;
3043 #if __cplusplus > 201703L
3045 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3046 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3049 starts_with(_CharT __x)
const noexcept
3050 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3053 starts_with(
const _CharT* __x)
const noexcept
3054 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3057 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3058 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3061 ends_with(_CharT __x)
const noexcept
3062 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3065 ends_with(
const _CharT* __x)
const noexcept
3066 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3070 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3072 _GLIBCXX_END_NAMESPACE_CXX11
3073 #else // !_GLIBCXX_USE_CXX11_ABI
3138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3142 rebind<_CharT>::other _CharT_alloc_type;
3147 typedef _Traits traits_type;
3148 typedef typename _Traits::char_type value_type;
3149 typedef _Alloc allocator_type;
3150 typedef typename _CharT_alloc_type::size_type size_type;
3151 typedef typename _CharT_alloc_type::difference_type difference_type;
3152 #if __cplusplus < 201103L
3153 typedef typename _CharT_alloc_type::reference reference;
3154 typedef typename _CharT_alloc_type::const_reference const_reference;
3156 typedef value_type& reference;
3157 typedef const value_type& const_reference;
3159 typedef typename _CharT_alloc_traits::pointer pointer;
3160 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3161 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3162 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3169 typedef iterator __const_iterator;
3188 size_type _M_length;
3189 size_type _M_capacity;
3190 _Atomic_word _M_refcount;
3193 struct _Rep : _Rep_base
3197 rebind<char>::other _Raw_bytes_alloc;
3212 static const size_type _S_max_size;
3213 static const _CharT _S_terminal;
3217 static size_type _S_empty_rep_storage[];
3220 _S_empty_rep() _GLIBCXX_NOEXCEPT
3225 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3226 return *
reinterpret_cast<_Rep*
>(__p);
3230 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3232 #if defined(__GTHREADS)
3237 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3239 return this->_M_refcount < 0;
3244 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3246 #if defined(__GTHREADS)
3252 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3254 return this->_M_refcount > 0;
3259 _M_set_leaked() _GLIBCXX_NOEXCEPT
3260 { this->_M_refcount = -1; }
3263 _M_set_sharable() _GLIBCXX_NOEXCEPT
3264 { this->_M_refcount = 0; }
3267 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3269 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3270 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3273 this->_M_set_sharable();
3274 this->_M_length = __n;
3275 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3282 _M_refdata()
throw()
3283 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3286 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3288 return (!_M_is_leaked() && __alloc1 == __alloc2)
3289 ? _M_refcopy() : _M_clone(__alloc1);
3294 _S_create(size_type, size_type,
const _Alloc&);
3297 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3299 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3300 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3304 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3313 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3316 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3323 _M_destroy(
const _Alloc&)
throw();
3326 _M_refcopy()
throw()
3328 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3329 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3331 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3332 return _M_refdata();
3336 _M_clone(
const _Alloc&, size_type __res = 0);
3340 struct _Alloc_hider : _Alloc
3342 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3343 : _Alloc(__a), _M_p(__dat) { }
3353 static const size_type npos =
static_cast<size_type
>(-1);
3357 mutable _Alloc_hider _M_dataplus;
3360 _M_data() const _GLIBCXX_NOEXCEPT
3361 {
return _M_dataplus._M_p; }
3364 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3365 {
return (_M_dataplus._M_p = __p); }
3368 _M_rep() const _GLIBCXX_NOEXCEPT
3369 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3374 _M_ibegin() const _GLIBCXX_NOEXCEPT
3375 {
return iterator(_M_data()); }
3378 _M_iend() const _GLIBCXX_NOEXCEPT
3379 {
return iterator(_M_data() + this->
size()); }
3384 if (!_M_rep()->_M_is_leaked())
3389 _M_check(size_type __pos,
const char* __s)
const
3391 if (__pos > this->
size())
3392 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3393 "this->size() (which is %zu)"),
3394 __s, __pos, this->
size());
3399 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3402 __throw_length_error(__N(__s));
3407 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3409 const bool __testoff = __off < this->
size() - __pos;
3410 return __testoff ? __off : this->
size() - __pos;
3415 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3417 return (less<const _CharT*>()(__s, _M_data())
3418 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3424 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3427 traits_type::assign(*__d, *__s);
3429 traits_type::copy(__d, __s, __n);
3433 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3436 traits_type::assign(*__d, *__s);
3442 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3445 traits_type::assign(*__d, __c);
3447 traits_type::assign(__d, __n, __c);
3452 template<
class _Iterator>
3454 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3456 for (; __k1 != __k2; ++__k1, (void)++__p)
3457 traits_type::assign(*__p, *__k1);
3461 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3462 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3465 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3467 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3470 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3471 { _M_copy(__p, __k1, __k2 - __k1); }
3474 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3476 { _M_copy(__p, __k1, __k2 - __k1); }
3479 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3481 const difference_type __d = difference_type(__n1 - __n2);
3483 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3484 return __gnu_cxx::__numeric_traits<int>::__max;
3485 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3486 return __gnu_cxx::__numeric_traits<int>::__min;
3492 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3498 _S_empty_rep() _GLIBCXX_NOEXCEPT
3499 {
return _Rep::_S_empty_rep(); }
3501 #if __cplusplus >= 201703L
3503 typedef basic_string_view<_CharT, _Traits> __sv_type;
3505 template<
typename _Tp,
typename _Res>
3507 __and_<is_convertible<const _Tp&, __sv_type>,
3508 __not_<is_convertible<const _Tp*, const basic_string*>>,
3509 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3514 _S_to_string_view(__sv_type __svt)
noexcept
3523 explicit __sv_wrapper(__sv_type __sv)
noexcept : _M_sv(__sv) { }
3547 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3549 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3551 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3577 const _Alloc& __a = _Alloc());
3595 size_type __n,
const _Alloc& __a);
3607 const _Alloc& __a = _Alloc());
3614 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3617 template<
typename = _RequireAllocator<_Alloc>>
3619 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
3620 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3621 __s + npos, __a), __a)
3630 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3632 #if __cplusplus >= 201103L
3641 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3644 : _M_dataplus(
std::move(__str._M_dataplus))
3646 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3647 __str._M_data(_S_empty_rep()._M_refdata());
3649 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3661 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3665 : _M_dataplus(__str._M_data(), __a)
3667 if (__a == __str.get_allocator())
3669 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3670 __str._M_data(_S_empty_rep()._M_refdata());
3672 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3676 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3686 template<
class _InputIterator>
3687 basic_string(_InputIterator __beg, _InputIterator __end,
3688 const _Alloc& __a = _Alloc());
3690 #if __cplusplus >= 201703L
3698 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3699 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3700 const _Alloc& __a = _Alloc())
3701 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
3708 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3710 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3711 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3726 {
return this->
assign(__str); }
3734 {
return this->
assign(__s); }
3750 #if __cplusplus >= 201103L
3774 this->
assign(__l.begin(), __l.size());
3779 #if __cplusplus >= 201703L
3784 template<
typename _Tp>
3785 _If_sv<_Tp, basic_string&>
3787 {
return this->
assign(__svt); }
3793 operator __sv_type() const
noexcept
3794 {
return __sv_type(
data(),
size()); }
3806 return iterator(_M_data());
3815 {
return const_iterator(_M_data()); }
3825 return iterator(_M_data() + this->
size());
3834 {
return const_iterator(_M_data() + this->
size()); }
3850 const_reverse_iterator
3868 const_reverse_iterator
3872 #if __cplusplus >= 201103L
3879 {
return const_iterator(this->_M_data()); }
3887 {
return const_iterator(this->_M_data() + this->
size()); }
3894 const_reverse_iterator
3903 const_reverse_iterator
3914 {
return _M_rep()->_M_length; }
3920 {
return _M_rep()->_M_length; }
3925 {
return _Rep::_S_max_size; }
3938 resize(size_type __n, _CharT __c);
3952 { this->
resize(__n, _CharT()); }
3954 #if __cplusplus >= 201103L
3959 #if __cpp_exceptions
3977 {
return _M_rep()->_M_capacity; }
3997 reserve(size_type __res_arg = 0);
4002 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4006 if (_M_rep()->_M_is_shared())
4009 _M_data(_S_empty_rep()._M_refdata());
4012 _M_rep()->_M_set_length_and_sharable(0);
4018 { _M_mutate(0, this->
size(), 0); }
4025 _GLIBCXX_NODISCARD
bool
4027 {
return this->
size() == 0; }
4043 __glibcxx_assert(__pos <=
size());
4044 return _M_data()[__pos];
4062 __glibcxx_assert(__pos <=
size());
4064 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4066 return _M_data()[__pos];
4082 if (__n >= this->
size())
4083 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4084 "(which is %zu) >= this->size() "
4087 return _M_data()[__n];
4105 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4106 "(which is %zu) >= this->size() "
4110 return _M_data()[__n];
4113 #if __cplusplus >= 201103L
4121 __glibcxx_assert(!
empty());
4132 __glibcxx_assert(!
empty());
4143 __glibcxx_assert(!
empty());
4154 __glibcxx_assert(!
empty());
4167 {
return this->
append(__str); }
4176 {
return this->
append(__s); }
4190 #if __cplusplus >= 201103L
4198 {
return this->
append(__l.begin(), __l.size()); }
4201 #if __cplusplus >= 201703L
4207 template<
typename _Tp>
4208 _If_sv<_Tp, basic_string&>
4210 {
return this->
append(__svt); }
4244 append(
const _CharT* __s, size_type __n);
4254 __glibcxx_requires_string(__s);
4255 return this->
append(__s, traits_type::length(__s));
4267 append(size_type __n, _CharT __c);
4269 #if __cplusplus >= 201103L
4277 {
return this->
append(__l.begin(), __l.size()); }
4288 template<
class _InputIterator>
4290 append(_InputIterator __first, _InputIterator __last)
4291 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4293 #if __cplusplus >= 201703L
4299 template<
typename _Tp>
4300 _If_sv<_Tp, basic_string&>
4303 __sv_type __sv = __svt;
4304 return this->
append(__sv.data(), __sv.size());
4315 template<
typename _Tp>
4316 _If_sv<_Tp, basic_string&>
4317 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4319 __sv_type __sv = __svt;
4320 return append(__sv.data()
4321 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4322 std::__sv_limit(__sv.size(), __pos, __n));
4333 const size_type __len = 1 + this->
size();
4334 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4336 traits_type::assign(_M_data()[this->
size()], __c);
4337 _M_rep()->_M_set_length_and_sharable(__len);
4348 #if __cplusplus >= 201103L
4381 {
return this->
assign(__str._M_data()
4382 + __str._M_check(__pos,
"basic_string::assign"),
4383 __str._M_limit(__pos, __n)); }
4396 assign(
const _CharT* __s, size_type __n);
4410 __glibcxx_requires_string(__s);
4411 return this->
assign(__s, traits_type::length(__s));
4425 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4435 template<
class _InputIterator>
4437 assign(_InputIterator __first, _InputIterator __last)
4438 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4440 #if __cplusplus >= 201103L
4448 {
return this->
assign(__l.begin(), __l.size()); }
4451 #if __cplusplus >= 201703L
4457 template<
typename _Tp>
4458 _If_sv<_Tp, basic_string&>
4461 __sv_type __sv = __svt;
4462 return this->
assign(__sv.data(), __sv.size());
4472 template<
typename _Tp>
4473 _If_sv<_Tp, basic_string&>
4474 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4476 __sv_type __sv = __svt;
4477 return assign(__sv.data()
4478 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4479 std::__sv_limit(__sv.size(), __pos, __n));
4497 insert(iterator __p, size_type __n, _CharT __c)
4498 { this->
replace(__p, __p, __n, __c); }
4512 template<
class _InputIterator>
4514 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4515 { this->
replace(__p, __p, __beg, __end); }
4517 #if __cplusplus >= 201103L
4527 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4528 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4546 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4568 size_type __pos2, size_type __n = npos)
4569 {
return this->
insert(__pos1, __str._M_data()
4570 + __str._M_check(__pos2,
"basic_string::insert"),
4571 __str._M_limit(__pos2, __n)); }
4590 insert(size_type __pos,
const _CharT* __s, size_type __n);
4610 __glibcxx_requires_string(__s);
4611 return this->
insert(__pos, __s, traits_type::length(__s));
4631 insert(size_type __pos, size_type __n, _CharT __c)
4632 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4633 size_type(0), __n, __c); }
4651 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4652 const size_type __pos = __p - _M_ibegin();
4653 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4654 _M_rep()->_M_set_leaked();
4655 return iterator(_M_data() + __pos);
4658 #if __cplusplus >= 201703L
4665 template<
typename _Tp>
4666 _If_sv<_Tp, basic_string&>
4667 insert(size_type __pos,
const _Tp& __svt)
4669 __sv_type __sv = __svt;
4670 return this->
insert(__pos, __sv.data(), __sv.size());
4682 template<
typename _Tp>
4683 _If_sv<_Tp, basic_string&>
4684 insert(size_type __pos1,
const _Tp& __svt,
4685 size_type __pos2, size_type __n = npos)
4687 __sv_type __sv = __svt;
4688 return this->
replace(__pos1, size_type(0), __sv.data()
4689 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4690 std::__sv_limit(__sv.size(), __pos2, __n));
4710 erase(size_type __pos = 0, size_type __n = npos)
4712 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4713 _M_limit(__pos, __n), size_type(0));
4728 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4729 && __position < _M_iend());
4730 const size_type __pos = __position - _M_ibegin();
4731 _M_mutate(__pos, size_type(1), size_type(0));
4732 _M_rep()->_M_set_leaked();
4733 return iterator(_M_data() + __pos);
4748 #if __cplusplus >= 201103L
4757 __glibcxx_assert(!
empty());
4781 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4803 size_type __pos2, size_type __n2 = npos)
4804 {
return this->
replace(__pos1, __n1, __str._M_data()
4805 + __str._M_check(__pos2,
"basic_string::replace"),
4806 __str._M_limit(__pos2, __n2)); }
4827 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4847 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4849 __glibcxx_requires_string(__s);
4850 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4871 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4872 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4873 _M_limit(__pos, __n1), __n2, __c); }
4890 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4908 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4910 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4911 && __i2 <= _M_iend());
4912 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4929 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4931 __glibcxx_requires_string(__s);
4932 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4950 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4952 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4953 && __i2 <= _M_iend());
4954 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4972 template<
class _InputIterator>
4975 _InputIterator __k1, _InputIterator __k2)
4977 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4978 && __i2 <= _M_iend());
4979 __glibcxx_requires_valid_range(__k1, __k2);
4980 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4981 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4989 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4990 && __i2 <= _M_iend());
4991 __glibcxx_requires_valid_range(__k1, __k2);
4992 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4997 replace(iterator __i1, iterator __i2,
4998 const _CharT* __k1,
const _CharT* __k2)
5000 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5001 && __i2 <= _M_iend());
5002 __glibcxx_requires_valid_range(__k1, __k2);
5003 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5008 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5010 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5011 && __i2 <= _M_iend());
5012 __glibcxx_requires_valid_range(__k1, __k2);
5013 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5014 __k1.base(), __k2 - __k1);
5018 replace(iterator __i1, iterator __i2,
5019 const_iterator __k1, const_iterator __k2)
5021 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5022 && __i2 <= _M_iend());
5023 __glibcxx_requires_valid_range(__k1, __k2);
5024 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5025 __k1.base(), __k2 - __k1);
5028 #if __cplusplus >= 201103L
5045 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5048 #if __cplusplus >= 201703L
5056 template<
typename _Tp>
5057 _If_sv<_Tp, basic_string&>
5058 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5060 __sv_type __sv = __svt;
5061 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5073 template<
typename _Tp>
5074 _If_sv<_Tp, basic_string&>
5075 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5076 size_type __pos2, size_type __n2 = npos)
5078 __sv_type __sv = __svt;
5079 return this->
replace(__pos1, __n1,
5081 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5082 std::__sv_limit(__sv.size(), __pos2, __n2));
5094 template<
typename _Tp>
5095 _If_sv<_Tp, basic_string&>
5096 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5098 __sv_type __sv = __svt;
5099 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5104 template<
class _Integer>
5106 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5107 _Integer __val, __true_type)
5108 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5110 template<
class _InputIterator>
5112 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5113 _InputIterator __k2, __false_type);
5116 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5120 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5125 template<
class _InIterator>
5127 _S_construct_aux(_InIterator __beg, _InIterator __end,
5128 const _Alloc& __a, __false_type)
5130 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5131 return _S_construct(__beg, __end, __a, _Tag());
5136 template<
class _Integer>
5138 _S_construct_aux(_Integer __beg, _Integer __end,
5139 const _Alloc& __a, __true_type)
5140 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5144 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5145 {
return _S_construct(__req, __c, __a); }
5147 template<
class _InIterator>
5149 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5151 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5152 return _S_construct_aux(__beg, __end, __a, _Integral());
5156 template<
class _InIterator>
5158 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5159 input_iterator_tag);
5163 template<
class _FwdIterator>
5165 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5166 forward_iterator_tag);
5169 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5186 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5197 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5208 {
return _M_data(); }
5220 {
return _M_data(); }
5222 #if __cplusplus >= 201703L
5242 {
return _M_dataplus; }
5257 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5273 {
return this->
find(__str.data(), __pos, __str.size()); }
5286 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5288 __glibcxx_requires_string(__s);
5289 return this->
find(__s, __pos, traits_type::length(__s));
5303 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5305 #if __cplusplus >= 201703L
5312 template<
typename _Tp>
5313 _If_sv<_Tp, size_type>
5314 find(
const _Tp& __svt, size_type __pos = 0) const
5317 __sv_type __sv = __svt;
5318 return this->
find(__sv.data(), __pos, __sv.size());
5335 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5350 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5364 rfind(
const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
5366 __glibcxx_requires_string(__s);
5367 return this->
rfind(__s, __pos, traits_type::length(__s));
5381 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
5383 #if __cplusplus >= 201703L
5390 template<
typename _Tp>
5391 _If_sv<_Tp, size_type>
5392 rfind(
const _Tp& __svt, size_type __pos = npos) const
5395 __sv_type __sv = __svt;
5396 return this->
rfind(__sv.data(), __pos, __sv.size());
5414 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5429 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5446 __glibcxx_requires_string(__s);
5447 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5464 {
return this->
find(__c, __pos); }
5466 #if __cplusplus >= 201703L
5474 template<
typename _Tp>
5475 _If_sv<_Tp, size_type>
5479 __sv_type __sv = __svt;
5480 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5498 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5513 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5530 __glibcxx_requires_string(__s);
5531 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5548 {
return this->
rfind(__c, __pos); }
5550 #if __cplusplus >= 201703L
5558 template<
typename _Tp>
5559 _If_sv<_Tp, size_type>
5560 find_last_of(
const _Tp& __svt, size_type __pos = npos) const
5563 __sv_type __sv = __svt;
5564 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5597 size_type __n)
const _GLIBCXX_NOEXCEPT;
5613 __glibcxx_requires_string(__s);
5631 #if __cplusplus >= 201703L
5639 template<
typename _Tp>
5640 _If_sv<_Tp, size_type>
5644 __sv_type __sv = __svt;
5679 size_type __n)
const _GLIBCXX_NOEXCEPT;
5695 __glibcxx_requires_string(__s);
5713 #if __cplusplus >= 201703L
5721 template<
typename _Tp>
5722 _If_sv<_Tp, size_type>
5726 __sv_type __sv = __svt;
5744 substr(size_type __pos = 0, size_type __n = npos)
const
5746 _M_check(__pos,
"basic_string::substr"), __n); }
5765 const size_type __size = this->
size();
5766 const size_type __osize = __str.size();
5767 const size_type __len =
std::min(__size, __osize);
5769 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5771 __r = _S_compare(__size, __osize);
5775 #if __cplusplus >= 201703L
5781 template<
typename _Tp>
5783 compare(
const _Tp& __svt)
const
5786 __sv_type __sv = __svt;
5787 const size_type __size = this->
size();
5788 const size_type __osize = __sv.size();
5789 const size_type __len =
std::min(__size, __osize);
5791 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5793 __r = _S_compare(__size, __osize);
5805 template<
typename _Tp>
5807 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5808 noexcept(is_same<_Tp, __sv_type>::value)
5810 __sv_type __sv = __svt;
5811 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5824 template<
typename _Tp>
5826 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5827 size_type __pos2, size_type __n2 = npos) const
5828 noexcept(is_same<_Tp, __sv_type>::value)
5830 __sv_type __sv = __svt;
5831 return __sv_type(*
this)
5832 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5883 size_type __pos2, size_type __n2 = npos)
const;
5900 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5924 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5951 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5952 size_type __n2)
const;
5954 #if __cplusplus > 201703L
5956 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5957 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5960 starts_with(_CharT __x)
const noexcept
5961 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5964 starts_with(
const _CharT* __x)
const noexcept
5965 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5968 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5969 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5972 ends_with(_CharT __x)
const noexcept
5973 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5976 ends_with(
const _CharT* __x)
const noexcept
5977 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5980 # ifdef _GLIBCXX_TM_TS_INTERNAL
5982 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5985 ::_txnal_cow_string_c_str(
const void *that);
5987 ::_txnal_cow_string_D1(
void *that);
5989 ::_txnal_cow_string_D1_commit(
void *that);
5992 #endif // !_GLIBCXX_USE_CXX11_ABI
5994 #if __cpp_deduction_guides >= 201606
5995 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5996 template<
typename _InputIterator,
typename _CharT
5997 =
typename iterator_traits<_InputIterator>::value_type,
5998 typename _Allocator = allocator<_CharT>,
5999 typename = _RequireInputIter<_InputIterator>,
6000 typename = _RequireAllocator<_Allocator>>
6001 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6002 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6006 template<
typename _CharT,
typename _Traits,
6007 typename _Allocator = allocator<_CharT>,
6008 typename = _RequireAllocator<_Allocator>>
6009 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6010 -> basic_string<_CharT, _Traits, _Allocator>;
6012 template<
typename _CharT,
typename _Traits,
6013 typename _Allocator = allocator<_CharT>,
6014 typename = _RequireAllocator<_Allocator>>
6016 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6017 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6018 const _Allocator& = _Allocator())
6019 -> basic_string<_CharT, _Traits, _Allocator>;
6020 _GLIBCXX_END_NAMESPACE_CXX11
6030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6031 basic_string<_CharT, _Traits, _Alloc>
6036 __str.append(__rhs);
6046 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6047 basic_string<_CharT,_Traits,_Alloc>
6049 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6057 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6058 basic_string<_CharT,_Traits,_Alloc>
6059 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6068 inline basic_string<_CharT, _Traits, _Alloc>
6070 const _CharT* __rhs)
6073 __str.append(__rhs);
6083 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6084 inline basic_string<_CharT, _Traits, _Alloc>
6088 typedef typename __string_type::size_type __size_type;
6089 __string_type __str(__lhs);
6090 __str.append(__size_type(1), __rhs);
6094 #if __cplusplus >= 201103L
6095 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6096 inline basic_string<_CharT, _Traits, _Alloc>
6097 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6098 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6099 {
return std::move(__lhs.append(__rhs)); }
6101 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6102 inline basic_string<_CharT, _Traits, _Alloc>
6103 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6104 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6105 {
return std::move(__rhs.insert(0, __lhs)); }
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 inline basic_string<_CharT, _Traits, _Alloc>
6109 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6110 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6112 #if _GLIBCXX_USE_CXX11_ABI
6113 using _Alloc_traits = allocator_traits<_Alloc>;
6114 bool __use_rhs =
false;
6115 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6117 else if (__lhs.get_allocator() == __rhs.get_allocator())
6122 const auto __size = __lhs.size() + __rhs.size();
6123 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6124 return std::move(__rhs.insert(0, __lhs));
6129 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6130 inline basic_string<_CharT, _Traits, _Alloc>
6132 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6133 {
return std::move(__rhs.insert(0, __lhs)); }
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6136 inline basic_string<_CharT, _Traits, _Alloc>
6138 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6139 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6141 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6142 inline basic_string<_CharT, _Traits, _Alloc>
6143 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6144 const _CharT* __rhs)
6145 {
return std::move(__lhs.append(__rhs)); }
6147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6148 inline basic_string<_CharT, _Traits, _Alloc>
6149 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6151 {
return std::move(__lhs.append(1, __rhs)); }
6161 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6166 {
return __lhs.compare(__rhs) == 0; }
6168 template<
typename _CharT>
6170 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6171 operator==(
const basic_string<_CharT>& __lhs,
6172 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6173 {
return (__lhs.size() == __rhs.size()
6183 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6186 const _CharT* __rhs)
6187 {
return __lhs.compare(__rhs) == 0; }
6189 #if __cpp_lib_three_way_comparison
6197 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6199 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6200 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
noexcept
6201 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6202 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6213 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6215 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6216 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6224 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6226 operator==(
const _CharT* __lhs,
6228 {
return __rhs.compare(__lhs) == 0; }
6237 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6242 {
return !(__lhs == __rhs); }
6250 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6252 operator!=(
const _CharT* __lhs,
6254 {
return !(__lhs == __rhs); }
6262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6265 const _CharT* __rhs)
6266 {
return !(__lhs == __rhs); }
6275 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6277 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6280 {
return __lhs.
compare(__rhs) < 0; }
6288 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6290 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6291 const _CharT* __rhs)
6292 {
return __lhs.compare(__rhs) < 0; }
6300 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6302 operator<(
const _CharT* __lhs,
6304 {
return __rhs.compare(__lhs) > 0; }
6313 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6318 {
return __lhs.compare(__rhs) > 0; }
6326 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6329 const _CharT* __rhs)
6330 {
return __lhs.compare(__rhs) > 0; }
6338 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6340 operator>(
const _CharT* __lhs,
6342 {
return __rhs.compare(__lhs) < 0; }
6351 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6353 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6356 {
return __lhs.
compare(__rhs) <= 0; }
6364 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6366 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6367 const _CharT* __rhs)
6368 {
return __lhs.compare(__rhs) <= 0; }
6376 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6378 operator<=(
const _CharT* __lhs,
6380 {
return __rhs.compare(__lhs) >= 0; }
6389 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6394 {
return __lhs.compare(__rhs) >= 0; }
6402 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6405 const _CharT* __rhs)
6406 {
return __lhs.compare(__rhs) >= 0; }
6414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6416 operator>=(
const _CharT* __lhs,
6418 {
return __rhs.compare(__lhs) <= 0; }
6419 #endif // three-way comparison
6428 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6432 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
6433 { __lhs.swap(__rhs); }
6448 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6449 basic_istream<_CharT, _Traits>&
6450 operator>>(basic_istream<_CharT, _Traits>& __is,
6451 basic_string<_CharT, _Traits, _Alloc>& __str);
6454 basic_istream<char>&
6455 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6466 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6467 inline basic_ostream<_CharT, _Traits>&
6468 operator<<(basic_ostream<_CharT, _Traits>& __os,
6473 return __ostream_insert(__os, __str.data(), __str.size());
6489 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6490 basic_istream<_CharT, _Traits>&
6491 getline(basic_istream<_CharT, _Traits>& __is,
6492 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6506 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6507 inline basic_istream<_CharT, _Traits>&
6512 #if __cplusplus >= 201103L
6514 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6515 inline basic_istream<_CharT, _Traits>&
6521 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6522 inline basic_istream<_CharT, _Traits>&
6529 basic_istream<char>&
6530 getline(basic_istream<char>& __in, basic_string<char>& __str,
6533 #ifdef _GLIBCXX_USE_WCHAR_T
6535 basic_istream<wchar_t>&
6536 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6540 _GLIBCXX_END_NAMESPACE_VERSION
6543 #if __cplusplus >= 201103L
6548 namespace std _GLIBCXX_VISIBILITY(default)
6550 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6551 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6553 #if _GLIBCXX_USE_C99_STDLIB
6556 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6557 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6561 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6562 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6565 inline unsigned long
6566 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6567 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6571 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6572 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6575 inline unsigned long long
6576 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6577 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6582 stof(
const string& __str,
size_t* __idx = 0)
6583 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6586 stod(
const string& __str,
size_t* __idx = 0)
6587 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6590 stold(
const string& __str,
size_t* __idx = 0)
6591 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6592 #endif // _GLIBCXX_USE_C99_STDLIB
6597 to_string(
int __val)
6599 const bool __neg = __val < 0;
6600 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6601 const auto __len = __detail::__to_chars_len(__uval);
6602 string __str(__neg + __len,
'-');
6603 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6608 to_string(
unsigned __val)
6610 string __str(__detail::__to_chars_len(__val),
'\0');
6611 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6616 to_string(
long __val)
6618 const bool __neg = __val < 0;
6619 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6620 const auto __len = __detail::__to_chars_len(__uval);
6621 string __str(__neg + __len,
'-');
6622 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6627 to_string(
unsigned long __val)
6629 string __str(__detail::__to_chars_len(__val),
'\0');
6630 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6635 to_string(
long long __val)
6637 const bool __neg = __val < 0;
6638 const unsigned long long __uval
6639 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6640 const auto __len = __detail::__to_chars_len(__uval);
6641 string __str(__neg + __len,
'-');
6642 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6647 to_string(
unsigned long long __val)
6649 string __str(__detail::__to_chars_len(__val),
'\0');
6650 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6654 #if _GLIBCXX_USE_C99_STDIO
6658 to_string(
float __val)
6661 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6662 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6667 to_string(
double __val)
6670 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6671 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6676 to_string(
long double __val)
6679 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6680 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6683 #endif // _GLIBCXX_USE_C99_STDIO
6685 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6687 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6688 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6692 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6693 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6696 inline unsigned long
6697 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6698 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6702 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6703 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6706 inline unsigned long long
6707 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6708 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6713 stof(
const wstring& __str,
size_t* __idx = 0)
6714 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6717 stod(
const wstring& __str,
size_t* __idx = 0)
6718 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6721 stold(
const wstring& __str,
size_t* __idx = 0)
6722 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6724 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6727 to_wstring(
int __val)
6728 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6732 to_wstring(
unsigned __val)
6733 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6734 4 *
sizeof(unsigned),
6738 to_wstring(
long __val)
6739 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6743 to_wstring(
unsigned long __val)
6744 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6745 4 *
sizeof(
unsigned long),
6749 to_wstring(
long long __val)
6750 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6751 4 *
sizeof(
long long),
6755 to_wstring(
unsigned long long __val)
6756 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6757 4 *
sizeof(
unsigned long long),
6761 to_wstring(
float __val)
6764 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6765 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6770 to_wstring(
double __val)
6773 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6774 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6779 to_wstring(
long double __val)
6782 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6783 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6786 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6787 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
6789 _GLIBCXX_END_NAMESPACE_CXX11
6790 _GLIBCXX_END_NAMESPACE_VERSION
6795 #if __cplusplus >= 201103L
6799 namespace std _GLIBCXX_VISIBILITY(default)
6801 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6805 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6809 :
public __hash_base<size_t, string>
6812 operator()(
const string& __s)
const noexcept
6813 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6820 #ifdef _GLIBCXX_USE_WCHAR_T
6824 :
public __hash_base<size_t, wstring>
6827 operator()(
const wstring& __s)
const noexcept
6828 {
return std::_Hash_impl::hash(__s.
data(),
6829 __s.
length() *
sizeof(wchar_t)); }
6838 #ifdef _GLIBCXX_USE_CHAR8_T
6841 struct hash<u8string>
6842 :
public __hash_base<size_t, u8string>
6845 operator()(
const u8string& __s)
const noexcept
6846 {
return std::_Hash_impl::hash(__s.data(),
6847 __s.length() *
sizeof(char8_t)); }
6858 :
public __hash_base<size_t, u16string>
6861 operator()(
const u16string& __s)
const noexcept
6862 {
return std::_Hash_impl::hash(__s.
data(),
6863 __s.
length() *
sizeof(char16_t)); }
6873 :
public __hash_base<size_t, u32string>
6876 operator()(
const u32string& __s)
const noexcept
6877 {
return std::_Hash_impl::hash(__s.
data(),
6878 __s.
length() *
sizeof(char32_t)); }
6885 #if __cplusplus >= 201402L
6887 #define __cpp_lib_string_udls 201304
6889 inline namespace literals
6891 inline namespace string_literals
6893 #pragma GCC diagnostic push
6894 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6895 _GLIBCXX_DEFAULT_ABI_TAG
6896 inline basic_string<char>
6897 operator""s(
const char* __str,
size_t __len)
6898 {
return basic_string<char>{__str, __len}; }
6900 #ifdef _GLIBCXX_USE_WCHAR_T
6901 _GLIBCXX_DEFAULT_ABI_TAG
6902 inline basic_string<wchar_t>
6903 operator""s(
const wchar_t* __str,
size_t __len)
6904 {
return basic_string<wchar_t>{__str, __len}; }
6907 #ifdef _GLIBCXX_USE_CHAR8_T
6908 _GLIBCXX_DEFAULT_ABI_TAG
6909 inline basic_string<char8_t>
6910 operator""s(
const char8_t* __str,
size_t __len)
6911 {
return basic_string<char8_t>{__str, __len}; }
6914 _GLIBCXX_DEFAULT_ABI_TAG
6915 inline basic_string<char16_t>
6916 operator""s(
const char16_t* __str,
size_t __len)
6917 {
return basic_string<char16_t>{__str, __len}; }
6919 _GLIBCXX_DEFAULT_ABI_TAG
6920 inline basic_string<char32_t>
6921 operator""s(
const char32_t* __str,
size_t __len)
6922 {
return basic_string<char32_t>{__str, __len}; }
6924 #pragma GCC diagnostic pop
6928 #if __cplusplus >= 201703L
6929 namespace __detail::__variant
6931 template<
typename>
struct _Never_valueless_alt;
6935 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6936 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
6938 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6939 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6946 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
Basis for explicit traits specializations.
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_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
~basic_string() noexcept
Destroy the string instance.
iterator erase(iterator __position)
Remove one character.
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_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.
const _CharT * data() const noexcept
Return const pointer to contents.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
reference at(size_type __n)
Provides access to the data contained in the string.
void push_back(_CharT __c)
Append a single character.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type capacity() const noexcept
const_iterator begin() const noexcept
Uniform interface to C++98 and C++11 allocators.
Managing sequences of characters and character-like objects.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
Template class basic_istream.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C 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.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_iterator cbegin() const noexcept
const_reverse_iterator rend() const noexcept
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(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
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(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
char_type widen(char __c) const
Widens characters.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
const_reference back() const noexcept
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
Uniform interface to all pointer-like types.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & append(const _CharT *__s)
Append a C string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
const_iterator cend() const noexcept
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
void pop_back()
Remove the last character.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
Uniform interface to all allocator types.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
const_reference front() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
const_reverse_iterator crend() const noexcept
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
static const size_type npos
Value returned by various member functions when they fail.
constexpr _Iterator __base(_Iterator __it)
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(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
const_reverse_iterator rbegin() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
Primary class template hash.
void noexcept()
Swap contents with another 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, _CharT __c)
Resizes the string to the specified number of characters.
basic_string< wchar_t > wstring
A string of wchar_t.
const_iterator end() const noexcept
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
int compare(const basic_string &__str) const
Compare to a string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
const_reverse_iterator crbegin() const noexcept
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
reverse_iterator rbegin()
bool empty() const noexcept
Forward iterators support a superset of input iterator operations.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.