34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
51 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 #if __cplusplus >= 201703L
57 # define __cpp_lib_constexpr_string 201611L
60 #if _GLIBCXX_USE_CXX11_ABI
61 _GLIBCXX_BEGIN_NAMESPACE_CXX11
80 template<
typename _CharT,
typename _Traits,
typename _Alloc>
84 rebind<_CharT>::other _Char_alloc_type;
89 typedef _Traits traits_type;
90 typedef typename _Traits::char_type value_type;
91 typedef _Char_alloc_type allocator_type;
92 typedef typename _Alloc_traits::size_type size_type;
93 typedef typename _Alloc_traits::difference_type difference_type;
94 typedef typename _Alloc_traits::reference reference;
95 typedef typename _Alloc_traits::const_reference const_reference;
96 typedef typename _Alloc_traits::pointer pointer;
97 typedef typename _Alloc_traits::const_pointer const_pointer;
98 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
99 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
105 static const size_type
npos =
static_cast<size_type
>(-1);
109 #if __cplusplus < 201103L
110 typedef iterator __const_iterator;
112 typedef const_iterator __const_iterator;
116 #if __cplusplus >= 201703L
118 typedef basic_string_view<_CharT, _Traits> __sv_type;
120 template<
typename _Tp,
typename _Res>
122 __and_<is_convertible<const _Tp&, __sv_type>,
123 __not_<is_convertible<const _Tp*, const basic_string*>>,
124 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
129 _S_to_string_view(__sv_type __svt) noexcept
138 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
154 struct _Alloc_hider : allocator_type
156 #if __cplusplus < 201103L
157 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
158 : allocator_type(__a), _M_p(__dat) { }
160 _Alloc_hider(pointer __dat,
const _Alloc& __a)
161 : allocator_type(__a), _M_p(__dat) { }
163 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
164 : allocator_type(
std::move(__a)), _M_p(__dat) { }
170 _Alloc_hider _M_dataplus;
171 size_type _M_string_length;
173 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
177 _CharT _M_local_buf[_S_local_capacity + 1];
178 size_type _M_allocated_capacity;
183 { _M_dataplus._M_p = __p; }
186 _M_length(size_type __length)
187 { _M_string_length = __length; }
191 {
return _M_dataplus._M_p; }
196 #if __cplusplus >= 201103L
199 return pointer(_M_local_buf);
204 _M_local_data()
const
206 #if __cplusplus >= 201103L
209 return const_pointer(_M_local_buf);
214 _M_capacity(size_type __capacity)
215 { _M_allocated_capacity = __capacity; }
218 _M_set_length(size_type __n)
221 traits_type::assign(_M_data()[__n], _CharT());
226 {
return _M_data() == _M_local_data(); }
230 _M_create(size_type&, size_type);
236 _M_destroy(_M_allocated_capacity);
240 _M_destroy(size_type __size)
throw()
241 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
245 template<
typename _InIterator>
247 _M_construct_aux(_InIterator __beg, _InIterator __end,
250 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
251 _M_construct(__beg, __end, _Tag());
256 template<
typename _Integer>
258 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
259 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
262 _M_construct_aux_2(size_type __req, _CharT __c)
263 { _M_construct(__req, __c); }
265 template<
typename _InIterator>
267 _M_construct(_InIterator __beg, _InIterator __end)
269 typedef typename std::__is_integer<_InIterator>::__type _Integral;
270 _M_construct_aux(__beg, __end, _Integral());
274 template<
typename _InIterator>
276 _M_construct(_InIterator __beg, _InIterator __end,
281 template<
typename _FwdIterator>
283 _M_construct(_FwdIterator __beg, _FwdIterator __end,
287 _M_construct(size_type __req, _CharT __c);
291 {
return _M_dataplus; }
293 const allocator_type&
294 _M_get_allocator()
const
295 {
return _M_dataplus; }
299 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
302 template<
typename _Tp,
bool _Requires =
303 !__are_same<_Tp, _CharT*>::__value
304 && !__are_same<_Tp, const _CharT*>::__value
305 && !__are_same<_Tp, iterator>::__value
306 && !__are_same<_Tp, const_iterator>::__value>
307 struct __enable_if_not_native_iterator
309 template<
typename _Tp>
310 struct __enable_if_not_native_iterator<_Tp, false> { };
314 _M_check(size_type __pos,
const char* __s)
const
316 if (__pos > this->
size())
317 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
318 "this->size() (which is %zu)"),
319 __s, __pos, this->
size());
324 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
327 __throw_length_error(__N(__s));
333 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
335 const bool __testoff = __off < this->
size() - __pos;
336 return __testoff ? __off : this->
size() - __pos;
341 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
343 return (less<const _CharT*>()(__s, _M_data())
344 || less<const _CharT*>()(_M_data() + this->
size(), __s));
350 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
353 traits_type::assign(*__d, *__s);
355 traits_type::copy(__d, __s, __n);
359 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
362 traits_type::assign(*__d, *__s);
364 traits_type::move(__d, __s, __n);
368 _S_assign(_CharT* __d, size_type __n, _CharT __c)
371 traits_type::assign(*__d, __c);
373 traits_type::assign(__d, __n, __c);
378 template<
class _Iterator>
380 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
382 for (; __k1 != __k2; ++__k1, (void)++__p)
383 traits_type::assign(*__p, *__k1);
387 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
388 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
391 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
393 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
396 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
397 { _S_copy(__p, __k1, __k2 - __k1); }
400 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
402 { _S_copy(__p, __k1, __k2 - __k1); }
405 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
407 const difference_type __d = difference_type(__n1 - __n2);
409 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
410 return __gnu_cxx::__numeric_traits<int>::__max;
411 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
412 return __gnu_cxx::__numeric_traits<int>::__min;
421 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
425 _M_erase(size_type __pos, size_type __n);
436 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
437 : _M_dataplus(_M_local_data())
438 { _M_set_length(0); }
445 : _M_dataplus(_M_local_data(), __a)
446 { _M_set_length(0); }
453 : _M_dataplus(_M_local_data(),
454 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
455 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
466 const _Alloc& __a = _Alloc())
467 : _M_dataplus(_M_local_data(), __a)
469 const _CharT* __start = __str._M_data()
470 + __str._M_check(__pos,
"basic_string::basic_string");
471 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
482 : _M_dataplus(_M_local_data())
484 const _CharT* __start = __str._M_data()
485 + __str._M_check(__pos,
"basic_string::basic_string");
486 _M_construct(__start, __start + __str._M_limit(__pos, __n));
497 size_type __n,
const _Alloc& __a)
498 : _M_dataplus(_M_local_data(), __a)
500 const _CharT* __start
501 = __str._M_data() + __str._M_check(__pos,
"string::string");
502 _M_construct(__start, __start + __str._M_limit(__pos, __n));
515 const _Alloc& __a = _Alloc())
516 : _M_dataplus(_M_local_data(), __a)
517 { _M_construct(__s, __s + __n); }
524 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
527 template<
typename = _RequireAllocator<_Alloc>>
529 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
530 : _M_dataplus(_M_local_data(), __a)
531 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
539 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
542 template<
typename = _RequireAllocator<_Alloc>>
544 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
545 : _M_dataplus(_M_local_data(), __a)
546 { _M_construct(__n, __c); }
548 #if __cplusplus >= 201103L
557 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
559 if (__str._M_is_local())
561 traits_type::copy(_M_local_buf, __str._M_local_buf,
562 _S_local_capacity + 1);
566 _M_data(__str._M_data());
567 _M_capacity(__str._M_allocated_capacity);
573 _M_length(__str.length());
574 __str._M_data(__str._M_local_data());
575 __str._M_set_length(0);
583 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
584 : _M_dataplus(_M_local_data(), __a)
585 { _M_construct(__l.begin(), __l.end()); }
588 : _M_dataplus(_M_local_data(), __a)
589 { _M_construct(__str.begin(), __str.end()); }
592 noexcept(_Alloc_traits::_S_always_equal())
593 : _M_dataplus(_M_local_data(), __a)
595 if (__str._M_is_local())
597 traits_type::copy(_M_local_buf, __str._M_local_buf,
598 _S_local_capacity + 1);
599 _M_length(__str.length());
600 __str._M_set_length(0);
602 else if (_Alloc_traits::_S_always_equal()
603 || __str.get_allocator() == __a)
605 _M_data(__str._M_data());
606 _M_length(__str.length());
607 _M_capacity(__str._M_allocated_capacity);
608 __str._M_data(__str._M_local_buf);
609 __str._M_set_length(0);
612 _M_construct(__str.begin(), __str.end());
623 #if __cplusplus >= 201103L
624 template<
typename _InputIterator,
625 typename = std::_RequireInputIter<_InputIterator>>
627 template<
typename _InputIterator>
629 basic_string(_InputIterator __beg, _InputIterator __end,
630 const _Alloc& __a = _Alloc())
631 : _M_dataplus(_M_local_data(), __a)
632 { _M_construct(__beg, __end); }
634 #if __cplusplus >= 201703L
642 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
643 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
644 const _Alloc& __a = _Alloc())
652 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
654 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
655 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
671 #if __cplusplus >= 201103L
672 if (_Alloc_traits::_S_propagate_on_copy_assign())
674 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
675 && _M_get_allocator() != __str._M_get_allocator())
679 if (__str.size() <= _S_local_capacity)
681 _M_destroy(_M_allocated_capacity);
682 _M_data(_M_local_data());
687 const auto __len = __str.size();
688 auto __alloc = __str._M_get_allocator();
690 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
691 _M_destroy(_M_allocated_capacity);
694 _M_set_length(__len);
697 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
700 return this->
assign(__str);
709 {
return this->
assign(__s); }
725 #if __cplusplus >= 201103L
737 noexcept(_Alloc_traits::_S_nothrow_move())
739 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
740 && !_Alloc_traits::_S_always_equal()
741 && _M_get_allocator() != __str._M_get_allocator())
744 _M_destroy(_M_allocated_capacity);
745 _M_data(_M_local_data());
749 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
751 if (__str._M_is_local())
755 this->_S_copy(_M_data(), __str._M_data(), __str.size());
756 _M_set_length(__str.size());
758 else if (_Alloc_traits::_S_propagate_on_move_assign()
759 || _Alloc_traits::_S_always_equal()
760 || _M_get_allocator() == __str._M_get_allocator())
763 pointer __data =
nullptr;
764 size_type __capacity;
767 if (_Alloc_traits::_S_always_equal())
771 __capacity = _M_allocated_capacity;
774 _M_destroy(_M_allocated_capacity);
777 _M_data(__str._M_data());
778 _M_length(__str.length());
779 _M_capacity(__str._M_allocated_capacity);
782 __str._M_data(__data);
783 __str._M_capacity(__capacity);
786 __str._M_data(__str._M_local_buf);
801 this->
assign(__l.begin(), __l.size());
806 #if __cplusplus >= 201703L
811 template<
typename _Tp>
812 _If_sv<_Tp, basic_string&>
814 {
return this->
assign(__svt); }
820 operator __sv_type() const noexcept
821 {
return __sv_type(
data(),
size()); }
830 begin() _GLIBCXX_NOEXCEPT
831 {
return iterator(_M_data()); }
838 begin() const _GLIBCXX_NOEXCEPT
839 {
return const_iterator(_M_data()); }
846 end() _GLIBCXX_NOEXCEPT
847 {
return iterator(_M_data() + this->
size()); }
854 end() const _GLIBCXX_NOEXCEPT
855 {
return const_iterator(_M_data() + this->
size()); }
863 rbegin() _GLIBCXX_NOEXCEPT
864 {
return reverse_iterator(this->
end()); }
871 const_reverse_iterator
872 rbegin() const _GLIBCXX_NOEXCEPT
873 {
return const_reverse_iterator(this->
end()); }
881 rend() _GLIBCXX_NOEXCEPT
882 {
return reverse_iterator(this->
begin()); }
889 const_reverse_iterator
890 rend() const _GLIBCXX_NOEXCEPT
891 {
return const_reverse_iterator(this->
begin()); }
893 #if __cplusplus >= 201103L
900 {
return const_iterator(this->_M_data()); }
907 cend() const noexcept
908 {
return const_iterator(this->_M_data() + this->
size()); }
915 const_reverse_iterator
917 {
return const_reverse_iterator(this->
end()); }
924 const_reverse_iterator
925 crend() const noexcept
926 {
return const_reverse_iterator(this->
begin()); }
934 size() const _GLIBCXX_NOEXCEPT
935 {
return _M_string_length; }
940 length() const _GLIBCXX_NOEXCEPT
941 {
return _M_string_length; }
946 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
959 resize(size_type __n, _CharT __c);
973 { this->
resize(__n, _CharT()); }
975 #if __cplusplus >= 201103L
999 return _M_is_local() ? size_type(_S_local_capacity)
1000 : _M_allocated_capacity;
1021 reserve(size_type __res_arg = 0);
1027 clear() _GLIBCXX_NOEXCEPT
1028 { _M_set_length(0); }
1034 _GLIBCXX_NODISCARD
bool
1035 empty() const _GLIBCXX_NOEXCEPT
1036 {
return this->
size() == 0; }
1050 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1052 __glibcxx_assert(__pos <=
size());
1053 return _M_data()[__pos];
1071 __glibcxx_assert(__pos <=
size());
1073 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1074 return _M_data()[__pos];
1088 at(size_type __n)
const
1090 if (__n >= this->
size())
1091 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1092 "(which is %zu) >= this->size() "
1095 return _M_data()[__n];
1112 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1113 "(which is %zu) >= this->size() "
1116 return _M_data()[__n];
1119 #if __cplusplus >= 201103L
1127 __glibcxx_assert(!
empty());
1136 front() const noexcept
1138 __glibcxx_assert(!
empty());
1149 __glibcxx_assert(!
empty());
1158 back() const noexcept
1160 __glibcxx_assert(!
empty());
1173 {
return this->
append(__str); }
1182 {
return this->
append(__s); }
1196 #if __cplusplus >= 201103L
1204 {
return this->
append(__l.begin(), __l.size()); }
1207 #if __cplusplus >= 201703L
1213 template<
typename _Tp>
1214 _If_sv<_Tp, basic_string&>
1216 {
return this->
append(__svt); }
1226 {
return _M_append(__str._M_data(), __str.size()); }
1243 {
return _M_append(__str._M_data()
1244 + __str._M_check(__pos,
"basic_string::append"),
1245 __str._M_limit(__pos, __n)); }
1254 append(
const _CharT* __s, size_type __n)
1256 __glibcxx_requires_string_len(__s, __n);
1257 _M_check_length(size_type(0), __n,
"basic_string::append");
1258 return _M_append(__s, __n);
1267 append(
const _CharT* __s)
1269 __glibcxx_requires_string(__s);
1270 const size_type __n = traits_type::length(__s);
1271 _M_check_length(size_type(0), __n,
"basic_string::append");
1272 return _M_append(__s, __n);
1284 append(size_type __n, _CharT __c)
1285 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1287 #if __cplusplus >= 201103L
1294 append(initializer_list<_CharT> __l)
1295 {
return this->
append(__l.begin(), __l.size()); }
1306 #if __cplusplus >= 201103L
1307 template<
class _InputIterator,
1308 typename = std::_RequireInputIter<_InputIterator>>
1310 template<
class _InputIterator>
1313 append(_InputIterator __first, _InputIterator __last)
1316 #if __cplusplus >= 201703L
1322 template<
typename _Tp>
1323 _If_sv<_Tp, basic_string&>
1326 __sv_type __sv = __svt;
1327 return this->
append(__sv.data(), __sv.size());
1337 template<
typename _Tp>
1338 _If_sv<_Tp, basic_string&>
1339 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1341 __sv_type __sv = __svt;
1342 return _M_append(__sv.data()
1343 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1344 std::__sv_limit(__sv.size(), __pos, __n));
1355 const size_type __size = this->
size();
1357 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1358 traits_type::assign(this->_M_data()[__size], __c);
1359 this->_M_set_length(__size + 1);
1370 this->_M_assign(__str);
1374 #if __cplusplus >= 201103L
1385 noexcept(_Alloc_traits::_S_nothrow_move())
1389 return *
this = std::move(__str);
1408 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1409 + __str._M_check(__pos,
"basic_string::assign"),
1410 __str._M_limit(__pos, __n)); }
1423 assign(
const _CharT* __s, size_type __n)
1425 __glibcxx_requires_string_len(__s, __n);
1426 return _M_replace(size_type(0), this->
size(), __s, __n);
1439 assign(
const _CharT* __s)
1441 __glibcxx_requires_string(__s);
1442 return _M_replace(size_type(0), this->
size(), __s,
1443 traits_type::length(__s));
1456 assign(size_type __n, _CharT __c)
1457 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1467 #if __cplusplus >= 201103L
1468 template<
class _InputIterator,
1469 typename = std::_RequireInputIter<_InputIterator>>
1471 template<
class _InputIterator>
1474 assign(_InputIterator __first, _InputIterator __last)
1477 #if __cplusplus >= 201103L
1484 assign(initializer_list<_CharT> __l)
1485 {
return this->
assign(__l.begin(), __l.size()); }
1488 #if __cplusplus >= 201703L
1494 template<
typename _Tp>
1495 _If_sv<_Tp, basic_string&>
1498 __sv_type __sv = __svt;
1499 return this->
assign(__sv.data(), __sv.size());
1509 template<
typename _Tp>
1510 _If_sv<_Tp, basic_string&>
1511 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1513 __sv_type __sv = __svt;
1514 return _M_replace(size_type(0), this->
size(),
1516 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1517 std::__sv_limit(__sv.size(), __pos, __n));
1521 #if __cplusplus >= 201103L
1538 insert(const_iterator __p, size_type __n, _CharT __c)
1540 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1541 const size_type __pos = __p -
begin();
1542 this->
replace(__p, __p, __n, __c);
1543 return iterator(this->_M_data() + __pos);
1560 insert(iterator __p, size_type __n, _CharT __c)
1561 { this->
replace(__p, __p, __n, __c); }
1564 #if __cplusplus >= 201103L
1579 template<
class _InputIterator,
1580 typename = std::_RequireInputIter<_InputIterator>>
1582 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1584 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1585 const size_type __pos = __p -
begin();
1586 this->
replace(__p, __p, __beg, __end);
1587 return iterator(this->_M_data() + __pos);
1602 template<
class _InputIterator>
1604 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1605 { this->
replace(__p, __p, __beg, __end); }
1608 #if __cplusplus >= 201103L
1616 insert(const_iterator __p, initializer_list<_CharT> __l)
1617 {
return this->
insert(__p, __l.begin(), __l.end()); }
1619 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1622 insert(iterator __p, initializer_list<_CharT> __l)
1624 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1625 this->
insert(__p -
begin(), __l.begin(), __l.size());
1644 {
return this->
replace(__pos1, size_type(0),
1645 __str._M_data(), __str.size()); }
1667 size_type __pos2, size_type __n =
npos)
1668 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1669 + __str._M_check(__pos2,
"basic_string::insert"),
1670 __str._M_limit(__pos2, __n)); }
1689 insert(size_type __pos,
const _CharT* __s, size_type __n)
1690 {
return this->
replace(__pos, size_type(0), __s, __n); }
1708 insert(size_type __pos,
const _CharT* __s)
1710 __glibcxx_requires_string(__s);
1711 return this->
replace(__pos, size_type(0), __s,
1712 traits_type::length(__s));
1732 insert(size_type __pos, size_type __n, _CharT __c)
1733 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1734 size_type(0), __n, __c); }
1750 insert(__const_iterator __p, _CharT __c)
1752 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1753 const size_type __pos = __p -
begin();
1754 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1755 return iterator(_M_data() + __pos);
1758 #if __cplusplus >= 201703L
1765 template<
typename _Tp>
1766 _If_sv<_Tp, basic_string&>
1767 insert(size_type __pos,
const _Tp& __svt)
1769 __sv_type __sv = __svt;
1770 return this->
insert(__pos, __sv.data(), __sv.size());
1782 template<
typename _Tp>
1783 _If_sv<_Tp, basic_string&>
1784 insert(size_type __pos1,
const _Tp& __svt,
1785 size_type __pos2, size_type __n =
npos)
1787 __sv_type __sv = __svt;
1788 return this->
replace(__pos1, size_type(0),
1790 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1791 std::__sv_limit(__sv.size(), __pos2, __n));
1811 erase(size_type __pos = 0, size_type __n =
npos)
1813 _M_check(__pos,
"basic_string::erase");
1815 this->_M_set_length(__pos);
1817 this->_M_erase(__pos, _M_limit(__pos, __n));
1830 erase(__const_iterator __position)
1832 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1833 && __position <
end());
1834 const size_type __pos = __position -
begin();
1835 this->_M_erase(__pos, size_type(1));
1836 return iterator(_M_data() + __pos);
1849 erase(__const_iterator __first, __const_iterator __last)
1851 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1852 && __last <=
end());
1853 const size_type __pos = __first -
begin();
1854 if (__last ==
end())
1855 this->_M_set_length(__pos);
1857 this->_M_erase(__pos, __last - __first);
1858 return iterator(this->_M_data() + __pos);
1861 #if __cplusplus >= 201103L
1870 __glibcxx_assert(!
empty());
1871 _M_erase(
size() - 1, 1);
1894 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1916 size_type __pos2, size_type __n2 =
npos)
1917 {
return this->
replace(__pos1, __n1, __str._M_data()
1918 + __str._M_check(__pos2,
"basic_string::replace"),
1919 __str._M_limit(__pos2, __n2)); }
1940 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1943 __glibcxx_requires_string_len(__s, __n2);
1944 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1945 _M_limit(__pos, __n1), __s, __n2);
1965 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1967 __glibcxx_requires_string(__s);
1968 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1989 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1990 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1991 _M_limit(__pos, __n1), __n2, __c); }
2007 replace(__const_iterator __i1, __const_iterator __i2,
2009 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2027 replace(__const_iterator __i1, __const_iterator __i2,
2028 const _CharT* __s, size_type __n)
2030 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2032 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2049 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2051 __glibcxx_requires_string(__s);
2052 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2070 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2073 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2075 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2093 #if __cplusplus >= 201103L
2094 template<
class _InputIterator,
2095 typename = std::_RequireInputIter<_InputIterator>>
2097 replace(const_iterator __i1, const_iterator __i2,
2098 _InputIterator __k1, _InputIterator __k2)
2100 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2102 __glibcxx_requires_valid_range(__k1, __k2);
2103 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2104 std::__false_type());
2107 template<
class _InputIterator>
2108 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2109 typename __enable_if_not_native_iterator<_InputIterator>::__type
2113 replace(iterator __i1, iterator __i2,
2114 _InputIterator __k1, _InputIterator __k2)
2116 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2118 __glibcxx_requires_valid_range(__k1, __k2);
2119 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2120 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2127 replace(__const_iterator __i1, __const_iterator __i2,
2128 _CharT* __k1, _CharT* __k2)
2130 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2132 __glibcxx_requires_valid_range(__k1, __k2);
2138 replace(__const_iterator __i1, __const_iterator __i2,
2139 const _CharT* __k1,
const _CharT* __k2)
2141 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2143 __glibcxx_requires_valid_range(__k1, __k2);
2149 replace(__const_iterator __i1, __const_iterator __i2,
2150 iterator __k1, iterator __k2)
2152 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2154 __glibcxx_requires_valid_range(__k1, __k2);
2156 __k1.base(), __k2 - __k1);
2160 replace(__const_iterator __i1, __const_iterator __i2,
2161 const_iterator __k1, const_iterator __k2)
2163 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2165 __glibcxx_requires_valid_range(__k1, __k2);
2167 __k1.base(), __k2 - __k1);
2170 #if __cplusplus >= 201103L
2186 initializer_list<_CharT> __l)
2187 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2190 #if __cplusplus >= 201703L
2198 template<
typename _Tp>
2199 _If_sv<_Tp, basic_string&>
2200 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2202 __sv_type __sv = __svt;
2203 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2215 template<
typename _Tp>
2216 _If_sv<_Tp, basic_string&>
2217 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2218 size_type __pos2, size_type __n2 =
npos)
2220 __sv_type __sv = __svt;
2221 return this->
replace(__pos1, __n1,
2223 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2224 std::__sv_limit(__sv.size(), __pos2, __n2));
2236 template<
typename _Tp>
2237 _If_sv<_Tp, basic_string&>
2238 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2240 __sv_type __sv = __svt;
2241 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2246 template<
class _Integer>
2248 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2249 _Integer __n, _Integer __val, __true_type)
2250 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2252 template<
class _InputIterator>
2254 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2255 _InputIterator __k1, _InputIterator __k2,
2259 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2263 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2264 const size_type __len2);
2267 _M_append(
const _CharT* __s, size_type __n);
2284 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2304 c_str() const _GLIBCXX_NOEXCEPT
2305 {
return _M_data(); }
2316 data() const _GLIBCXX_NOEXCEPT
2317 {
return _M_data(); }
2319 #if __cplusplus >= 201703L
2328 {
return _M_data(); }
2336 {
return _M_get_allocator(); }
2351 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2367 {
return this->
find(__str.data(), __pos, __str.size()); }
2369 #if __cplusplus >= 201703L
2376 template<
typename _Tp>
2377 _If_sv<_Tp, size_type>
2378 find(
const _Tp& __svt, size_type __pos = 0) const
2379 noexcept(is_same<_Tp, __sv_type>::value)
2381 __sv_type __sv = __svt;
2382 return this->
find(__sv.data(), __pos, __sv.size());
2397 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2399 __glibcxx_requires_string(__s);
2400 return this->
find(__s, __pos, traits_type::length(__s));
2414 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2429 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2431 #if __cplusplus >= 201703L
2438 template<
typename _Tp>
2439 _If_sv<_Tp, size_type>
2440 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2441 noexcept(is_same<_Tp, __sv_type>::value)
2443 __sv_type __sv = __svt;
2444 return this->
rfind(__sv.data(), __pos, __sv.size());
2461 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2475 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2477 __glibcxx_requires_string(__s);
2478 return this->
rfind(__s, __pos, traits_type::length(__s));
2492 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2508 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2510 #if __cplusplus >= 201703L
2518 template<
typename _Tp>
2519 _If_sv<_Tp, size_type>
2521 noexcept(is_same<_Tp, __sv_type>::value)
2523 __sv_type __sv = __svt;
2524 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2541 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2558 __glibcxx_requires_string(__s);
2559 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2575 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2576 {
return this->
find(__c, __pos); }
2592 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2594 #if __cplusplus >= 201703L
2602 template<
typename _Tp>
2603 _If_sv<_Tp, size_type>
2605 noexcept(is_same<_Tp, __sv_type>::value)
2607 __sv_type __sv = __svt;
2608 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2625 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2642 __glibcxx_requires_string(__s);
2643 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2660 {
return this->
rfind(__c, __pos); }
2677 #if __cplusplus >= 201703L
2685 template<
typename _Tp>
2686 _If_sv<_Tp, size_type>
2688 noexcept(is_same<_Tp, __sv_type>::value)
2690 __sv_type __sv = __svt;
2709 size_type __n)
const _GLIBCXX_NOEXCEPT;
2725 __glibcxx_requires_string(__s);
2759 #if __cplusplus >= 201703L
2767 template<
typename _Tp>
2768 _If_sv<_Tp, size_type>
2770 noexcept(is_same<_Tp, __sv_type>::value)
2772 __sv_type __sv = __svt;
2791 size_type __n)
const _GLIBCXX_NOEXCEPT;
2807 __glibcxx_requires_string(__s);
2838 substr(size_type __pos = 0, size_type __n =
npos)
const
2840 _M_check(__pos,
"basic_string::substr"), __n); }
2859 const size_type __size = this->
size();
2860 const size_type __osize = __str.size();
2861 const size_type __len =
std::min(__size, __osize);
2863 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2865 __r = _S_compare(__size, __osize);
2869 #if __cplusplus >= 201703L
2875 template<
typename _Tp>
2877 compare(
const _Tp& __svt)
const
2878 noexcept(is_same<_Tp, __sv_type>::value)
2880 __sv_type __sv = __svt;
2881 const size_type __size = this->
size();
2882 const size_type __osize = __sv.size();
2883 const size_type __len =
std::min(__size, __osize);
2885 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2887 __r = _S_compare(__size, __osize);
2899 template<
typename _Tp>
2901 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2902 noexcept(is_same<_Tp, __sv_type>::value)
2904 __sv_type __sv = __svt;
2905 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2918 template<
typename _Tp>
2920 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2921 size_type __pos2, size_type __n2 =
npos)
const
2922 noexcept(is_same<_Tp, __sv_type>::value)
2924 __sv_type __sv = __svt;
2925 return __sv_type(*
this)
2926 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2977 size_type __pos2, size_type __n2 =
npos)
const;
2994 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3018 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3045 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3046 size_type __n2)
const;
3048 #if __cplusplus > 201703L
3050 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3051 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3054 starts_with(_CharT __x)
const noexcept
3055 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3058 starts_with(
const _CharT* __x)
const noexcept
3059 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3062 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3063 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3066 ends_with(_CharT __x)
const noexcept
3067 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3070 ends_with(
const _CharT* __x)
const noexcept
3071 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3075 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3077 _GLIBCXX_END_NAMESPACE_CXX11
3143 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3146 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3150 typedef _Traits traits_type;
3151 typedef typename _Traits::char_type value_type;
3152 typedef _Alloc allocator_type;
3153 typedef typename _CharT_alloc_type::size_type size_type;
3154 typedef typename _CharT_alloc_type::difference_type difference_type;
3155 #if __cplusplus < 201103L
3156 typedef typename _CharT_alloc_type::reference reference;
3157 typedef typename _CharT_alloc_type::const_reference const_reference;
3159 typedef value_type& reference;
3160 typedef const value_type& const_reference;
3162 typedef typename _CharT_alloc_type::pointer pointer;
3163 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3164 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3165 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3172 typedef iterator __const_iterator;
3191 size_type _M_length;
3192 size_type _M_capacity;
3193 _Atomic_word _M_refcount;
3196 struct _Rep : _Rep_base
3199 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3214 static const size_type _S_max_size;
3215 static const _CharT _S_terminal;
3219 static size_type _S_empty_rep_storage[];
3222 _S_empty_rep() _GLIBCXX_NOEXCEPT
3227 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3228 return *
reinterpret_cast<_Rep*
>(__p);
3232 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3234 #if defined(__GTHREADS)
3239 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3241 return this->_M_refcount < 0;
3246 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3248 #if defined(__GTHREADS)
3254 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3256 return this->_M_refcount > 0;
3261 _M_set_leaked() _GLIBCXX_NOEXCEPT
3262 { this->_M_refcount = -1; }
3265 _M_set_sharable() _GLIBCXX_NOEXCEPT
3266 { this->_M_refcount = 0; }
3269 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3271 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3272 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3275 this->_M_set_sharable();
3276 this->_M_length = __n;
3277 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3284 _M_refdata()
throw()
3285 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3288 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3290 return (!_M_is_leaked() && __alloc1 == __alloc2)
3291 ? _M_refcopy() : _M_clone(__alloc1);
3296 _S_create(size_type, size_type,
const _Alloc&);
3299 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3301 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3302 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3306 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3315 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3318 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3325 _M_destroy(
const _Alloc&)
throw();
3328 _M_refcopy()
throw()
3330 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3331 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3333 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3334 return _M_refdata();
3338 _M_clone(
const _Alloc&, size_type __res = 0);
3342 struct _Alloc_hider : _Alloc
3344 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3345 : _Alloc(__a), _M_p(__dat) { }
3355 static const size_type
npos =
static_cast<size_type
>(-1);
3359 mutable _Alloc_hider _M_dataplus;
3362 _M_data() const _GLIBCXX_NOEXCEPT
3363 {
return _M_dataplus._M_p; }
3366 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3367 {
return (_M_dataplus._M_p = __p); }
3370 _M_rep() const _GLIBCXX_NOEXCEPT
3371 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3376 _M_ibegin() const _GLIBCXX_NOEXCEPT
3377 {
return iterator(_M_data()); }
3380 _M_iend() const _GLIBCXX_NOEXCEPT
3381 {
return iterator(_M_data() + this->
size()); }
3386 if (!_M_rep()->_M_is_leaked())
3391 _M_check(size_type __pos,
const char* __s)
const
3393 if (__pos > this->
size())
3394 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3395 "this->size() (which is %zu)"),
3396 __s, __pos, this->
size());
3401 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3404 __throw_length_error(__N(__s));
3409 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3411 const bool __testoff = __off < this->
size() - __pos;
3412 return __testoff ? __off : this->
size() - __pos;
3417 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3419 return (less<const _CharT*>()(__s, _M_data())
3420 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3426 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3429 traits_type::assign(*__d, *__s);
3431 traits_type::copy(__d, __s, __n);
3435 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3438 traits_type::assign(*__d, *__s);
3440 traits_type::move(__d, __s, __n);
3444 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3447 traits_type::assign(*__d, __c);
3449 traits_type::assign(__d, __n, __c);
3454 template<
class _Iterator>
3456 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3458 for (; __k1 != __k2; ++__k1, (void)++__p)
3459 traits_type::assign(*__p, *__k1);
3463 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3464 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3467 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3469 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3472 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3473 { _M_copy(__p, __k1, __k2 - __k1); }
3476 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3478 { _M_copy(__p, __k1, __k2 - __k1); }
3481 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3483 const difference_type __d = difference_type(__n1 - __n2);
3485 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3486 return __gnu_cxx::__numeric_traits<int>::__max;
3487 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3488 return __gnu_cxx::__numeric_traits<int>::__min;
3494 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3500 _S_empty_rep() _GLIBCXX_NOEXCEPT
3501 {
return _Rep::_S_empty_rep(); }
3503 #if __cplusplus >= 201703L
3505 typedef basic_string_view<_CharT, _Traits> __sv_type;
3507 template<
typename _Tp,
typename _Res>
3509 __and_<is_convertible<const _Tp&, __sv_type>,
3510 __not_<is_convertible<const _Tp*, const basic_string*>>,
3511 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3516 _S_to_string_view(__sv_type __svt) noexcept
3525 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3549 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3551 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3553 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3579 const _Alloc& __a = _Alloc());
3597 size_type __n,
const _Alloc& __a);
3609 const _Alloc& __a = _Alloc());
3615 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3622 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3624 #if __cplusplus >= 201103L
3633 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3636 : _M_dataplus(std::move(__str._M_dataplus))
3638 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3639 __str._M_data(_S_empty_rep()._M_refdata());
3641 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3653 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3657 : _M_dataplus(__str._M_data(), __a)
3659 if (__a == __str.get_allocator())
3661 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3662 __str._M_data(_S_empty_rep()._M_refdata());
3664 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3668 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3678 template<
class _InputIterator>
3679 basic_string(_InputIterator __beg, _InputIterator __end,
3680 const _Alloc& __a = _Alloc());
3682 #if __cplusplus >= 201703L
3690 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3691 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3692 const _Alloc& __a = _Alloc())
3700 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3702 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3703 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3718 {
return this->
assign(__str); }
3726 {
return this->
assign(__s); }
3742 #if __cplusplus >= 201103L
3766 this->
assign(__l.begin(), __l.size());
3771 #if __cplusplus >= 201703L
3776 template<
typename _Tp>
3777 _If_sv<_Tp, basic_string&>
3779 {
return this->
assign(__svt); }
3785 operator __sv_type() const noexcept
3786 {
return __sv_type(
data(),
size()); }
3798 return iterator(_M_data());
3807 {
return const_iterator(_M_data()); }
3817 return iterator(_M_data() + this->
size());
3826 {
return const_iterator(_M_data() + this->
size()); }
3842 const_reverse_iterator
3860 const_reverse_iterator
3864 #if __cplusplus >= 201103L
3871 {
return const_iterator(this->_M_data()); }
3879 {
return const_iterator(this->_M_data() + this->
size()); }
3886 const_reverse_iterator
3895 const_reverse_iterator
3906 {
return _M_rep()->_M_length; }
3912 {
return _M_rep()->_M_length; }
3917 {
return _Rep::_S_max_size; }
3930 resize(size_type __n, _CharT __c);
3944 { this->
resize(__n, _CharT()); }
3946 #if __cplusplus >= 201103L
3951 #if __cpp_exceptions
3969 {
return _M_rep()->_M_capacity; }
3989 reserve(size_type __res_arg = 0);
3994 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3998 if (_M_rep()->_M_is_shared())
4001 _M_data(_S_empty_rep()._M_refdata());
4004 _M_rep()->_M_set_length_and_sharable(0);
4010 { _M_mutate(0, this->
size(), 0); }
4017 _GLIBCXX_NODISCARD
bool
4019 {
return this->
size() == 0; }
4035 __glibcxx_assert(__pos <=
size());
4036 return _M_data()[__pos];
4054 __glibcxx_assert(__pos <=
size());
4056 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4058 return _M_data()[__pos];
4074 if (__n >= this->
size())
4075 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4076 "(which is %zu) >= this->size() "
4079 return _M_data()[__n];
4097 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4098 "(which is %zu) >= this->size() "
4102 return _M_data()[__n];
4105 #if __cplusplus >= 201103L
4113 __glibcxx_assert(!
empty());
4124 __glibcxx_assert(!
empty());
4135 __glibcxx_assert(!
empty());
4146 __glibcxx_assert(!
empty());
4159 {
return this->
append(__str); }
4168 {
return this->
append(__s); }
4182 #if __cplusplus >= 201103L
4190 {
return this->
append(__l.begin(), __l.size()); }
4193 #if __cplusplus >= 201703L
4199 template<
typename _Tp>
4200 _If_sv<_Tp, basic_string&>
4202 {
return this->
append(__svt); }
4236 append(
const _CharT* __s, size_type __n);
4246 __glibcxx_requires_string(__s);
4247 return this->
append(__s, traits_type::length(__s));
4259 append(size_type __n, _CharT __c);
4261 #if __cplusplus >= 201103L
4269 {
return this->
append(__l.begin(), __l.size()); }
4280 template<
class _InputIterator>
4282 append(_InputIterator __first, _InputIterator __last)
4283 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4285 #if __cplusplus >= 201703L
4291 template<
typename _Tp>
4292 _If_sv<_Tp, basic_string&>
4295 __sv_type __sv = __svt;
4296 return this->
append(__sv.data(), __sv.size());
4307 template<
typename _Tp>
4308 _If_sv<_Tp, basic_string&>
4309 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4311 __sv_type __sv = __svt;
4312 return append(__sv.data()
4313 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4314 std::__sv_limit(__sv.size(), __pos, __n));
4325 const size_type __len = 1 + this->
size();
4326 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4328 traits_type::assign(_M_data()[this->
size()], __c);
4329 _M_rep()->_M_set_length_and_sharable(__len);
4340 #if __cplusplus >= 201103L
4373 {
return this->
assign(__str._M_data()
4374 + __str._M_check(__pos,
"basic_string::assign"),
4375 __str._M_limit(__pos, __n)); }
4388 assign(
const _CharT* __s, size_type __n);
4402 __glibcxx_requires_string(__s);
4403 return this->
assign(__s, traits_type::length(__s));
4417 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4427 template<
class _InputIterator>
4429 assign(_InputIterator __first, _InputIterator __last)
4430 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4432 #if __cplusplus >= 201103L
4440 {
return this->
assign(__l.begin(), __l.size()); }
4443 #if __cplusplus >= 201703L
4449 template<
typename _Tp>
4450 _If_sv<_Tp, basic_string&>
4453 __sv_type __sv = __svt;
4454 return this->
assign(__sv.data(), __sv.size());
4464 template<
typename _Tp>
4465 _If_sv<_Tp, basic_string&>
4466 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4468 __sv_type __sv = __svt;
4469 return assign(__sv.data()
4470 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4471 std::__sv_limit(__sv.size(), __pos, __n));
4489 insert(iterator __p, size_type __n, _CharT __c)
4490 { this->
replace(__p, __p, __n, __c); }
4504 template<
class _InputIterator>
4506 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4507 { this->
replace(__p, __p, __beg, __end); }
4509 #if __cplusplus >= 201103L
4519 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4520 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4538 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4560 size_type __pos2, size_type __n =
npos)
4561 {
return this->
insert(__pos1, __str._M_data()
4562 + __str._M_check(__pos2,
"basic_string::insert"),
4563 __str._M_limit(__pos2, __n)); }
4582 insert(size_type __pos,
const _CharT* __s, size_type __n);
4602 __glibcxx_requires_string(__s);
4603 return this->
insert(__pos, __s, traits_type::length(__s));
4623 insert(size_type __pos, size_type __n, _CharT __c)
4624 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4625 size_type(0), __n, __c); }
4643 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4644 const size_type __pos = __p - _M_ibegin();
4645 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4646 _M_rep()->_M_set_leaked();
4647 return iterator(_M_data() + __pos);
4650 #if __cplusplus >= 201703L
4657 template<
typename _Tp>
4658 _If_sv<_Tp, basic_string&>
4659 insert(size_type __pos,
const _Tp& __svt)
4661 __sv_type __sv = __svt;
4662 return this->
insert(__pos, __sv.data(), __sv.size());
4673 template<
typename _Tp>
4674 _If_sv<_Tp, basic_string&>
4675 insert(size_type __pos1,
const _Tp& __svt,
4676 size_type __pos2, size_type __n =
npos)
4678 __sv_type __sv = __svt;
4679 return this->
replace(__pos1, size_type(0), __sv.data()
4680 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4681 std::__sv_limit(__sv.size(), __pos2, __n));
4703 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4704 _M_limit(__pos, __n), size_type(0));
4719 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4720 && __position < _M_iend());
4721 const size_type __pos = __position - _M_ibegin();
4722 _M_mutate(__pos, size_type(1), size_type(0));
4723 _M_rep()->_M_set_leaked();
4724 return iterator(_M_data() + __pos);
4739 #if __cplusplus >= 201103L
4748 __glibcxx_assert(!
empty());
4772 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4794 size_type __pos2, size_type __n2 =
npos)
4795 {
return this->
replace(__pos1, __n1, __str._M_data()
4796 + __str._M_check(__pos2,
"basic_string::replace"),
4797 __str._M_limit(__pos2, __n2)); }
4818 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4838 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4840 __glibcxx_requires_string(__s);
4841 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4862 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4863 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4864 _M_limit(__pos, __n1), __n2, __c); }
4881 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4899 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4901 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4902 && __i2 <= _M_iend());
4903 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4920 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4922 __glibcxx_requires_string(__s);
4923 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4941 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4943 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4944 && __i2 <= _M_iend());
4945 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4963 template<
class _InputIterator>
4966 _InputIterator __k1, _InputIterator __k2)
4968 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4969 && __i2 <= _M_iend());
4970 __glibcxx_requires_valid_range(__k1, __k2);
4971 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4972 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4980 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4981 && __i2 <= _M_iend());
4982 __glibcxx_requires_valid_range(__k1, __k2);
4983 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4988 replace(iterator __i1, iterator __i2,
4989 const _CharT* __k1,
const _CharT* __k2)
4991 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4992 && __i2 <= _M_iend());
4993 __glibcxx_requires_valid_range(__k1, __k2);
4994 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4999 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5001 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5002 && __i2 <= _M_iend());
5003 __glibcxx_requires_valid_range(__k1, __k2);
5004 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5005 __k1.base(), __k2 - __k1);
5009 replace(iterator __i1, iterator __i2,
5010 const_iterator __k1, const_iterator __k2)
5012 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5013 && __i2 <= _M_iend());
5014 __glibcxx_requires_valid_range(__k1, __k2);
5015 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5016 __k1.base(), __k2 - __k1);
5019 #if __cplusplus >= 201103L
5036 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5039 #if __cplusplus >= 201703L
5047 template<
typename _Tp>
5048 _If_sv<_Tp, basic_string&>
5049 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5051 __sv_type __sv = __svt;
5052 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5064 template<
typename _Tp>
5065 _If_sv<_Tp, basic_string&>
5066 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5067 size_type __pos2, size_type __n2 =
npos)
5069 __sv_type __sv = __svt;
5070 return this->
replace(__pos1, __n1,
5072 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5073 std::__sv_limit(__sv.size(), __pos2, __n2));
5085 template<
typename _Tp>
5086 _If_sv<_Tp, basic_string&>
5087 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5089 __sv_type __sv = __svt;
5090 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5095 template<
class _Integer>
5097 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5098 _Integer __val, __true_type)
5099 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5101 template<
class _InputIterator>
5103 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5104 _InputIterator __k2, __false_type);
5107 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5111 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5116 template<
class _InIterator>
5118 _S_construct_aux(_InIterator __beg, _InIterator __end,
5119 const _Alloc& __a, __false_type)
5121 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5122 return _S_construct(__beg, __end, __a, _Tag());
5127 template<
class _Integer>
5129 _S_construct_aux(_Integer __beg, _Integer __end,
5130 const _Alloc& __a, __true_type)
5131 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5135 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5136 {
return _S_construct(__req, __c, __a); }
5138 template<
class _InIterator>
5140 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5142 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5143 return _S_construct_aux(__beg, __end, __a, _Integral());
5147 template<
class _InIterator>
5149 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5150 input_iterator_tag);
5154 template<
class _FwdIterator>
5156 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5157 forward_iterator_tag);
5160 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5177 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5188 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5199 {
return _M_data(); }
5211 {
return _M_data(); }
5213 #if __cplusplus >= 201703L
5233 {
return _M_dataplus; }
5248 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5264 {
return this->
find(__str.data(), __pos, __str.size()); }
5277 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5279 __glibcxx_requires_string(__s);
5280 return this->
find(__s, __pos, traits_type::length(__s));
5294 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5296 #if __cplusplus >= 201703L
5303 template<
typename _Tp>
5304 _If_sv<_Tp, size_type>
5305 find(
const _Tp& __svt, size_type __pos = 0) const
5306 noexcept(
is_same<_Tp, __sv_type>::value)
5308 __sv_type __sv = __svt;
5309 return this->
find(__sv.data(), __pos, __sv.size());
5326 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5341 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5355 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5357 __glibcxx_requires_string(__s);
5358 return this->
rfind(__s, __pos, traits_type::length(__s));
5372 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5374 #if __cplusplus >= 201703L
5381 template<
typename _Tp>
5382 _If_sv<_Tp, size_type>
5383 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
5386 __sv_type __sv = __svt;
5387 return this->
rfind(__sv.data(), __pos, __sv.size());
5405 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5420 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5437 __glibcxx_requires_string(__s);
5438 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5455 {
return this->
find(__c, __pos); }
5457 #if __cplusplus >= 201703L
5465 template<
typename _Tp>
5466 _If_sv<_Tp, size_type>
5468 noexcept(
is_same<_Tp, __sv_type>::value)
5470 __sv_type __sv = __svt;
5471 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5489 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5504 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5521 __glibcxx_requires_string(__s);
5522 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5539 {
return this->
rfind(__c, __pos); }
5541 #if __cplusplus >= 201703L
5549 template<
typename _Tp>
5550 _If_sv<_Tp, size_type>
5554 __sv_type __sv = __svt;
5555 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5588 size_type __n)
const _GLIBCXX_NOEXCEPT;
5604 __glibcxx_requires_string(__s);
5622 #if __cplusplus >= 201703L
5630 template<
typename _Tp>
5631 _If_sv<_Tp, size_type>
5633 noexcept(
is_same<_Tp, __sv_type>::value)
5635 __sv_type __sv = __svt;
5670 size_type __n)
const _GLIBCXX_NOEXCEPT;
5686 __glibcxx_requires_string(__s);
5704 #if __cplusplus >= 201703L
5712 template<
typename _Tp>
5713 _If_sv<_Tp, size_type>
5717 __sv_type __sv = __svt;
5737 _M_check(__pos,
"basic_string::substr"), __n); }
5756 const size_type __size = this->
size();
5757 const size_type __osize = __str.size();
5758 const size_type __len =
std::min(__size, __osize);
5760 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5762 __r = _S_compare(__size, __osize);
5766 #if __cplusplus >= 201703L
5772 template<
typename _Tp>
5774 compare(
const _Tp& __svt)
const
5777 __sv_type __sv = __svt;
5778 const size_type __size = this->
size();
5779 const size_type __osize = __sv.size();
5780 const size_type __len =
std::min(__size, __osize);
5782 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5784 __r = _S_compare(__size, __osize);
5796 template<
typename _Tp>
5798 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5799 noexcept(is_same<_Tp, __sv_type>::value)
5801 __sv_type __sv = __svt;
5802 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5815 template<
typename _Tp>
5817 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5818 size_type __pos2, size_type __n2 =
npos)
const
5819 noexcept(is_same<_Tp, __sv_type>::value)
5821 __sv_type __sv = __svt;
5822 return __sv_type(*
this)
5823 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5874 size_type __pos2, size_type __n2 =
npos)
const;
5891 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5915 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5942 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5943 size_type __n2)
const;
5945 #if __cplusplus > 201703L
5947 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5948 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5951 starts_with(_CharT __x)
const noexcept
5952 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5955 starts_with(
const _CharT* __x)
const noexcept
5956 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5959 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5960 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5963 ends_with(_CharT __x)
const noexcept
5964 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5967 ends_with(
const _CharT* __x)
const noexcept
5968 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5971 # ifdef _GLIBCXX_TM_TS_INTERNAL
5973 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5976 ::_txnal_cow_string_c_str(
const void *that);
5978 ::_txnal_cow_string_D1(
void *that);
5980 ::_txnal_cow_string_D1_commit(
void *that);
5985 #if __cpp_deduction_guides >= 201606
5986 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5987 template<
typename _InputIterator,
typename _CharT
5988 =
typename iterator_traits<_InputIterator>::value_type,
5989 typename _Allocator = allocator<_CharT>,
5990 typename = _RequireInputIter<_InputIterator>,
5991 typename = _RequireAllocator<_Allocator>>
5992 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5993 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5997 template<
typename _CharT,
typename _Traits,
5998 typename _Allocator = allocator<_CharT>,
5999 typename = _RequireAllocator<_Allocator>>
6000 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6001 -> basic_string<_CharT, _Traits, _Allocator>;
6003 template<
typename _CharT,
typename _Traits,
6004 typename _Allocator = allocator<_CharT>,
6005 typename = _RequireAllocator<_Allocator>>
6006 basic_string(basic_string_view<_CharT, _Traits>,
6007 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6008 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6009 const _Allocator& = _Allocator())
6010 -> basic_string<_CharT, _Traits, _Allocator>;
6011 _GLIBCXX_END_NAMESPACE_CXX11
6021 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6022 basic_string<_CharT, _Traits, _Alloc>
6027 __str.append(__rhs);
6037 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6038 basic_string<_CharT,_Traits,_Alloc>
6040 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6048 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6049 basic_string<_CharT,_Traits,_Alloc>
6050 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6058 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6059 inline basic_string<_CharT, _Traits, _Alloc>
6061 const _CharT* __rhs)
6064 __str.append(__rhs);
6074 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6075 inline basic_string<_CharT, _Traits, _Alloc>
6079 typedef typename __string_type::size_type __size_type;
6080 __string_type __str(__lhs);
6081 __str.append(__size_type(1), __rhs);
6085 #if __cplusplus >= 201103L
6086 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6087 inline basic_string<_CharT, _Traits, _Alloc>
6088 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6089 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6090 {
return std::move(__lhs.append(__rhs)); }
6092 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6093 inline basic_string<_CharT, _Traits, _Alloc>
6094 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6095 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6096 {
return std::move(__rhs.insert(0, __lhs)); }
6098 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6099 inline basic_string<_CharT, _Traits, _Alloc>
6100 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6101 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6103 const auto __size = __lhs.size() + __rhs.size();
6104 const bool __cond = (__size > __lhs.capacity()
6105 && __size <= __rhs.capacity());
6106 return __cond ? std::move(__rhs.insert(0, __lhs))
6107 :
std::move(__lhs.append(__rhs));
6110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6111 inline basic_string<_CharT, _Traits, _Alloc>
6113 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6114 {
return std::move(__rhs.insert(0, __lhs)); }
6116 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6117 inline basic_string<_CharT, _Traits, _Alloc>
6119 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6120 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6123 inline basic_string<_CharT, _Traits, _Alloc>
6124 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6125 const _CharT* __rhs)
6126 {
return std::move(__lhs.append(__rhs)); }
6128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6129 inline basic_string<_CharT, _Traits, _Alloc>
6130 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6132 {
return std::move(__lhs.append(1, __rhs)); }
6142 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6147 {
return __lhs.compare(__rhs) == 0; }
6149 template<
typename _CharT>
6151 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6152 operator==(
const basic_string<_CharT>& __lhs,
6153 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6154 {
return (__lhs.size() == __rhs.size()
6164 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6166 operator==(
const _CharT* __lhs,
6168 {
return __rhs.compare(__lhs) == 0; }
6176 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6179 const _CharT* __rhs)
6180 {
return __lhs.compare(__rhs) == 0; }
6189 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6194 {
return !(__lhs == __rhs); }
6202 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6204 operator!=(
const _CharT* __lhs,
6206 {
return !(__lhs == __rhs); }
6214 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6217 const _CharT* __rhs)
6218 {
return !(__lhs == __rhs); }
6227 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6232 {
return __lhs.compare(__rhs) < 0; }
6240 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6243 const _CharT* __rhs)
6244 {
return __lhs.compare(__rhs) < 0; }
6252 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6254 operator<(
const _CharT* __lhs,
6256 {
return __rhs.compare(__lhs) > 0; }
6265 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6270 {
return __lhs.compare(__rhs) > 0; }
6278 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6281 const _CharT* __rhs)
6282 {
return __lhs.compare(__rhs) > 0; }
6290 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6292 operator>(
const _CharT* __lhs,
6294 {
return __rhs.compare(__lhs) < 0; }
6303 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6308 {
return __lhs.compare(__rhs) <= 0; }
6316 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6319 const _CharT* __rhs)
6320 {
return __lhs.compare(__rhs) <= 0; }
6328 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6330 operator<=(
const _CharT* __lhs,
6332 {
return __rhs.compare(__lhs) >= 0; }
6341 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6346 {
return __lhs.compare(__rhs) >= 0; }
6354 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6357 const _CharT* __rhs)
6358 {
return __lhs.compare(__rhs) >= 0; }
6366 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6368 operator>=(
const _CharT* __lhs,
6370 {
return __rhs.compare(__lhs) <= 0; }
6379 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6383 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6384 { __lhs.swap(__rhs); }
6399 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6400 basic_istream<_CharT, _Traits>&
6401 operator>>(basic_istream<_CharT, _Traits>& __is,
6402 basic_string<_CharT, _Traits, _Alloc>& __str);
6405 basic_istream<char>&
6417 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6424 return __ostream_insert(__os, __str.data(), __str.size());
6440 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6441 basic_istream<_CharT, _Traits>&
6442 getline(basic_istream<_CharT, _Traits>& __is,
6443 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6457 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6458 inline basic_istream<_CharT, _Traits>&
6463 #if __cplusplus >= 201103L
6465 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6466 inline basic_istream<_CharT, _Traits>&
6472 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6473 inline basic_istream<_CharT, _Traits>&
6480 basic_istream<char>&
6481 getline(basic_istream<char>& __in, basic_string<char>& __str,
6484 #ifdef _GLIBCXX_USE_WCHAR_T
6486 basic_istream<wchar_t>&
6487 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6491 _GLIBCXX_END_NAMESPACE_VERSION
6494 #if __cplusplus >= 201103L
6498 namespace std _GLIBCXX_VISIBILITY(default)
6500 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6501 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6503 #if _GLIBCXX_USE_C99_STDLIB
6506 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6507 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6511 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6512 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6515 inline unsigned long
6516 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6517 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6521 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6522 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6525 inline unsigned long long
6526 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6527 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6532 stof(
const string& __str,
size_t* __idx = 0)
6533 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6536 stod(
const string& __str,
size_t* __idx = 0)
6537 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6540 stold(
const string& __str,
size_t* __idx = 0)
6541 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6544 #if _GLIBCXX_USE_C99_STDIO
6549 to_string(
int __val)
6550 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
int),
6554 to_string(
unsigned __val)
6555 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6556 4 *
sizeof(
unsigned),
6560 to_string(
long __val)
6561 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
long),
6565 to_string(
unsigned long __val)
6566 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6567 4 *
sizeof(
unsigned long),
6571 to_string(
long long __val)
6572 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6573 4 *
sizeof(
long long),
6577 to_string(
unsigned long long __val)
6578 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6579 4 *
sizeof(
unsigned long long),
6583 to_string(
float __val)
6586 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6587 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6592 to_string(
double __val)
6595 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6596 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6601 to_string(
long double __val)
6604 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6605 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6610 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6612 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6613 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6617 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6618 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6621 inline unsigned long
6622 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6623 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6627 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6628 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6631 inline unsigned long long
6632 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6633 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6638 stof(
const wstring& __str,
size_t* __idx = 0)
6639 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6642 stod(
const wstring& __str,
size_t* __idx = 0)
6643 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6646 stold(
const wstring& __str,
size_t* __idx = 0)
6647 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6649 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6652 to_wstring(
int __val)
6653 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6657 to_wstring(
unsigned __val)
6658 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6659 4 *
sizeof(
unsigned),
6663 to_wstring(
long __val)
6664 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6668 to_wstring(
unsigned long __val)
6669 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6670 4 *
sizeof(
unsigned long),
6674 to_wstring(
long long __val)
6675 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6676 4 *
sizeof(
long long),
6680 to_wstring(
unsigned long long __val)
6681 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6682 4 *
sizeof(
unsigned long long),
6686 to_wstring(
float __val)
6689 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6690 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6695 to_wstring(
double __val)
6698 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6699 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6704 to_wstring(
long double __val)
6707 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6708 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6714 _GLIBCXX_END_NAMESPACE_CXX11
6715 _GLIBCXX_END_NAMESPACE_VERSION
6720 #if __cplusplus >= 201103L
6724 namespace std _GLIBCXX_VISIBILITY(default)
6726 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6730 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6734 :
public __hash_base<size_t, string>
6737 operator()(
const string& __s)
const noexcept
6738 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6745 #ifdef _GLIBCXX_USE_WCHAR_T
6749 :
public __hash_base<size_t, wstring>
6752 operator()(
const wstring& __s)
const noexcept
6753 {
return std::_Hash_impl::hash(__s.
data(),
6754 __s.
length() *
sizeof(
wchar_t)); }
6763 #ifdef _GLIBCXX_USE_CHAR8_T
6766 struct hash<u8string>
6767 :
public __hash_base<size_t, u8string>
6770 operator()(
const u8string& __s)
const noexcept
6771 {
return std::_Hash_impl::hash(__s.data(),
6772 __s.length() *
sizeof(char8_t)); }
6783 :
public __hash_base<size_t, u16string>
6786 operator()(
const u16string& __s)
const noexcept
6787 {
return std::_Hash_impl::hash(__s.
data(),
6788 __s.
length() *
sizeof(char16_t)); }
6798 :
public __hash_base<size_t, u32string>
6801 operator()(
const u32string& __s)
const noexcept
6802 {
return std::_Hash_impl::hash(__s.
data(),
6803 __s.
length() *
sizeof(char32_t)); }
6810 #if __cplusplus >= 201402L
6812 #define __cpp_lib_string_udls 201304
6814 inline namespace literals
6816 inline namespace string_literals
6818 #pragma GCC diagnostic push
6819 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6820 _GLIBCXX_DEFAULT_ABI_TAG
6821 inline basic_string<char>
6822 operator""s(
const char* __str,
size_t __len)
6823 {
return basic_string<char>{__str, __len}; }
6825 #ifdef _GLIBCXX_USE_WCHAR_T
6826 _GLIBCXX_DEFAULT_ABI_TAG
6827 inline basic_string<wchar_t>
6828 operator""s(
const wchar_t* __str,
size_t __len)
6829 {
return basic_string<wchar_t>{__str, __len}; }
6832 #ifdef _GLIBCXX_USE_CHAR8_T
6833 _GLIBCXX_DEFAULT_ABI_TAG
6834 inline basic_string<char8_t>
6835 operator""s(
const char8_t* __str,
size_t __len)
6836 {
return basic_string<char8_t>{__str, __len}; }
6839 _GLIBCXX_DEFAULT_ABI_TAG
6840 inline basic_string<char16_t>
6841 operator""s(
const char16_t* __str,
size_t __len)
6842 {
return basic_string<char16_t>{__str, __len}; }
6844 _GLIBCXX_DEFAULT_ABI_TAG
6845 inline basic_string<char32_t>
6846 operator""s(
const char32_t* __str,
size_t __len)
6847 {
return basic_string<char32_t>{__str, __len}; }
6849 #pragma GCC diagnostic pop
6853 #if __cplusplus >= 201703L
6854 namespace __detail::__variant
6856 template<
typename>
struct _Never_valueless_alt;
6860 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6861 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6863 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6864 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6871 _GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX20_CONSTEXPR complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
_Iterator __base(_Iterator __it)
char_type widen(char __c) const
Widens characters.
Template class basic_ostream.
Primary class template hash.
Uniform interface to all allocator types.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
iterator erase(iterator __position)
Remove one character.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
const_reference front() const noexcept
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
const_reverse_iterator crend() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
_GLIBCXX_NODISCARD bool empty() const noexcept
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_iterator cbegin() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string() noexcept
Default constructor creates an empty string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.