34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 #if __cplusplus > 201402L 52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 #if _GLIBCXX_USE_CXX11_ABI 57 _GLIBCXX_BEGIN_NAMESPACE_CXX11
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
80 rebind<_CharT>::other _Char_alloc_type;
85 typedef _Traits traits_type;
86 typedef typename _Traits::char_type value_type;
87 typedef _Char_alloc_type allocator_type;
88 typedef typename _Alloc_traits::size_type size_type;
89 typedef typename _Alloc_traits::difference_type difference_type;
90 typedef typename _Alloc_traits::reference reference;
91 typedef typename _Alloc_traits::const_reference const_reference;
92 typedef typename _Alloc_traits::pointer pointer;
93 typedef typename _Alloc_traits::const_pointer const_pointer;
94 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
95 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
101 static const size_type
npos =
static_cast<size_type
>(-1);
105 #if __cplusplus < 201103L 106 typedef iterator __const_iterator;
108 typedef const_iterator __const_iterator;
111 #if __cplusplus > 201402L 113 typedef basic_string_view<_CharT, _Traits> __sv_type;
115 template<
typename _Tp,
typename _Res>
117 __and_<is_convertible<const _Tp&, __sv_type>,
118 __not_<is_convertible<const _Tp*, const basic_string*>>,
119 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
124 _S_to_string_view(__sv_type __svt) noexcept
133 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
139 struct _Alloc_hider : allocator_type
141 #if __cplusplus < 201103L 142 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
143 : allocator_type(__a), _M_p(__dat) { }
145 _Alloc_hider(pointer __dat,
const _Alloc& __a)
146 : allocator_type(__a), _M_p(__dat) { }
148 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
149 : allocator_type(
std::move(__a)), _M_p(__dat) { }
155 _Alloc_hider _M_dataplus;
156 size_type _M_string_length;
158 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
162 _CharT _M_local_buf[_S_local_capacity + 1];
163 size_type _M_allocated_capacity;
168 { _M_dataplus._M_p = __p; }
171 _M_length(size_type __length)
172 { _M_string_length = __length; }
176 {
return _M_dataplus._M_p; }
181 #if __cplusplus >= 201103L 184 return pointer(_M_local_buf);
189 _M_local_data()
const 191 #if __cplusplus >= 201103L 194 return const_pointer(_M_local_buf);
199 _M_capacity(size_type __capacity)
200 { _M_allocated_capacity = __capacity; }
203 _M_set_length(size_type __n)
206 traits_type::assign(_M_data()[__n], _CharT());
211 {
return _M_data() == _M_local_data(); }
215 _M_create(size_type&, size_type);
221 _M_destroy(_M_allocated_capacity);
225 _M_destroy(size_type __size)
throw()
226 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
230 template<
typename _InIterator>
232 _M_construct_aux(_InIterator __beg, _InIterator __end,
235 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
236 _M_construct(__beg, __end, _Tag());
241 template<
typename _Integer>
243 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
244 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
247 _M_construct_aux_2(size_type __req, _CharT __c)
248 { _M_construct(__req, __c); }
250 template<
typename _InIterator>
252 _M_construct(_InIterator __beg, _InIterator __end)
254 typedef typename std::__is_integer<_InIterator>::__type _Integral;
255 _M_construct_aux(__beg, __end, _Integral());
259 template<
typename _InIterator>
261 _M_construct(_InIterator __beg, _InIterator __end,
266 template<
typename _FwdIterator>
268 _M_construct(_FwdIterator __beg, _FwdIterator __end,
272 _M_construct(size_type __req, _CharT __c);
276 {
return _M_dataplus; }
278 const allocator_type&
279 _M_get_allocator()
const 280 {
return _M_dataplus; }
284 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 287 template<
typename _Tp,
bool _Requires =
288 !__are_same<_Tp, _CharT*>::__value
289 && !__are_same<_Tp, const _CharT*>::__value
290 && !__are_same<_Tp, iterator>::__value
291 && !__are_same<_Tp, const_iterator>::__value>
292 struct __enable_if_not_native_iterator
294 template<
typename _Tp>
295 struct __enable_if_not_native_iterator<_Tp, false> { };
299 _M_check(size_type __pos,
const char* __s)
const 301 if (__pos > this->
size())
302 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 303 "this->size() (which is %zu)"),
304 __s, __pos, this->
size());
309 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 312 __throw_length_error(__N(__s));
318 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
320 const bool __testoff = __off < this->
size() - __pos;
321 return __testoff ? __off : this->
size() - __pos;
326 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
328 return (less<const _CharT*>()(__s, _M_data())
329 || less<const _CharT*>()(_M_data() + this->
size(), __s));
335 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
338 traits_type::assign(*__d, *__s);
340 traits_type::copy(__d, __s, __n);
344 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
347 traits_type::assign(*__d, *__s);
349 traits_type::move(__d, __s, __n);
353 _S_assign(_CharT* __d, size_type __n, _CharT __c)
356 traits_type::assign(*__d, __c);
358 traits_type::assign(__d, __n, __c);
363 template<
class _Iterator>
365 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
367 for (; __k1 != __k2; ++__k1, (void)++__p)
368 traits_type::assign(*__p, *__k1);
372 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
373 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
376 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
378 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
381 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
382 { _S_copy(__p, __k1, __k2 - __k1); }
385 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
387 { _S_copy(__p, __k1, __k2 - __k1); }
390 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
392 const difference_type __d = difference_type(__n1 - __n2);
394 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
395 return __gnu_cxx::__numeric_traits<int>::__max;
396 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
397 return __gnu_cxx::__numeric_traits<int>::__min;
406 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
410 _M_erase(size_type __pos, size_type __n);
421 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
422 : _M_dataplus(_M_local_data())
423 { _M_set_length(0); }
430 : _M_dataplus(_M_local_data(), __a)
431 { _M_set_length(0); }
438 : _M_dataplus(_M_local_data(),
439 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
440 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
451 const _Alloc& __a = _Alloc())
452 : _M_dataplus(_M_local_data(), __a)
454 const _CharT* __start = __str._M_data()
455 + __str._M_check(__pos,
"basic_string::basic_string");
456 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
467 : _M_dataplus(_M_local_data())
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, __n));
482 size_type __n,
const _Alloc& __a)
483 : _M_dataplus(_M_local_data(), __a)
485 const _CharT* __start
486 = __str._M_data() + __str._M_check(__pos,
"string::string");
487 _M_construct(__start, __start + __str._M_limit(__pos, __n));
500 const _Alloc& __a = _Alloc())
501 : _M_dataplus(_M_local_data(), __a)
502 { _M_construct(__s, __s + __n); }
509 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
510 : _M_dataplus(_M_local_data(), __a)
511 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
519 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
520 : _M_dataplus(_M_local_data(), __a)
521 { _M_construct(__n, __c); }
523 #if __cplusplus >= 201103L 532 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
534 if (__str._M_is_local())
536 traits_type::copy(_M_local_buf, __str._M_local_buf,
537 _S_local_capacity + 1);
541 _M_data(__str._M_data());
542 _M_capacity(__str._M_allocated_capacity);
548 _M_length(__str.length());
549 __str._M_data(__str._M_local_data());
550 __str._M_set_length(0);
558 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
559 : _M_dataplus(_M_local_data(), __a)
560 { _M_construct(__l.begin(), __l.end()); }
563 : _M_dataplus(_M_local_data(), __a)
564 { _M_construct(__str.begin(), __str.end()); }
567 noexcept(_Alloc_traits::_S_always_equal())
568 : _M_dataplus(_M_local_data(), __a)
570 if (__str._M_is_local())
572 traits_type::copy(_M_local_buf, __str._M_local_buf,
573 _S_local_capacity + 1);
574 _M_length(__str.length());
575 __str._M_set_length(0);
577 else if (_Alloc_traits::_S_always_equal()
578 || __str.get_allocator() == __a)
580 _M_data(__str._M_data());
581 _M_length(__str.length());
582 _M_capacity(__str._M_allocated_capacity);
583 __str._M_data(__str._M_local_buf);
584 __str._M_set_length(0);
587 _M_construct(__str.begin(), __str.end());
598 #if __cplusplus >= 201103L 599 template<
typename _InputIterator,
600 typename = std::_RequireInputIter<_InputIterator>>
602 template<
typename _InputIterator>
604 basic_string(_InputIterator __beg, _InputIterator __end,
605 const _Alloc& __a = _Alloc())
606 : _M_dataplus(_M_local_data(), __a)
607 { _M_construct(__beg, __end); }
609 #if __cplusplus > 201402L 617 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
618 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
619 const _Alloc& __a = _Alloc())
627 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
629 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
630 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
656 #if __cplusplus >= 201103L 657 if (_Alloc_traits::_S_propagate_on_copy_assign())
659 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
660 && _M_get_allocator() != __str._M_get_allocator())
664 if (__str.size() <= _S_local_capacity)
666 _M_destroy(_M_allocated_capacity);
667 _M_data(_M_local_data());
672 const auto __len = __str.size();
673 auto __alloc = __str._M_get_allocator();
675 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
676 _M_destroy(_M_allocated_capacity);
679 _M_set_length(__len);
682 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
685 return this->
assign(__str);
694 {
return this->
assign(__s); }
710 #if __cplusplus >= 201103L 723 noexcept(_Alloc_traits::_S_nothrow_move())
725 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
726 && !_Alloc_traits::_S_always_equal()
727 && _M_get_allocator() != __str._M_get_allocator())
730 _M_destroy(_M_allocated_capacity);
731 _M_data(_M_local_data());
735 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
737 if (!__str._M_is_local()
738 && (_Alloc_traits::_S_propagate_on_move_assign()
739 || _Alloc_traits::_S_always_equal()))
741 pointer __data =
nullptr;
742 size_type __capacity;
745 if (_Alloc_traits::_S_always_equal())
748 __capacity = _M_allocated_capacity;
751 _M_destroy(_M_allocated_capacity);
754 _M_data(__str._M_data());
755 _M_length(__str.length());
756 _M_capacity(__str._M_allocated_capacity);
759 __str._M_data(__data);
760 __str._M_capacity(__capacity);
763 __str._M_data(__str._M_local_buf);
778 this->
assign(__l.begin(), __l.size());
783 #if __cplusplus > 201402L 788 template<
typename _Tp>
789 _If_sv<_Tp, basic_string&>
791 {
return this->
assign(__svt); }
797 operator __sv_type() const noexcept
798 {
return __sv_type(
data(),
size()); }
807 begin() _GLIBCXX_NOEXCEPT
808 {
return iterator(_M_data()); }
815 begin() const _GLIBCXX_NOEXCEPT
816 {
return const_iterator(_M_data()); }
823 end() _GLIBCXX_NOEXCEPT
824 {
return iterator(_M_data() + this->
size()); }
831 end() const _GLIBCXX_NOEXCEPT
832 {
return const_iterator(_M_data() + this->
size()); }
840 rbegin() _GLIBCXX_NOEXCEPT
841 {
return reverse_iterator(this->
end()); }
848 const_reverse_iterator
849 rbegin() const _GLIBCXX_NOEXCEPT
850 {
return const_reverse_iterator(this->
end()); }
858 rend() _GLIBCXX_NOEXCEPT
859 {
return reverse_iterator(this->
begin()); }
866 const_reverse_iterator
867 rend() const _GLIBCXX_NOEXCEPT
868 {
return const_reverse_iterator(this->
begin()); }
870 #if __cplusplus >= 201103L 877 {
return const_iterator(this->_M_data()); }
884 cend() const noexcept
885 {
return const_iterator(this->_M_data() + this->
size()); }
892 const_reverse_iterator
894 {
return const_reverse_iterator(this->
end()); }
901 const_reverse_iterator
902 crend() const noexcept
903 {
return const_reverse_iterator(this->
begin()); }
911 size() const _GLIBCXX_NOEXCEPT
912 {
return _M_string_length; }
917 length() const _GLIBCXX_NOEXCEPT
918 {
return _M_string_length; }
923 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
936 resize(size_type __n, _CharT __c);
950 { this->
resize(__n, _CharT()); }
952 #if __cplusplus >= 201103L 976 return _M_is_local() ? size_type(_S_local_capacity)
977 : _M_allocated_capacity;
998 reserve(size_type __res_arg = 0);
1004 clear() _GLIBCXX_NOEXCEPT
1005 { _M_set_length(0); }
1012 empty() const _GLIBCXX_NOEXCEPT
1013 {
return this->
size() == 0; }
1027 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1029 __glibcxx_assert(__pos <=
size());
1030 return _M_data()[__pos];
1048 __glibcxx_assert(__pos <=
size());
1050 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1051 return _M_data()[__pos];
1065 at(size_type __n)
const 1067 if (__n >= this->
size())
1068 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1069 "(which is %zu) >= this->size() " 1072 return _M_data()[__n];
1089 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1090 "(which is %zu) >= this->size() " 1093 return _M_data()[__n];
1096 #if __cplusplus >= 201103L 1104 __glibcxx_assert(!
empty());
1113 front() const noexcept
1115 __glibcxx_assert(!
empty());
1126 __glibcxx_assert(!
empty());
1135 back() const noexcept
1137 __glibcxx_assert(!
empty());
1150 {
return this->
append(__str); }
1159 {
return this->
append(__s); }
1173 #if __cplusplus >= 201103L 1181 {
return this->
append(__l.begin(), __l.size()); }
1184 #if __cplusplus > 201402L 1190 template<
typename _Tp>
1191 _If_sv<_Tp, basic_string&>
1193 {
return this->
append(__svt); }
1203 {
return _M_append(__str._M_data(), __str.size()); }
1220 {
return _M_append(__str._M_data()
1221 + __str._M_check(__pos,
"basic_string::append"),
1222 __str._M_limit(__pos, __n)); }
1231 append(
const _CharT* __s, size_type __n)
1233 __glibcxx_requires_string_len(__s, __n);
1234 _M_check_length(size_type(0), __n,
"basic_string::append");
1235 return _M_append(__s, __n);
1244 append(
const _CharT* __s)
1246 __glibcxx_requires_string(__s);
1247 const size_type __n = traits_type::length(__s);
1248 _M_check_length(size_type(0), __n,
"basic_string::append");
1249 return _M_append(__s, __n);
1261 append(size_type __n, _CharT __c)
1262 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1264 #if __cplusplus >= 201103L 1271 append(initializer_list<_CharT> __l)
1272 {
return this->
append(__l.begin(), __l.size()); }
1283 #if __cplusplus >= 201103L 1284 template<
class _InputIterator,
1285 typename = std::_RequireInputIter<_InputIterator>>
1287 template<
class _InputIterator>
1290 append(_InputIterator __first, _InputIterator __last)
1293 #if __cplusplus > 201402L 1299 template<
typename _Tp>
1300 _If_sv<_Tp, basic_string&>
1303 __sv_type __sv = __svt;
1304 return this->
append(__sv.data(), __sv.size());
1314 template<
typename _Tp>
1315 _If_sv<_Tp, basic_string&>
1316 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1318 __sv_type __sv = __svt;
1319 return _M_append(__sv.data()
1320 + __sv._M_check(__pos,
"basic_string::append"),
1321 __sv._M_limit(__pos, __n));
1332 const size_type __size = this->
size();
1334 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1335 traits_type::assign(this->_M_data()[__size], __c);
1336 this->_M_set_length(__size + 1);
1347 this->_M_assign(__str);
1351 #if __cplusplus >= 201103L 1362 noexcept(_Alloc_traits::_S_nothrow_move())
1366 return *
this = std::move(__str);
1385 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1386 + __str._M_check(__pos,
"basic_string::assign"),
1387 __str._M_limit(__pos, __n)); }
1400 assign(
const _CharT* __s, size_type __n)
1402 __glibcxx_requires_string_len(__s, __n);
1403 return _M_replace(size_type(0), this->
size(), __s, __n);
1416 assign(
const _CharT* __s)
1418 __glibcxx_requires_string(__s);
1419 return _M_replace(size_type(0), this->
size(), __s,
1420 traits_type::length(__s));
1433 assign(size_type __n, _CharT __c)
1434 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1444 #if __cplusplus >= 201103L 1445 template<
class _InputIterator,
1446 typename = std::_RequireInputIter<_InputIterator>>
1448 template<
class _InputIterator>
1451 assign(_InputIterator __first, _InputIterator __last)
1454 #if __cplusplus >= 201103L 1461 assign(initializer_list<_CharT> __l)
1462 {
return this->
assign(__l.begin(), __l.size()); }
1465 #if __cplusplus > 201402L 1471 template<
typename _Tp>
1472 _If_sv<_Tp, basic_string&>
1475 __sv_type __sv = __svt;
1476 return this->
assign(__sv.data(), __sv.size());
1486 template<
typename _Tp>
1487 _If_sv<_Tp, basic_string&>
1488 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1490 __sv_type __sv = __svt;
1491 return _M_replace(size_type(0), this->
size(), __sv.data()
1492 + __sv._M_check(__pos,
"basic_string::assign"),
1493 __sv._M_limit(__pos, __n));
1497 #if __cplusplus >= 201103L 1514 insert(const_iterator __p, size_type __n, _CharT __c)
1516 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1517 const size_type __pos = __p -
begin();
1518 this->
replace(__p, __p, __n, __c);
1519 return iterator(this->_M_data() + __pos);
1536 insert(iterator __p, size_type __n, _CharT __c)
1537 { this->
replace(__p, __p, __n, __c); }
1540 #if __cplusplus >= 201103L 1555 template<
class _InputIterator,
1556 typename = std::_RequireInputIter<_InputIterator>>
1558 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1560 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1561 const size_type __pos = __p -
begin();
1562 this->
replace(__p, __p, __beg, __end);
1563 return iterator(this->_M_data() + __pos);
1578 template<
class _InputIterator>
1580 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1581 { this->
replace(__p, __p, __beg, __end); }
1584 #if __cplusplus >= 201103L 1592 insert(iterator __p, initializer_list<_CharT> __l)
1594 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1595 this->
insert(__p -
begin(), __l.begin(), __l.size());
1613 {
return this->
replace(__pos1, size_type(0),
1614 __str._M_data(), __str.size()); }
1636 size_type __pos2, size_type __n)
1637 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1638 + __str._M_check(__pos2,
"basic_string::insert"),
1639 __str._M_limit(__pos2, __n)); }
1658 insert(size_type __pos,
const _CharT* __s, size_type __n)
1659 {
return this->
replace(__pos, size_type(0), __s, __n); }
1677 insert(size_type __pos,
const _CharT* __s)
1679 __glibcxx_requires_string(__s);
1680 return this->
replace(__pos, size_type(0), __s,
1681 traits_type::length(__s));
1701 insert(size_type __pos, size_type __n, _CharT __c)
1702 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1703 size_type(0), __n, __c); }
1719 insert(__const_iterator __p, _CharT __c)
1721 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1722 const size_type __pos = __p -
begin();
1723 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1724 return iterator(_M_data() + __pos);
1727 #if __cplusplus > 201402L 1734 template<
typename _Tp>
1735 _If_sv<_Tp, basic_string&>
1736 insert(size_type __pos,
const _Tp& __svt)
1738 __sv_type __sv = __svt;
1739 return this->
insert(__pos, __sv.data(), __sv.size());
1751 template<
typename _Tp>
1752 _If_sv<_Tp, basic_string&>
1753 insert(size_type __pos1,
const _Tp& __svt,
1754 size_type __pos2, size_type __n =
npos)
1756 __sv_type __sv = __svt;
1757 return this->
replace(__pos1, size_type(0), __sv.data()
1758 + __sv._M_check(__pos2,
"basic_string::insert"),
1759 __sv._M_limit(__pos2, __n));
1779 erase(size_type __pos = 0, size_type __n =
npos)
1781 _M_check(__pos,
"basic_string::erase");
1783 this->_M_set_length(__pos);
1785 this->_M_erase(__pos, _M_limit(__pos, __n));
1798 erase(__const_iterator __position)
1800 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1801 && __position <
end());
1802 const size_type __pos = __position -
begin();
1803 this->_M_erase(__pos, size_type(1));
1804 return iterator(_M_data() + __pos);
1817 erase(__const_iterator __first, __const_iterator __last)
1819 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1820 && __last <=
end());
1821 const size_type __pos = __first -
begin();
1822 if (__last ==
end())
1823 this->_M_set_length(__pos);
1825 this->_M_erase(__pos, __last - __first);
1826 return iterator(this->_M_data() + __pos);
1829 #if __cplusplus >= 201103L 1838 __glibcxx_assert(!
empty());
1839 _M_erase(
size() - 1, 1);
1862 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1884 size_type __pos2, size_type __n2)
1885 {
return this->
replace(__pos1, __n1, __str._M_data()
1886 + __str._M_check(__pos2,
"basic_string::replace"),
1887 __str._M_limit(__pos2, __n2)); }
1908 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1911 __glibcxx_requires_string_len(__s, __n2);
1912 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1913 _M_limit(__pos, __n1), __s, __n2);
1933 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1935 __glibcxx_requires_string(__s);
1936 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1957 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1958 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1959 _M_limit(__pos, __n1), __n2, __c); }
1975 replace(__const_iterator __i1, __const_iterator __i2,
1977 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1995 replace(__const_iterator __i1, __const_iterator __i2,
1996 const _CharT* __s, size_type __n)
1998 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2000 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2017 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2019 __glibcxx_requires_string(__s);
2020 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2038 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2041 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2043 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2061 #if __cplusplus >= 201103L 2062 template<
class _InputIterator,
2063 typename = std::_RequireInputIter<_InputIterator>>
2065 replace(const_iterator __i1, const_iterator __i2,
2066 _InputIterator __k1, _InputIterator __k2)
2068 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2070 __glibcxx_requires_valid_range(__k1, __k2);
2071 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2072 std::__false_type());
2075 template<
class _InputIterator>
2076 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2077 typename __enable_if_not_native_iterator<_InputIterator>::__type
2081 replace(iterator __i1, iterator __i2,
2082 _InputIterator __k1, _InputIterator __k2)
2084 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2086 __glibcxx_requires_valid_range(__k1, __k2);
2087 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2088 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2095 replace(__const_iterator __i1, __const_iterator __i2,
2096 _CharT* __k1, _CharT* __k2)
2098 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2100 __glibcxx_requires_valid_range(__k1, __k2);
2106 replace(__const_iterator __i1, __const_iterator __i2,
2107 const _CharT* __k1,
const _CharT* __k2)
2109 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2111 __glibcxx_requires_valid_range(__k1, __k2);
2117 replace(__const_iterator __i1, __const_iterator __i2,
2118 iterator __k1, iterator __k2)
2120 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2122 __glibcxx_requires_valid_range(__k1, __k2);
2124 __k1.base(), __k2 - __k1);
2128 replace(__const_iterator __i1, __const_iterator __i2,
2129 const_iterator __k1, const_iterator __k2)
2131 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2133 __glibcxx_requires_valid_range(__k1, __k2);
2135 __k1.base(), __k2 - __k1);
2138 #if __cplusplus >= 201103L 2154 initializer_list<_CharT> __l)
2155 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2158 #if __cplusplus > 201402L 2166 template<
typename _Tp>
2167 _If_sv<_Tp, basic_string&>
2168 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2170 __sv_type __sv = __svt;
2171 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2183 template<
typename _Tp>
2184 _If_sv<_Tp, basic_string&>
2185 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2186 size_type __pos2, size_type __n2 =
npos)
2188 __sv_type __sv = __svt;
2189 return this->
replace(__pos1, __n1, __sv.data()
2190 + __sv._M_check(__pos2,
"basic_string::replace"),
2191 __sv._M_limit(__pos2, __n2));
2203 template<
typename _Tp>
2204 _If_sv<_Tp, basic_string&>
2205 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2207 __sv_type __sv = __svt;
2208 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2213 template<
class _Integer>
2215 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2216 _Integer __n, _Integer __val, __true_type)
2217 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2219 template<
class _InputIterator>
2221 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2222 _InputIterator __k1, _InputIterator __k2,
2226 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2230 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2231 const size_type __len2);
2234 _M_append(
const _CharT* __s, size_type __n);
2251 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2271 c_str() const _GLIBCXX_NOEXCEPT
2272 {
return _M_data(); }
2283 data() const _GLIBCXX_NOEXCEPT
2284 {
return _M_data(); }
2286 #if __cplusplus > 201402L 2295 {
return _M_data(); }
2303 {
return _M_get_allocator(); }
2318 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2334 {
return this->
find(__str.data(), __pos, __str.size()); }
2336 #if __cplusplus > 201402L 2343 template<
typename _Tp>
2344 _If_sv<_Tp, size_type>
2345 find(
const _Tp& __svt, size_type __pos = 0) const
2346 noexcept(is_same<_Tp, __sv_type>::value)
2348 __sv_type __sv = __svt;
2349 return this->
find(__sv.data(), __pos, __sv.size());
2364 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2366 __glibcxx_requires_string(__s);
2367 return this->
find(__s, __pos, traits_type::length(__s));
2381 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2396 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2398 #if __cplusplus > 201402L 2405 template<
typename _Tp>
2406 _If_sv<_Tp, size_type>
2407 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 2408 noexcept(is_same<_Tp, __sv_type>::value)
2410 __sv_type __sv = __svt;
2411 return this->
rfind(__sv.data(), __pos, __sv.size());
2428 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2442 rfind(
const _CharT* __s, size_type __pos =
npos)
const 2444 __glibcxx_requires_string(__s);
2445 return this->
rfind(__s, __pos, traits_type::length(__s));
2459 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2475 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2477 #if __cplusplus > 201402L 2485 template<
typename _Tp>
2486 _If_sv<_Tp, size_type>
2488 noexcept(is_same<_Tp, __sv_type>::value)
2490 __sv_type __sv = __svt;
2491 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2508 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2525 __glibcxx_requires_string(__s);
2526 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2542 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2543 {
return this->
find(__c, __pos); }
2559 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2561 #if __cplusplus > 201402L 2569 template<
typename _Tp>
2570 _If_sv<_Tp, size_type>
2572 noexcept(is_same<_Tp, __sv_type>::value)
2574 __sv_type __sv = __svt;
2575 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2592 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2609 __glibcxx_requires_string(__s);
2610 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2627 {
return this->
rfind(__c, __pos); }
2644 #if __cplusplus > 201402L 2652 template<
typename _Tp>
2653 _If_sv<_Tp, size_type>
2655 noexcept(is_same<_Tp, __sv_type>::value)
2657 __sv_type __sv = __svt;
2676 size_type __n)
const _GLIBCXX_NOEXCEPT;
2692 __glibcxx_requires_string(__s);
2726 #if __cplusplus > 201402L 2734 template<
typename _Tp>
2735 _If_sv<_Tp, size_type>
2737 noexcept(is_same<_Tp, __sv_type>::value)
2739 __sv_type __sv = __svt;
2758 size_type __n)
const _GLIBCXX_NOEXCEPT;
2774 __glibcxx_requires_string(__s);
2805 substr(size_type __pos = 0, size_type __n =
npos)
const 2807 _M_check(__pos,
"basic_string::substr"), __n); }
2826 const size_type __size = this->
size();
2827 const size_type __osize = __str.size();
2828 const size_type __len =
std::min(__size, __osize);
2830 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2832 __r = _S_compare(__size, __osize);
2836 #if __cplusplus > 201402L 2842 template<
typename _Tp>
2844 compare(
const _Tp& __svt)
const 2845 noexcept(is_same<_Tp, __sv_type>::value)
2847 __sv_type __sv = __svt;
2848 const size_type __size = this->
size();
2849 const size_type __osize = __sv.size();
2850 const size_type __len =
std::min(__size, __osize);
2852 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2854 __r = _S_compare(__size, __osize);
2866 template<
typename _Tp>
2868 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 2869 noexcept(is_same<_Tp, __sv_type>::value)
2871 __sv_type __sv = __svt;
2872 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2885 template<
typename _Tp>
2887 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2888 size_type __pos2, size_type __n2 =
npos)
const 2889 noexcept(is_same<_Tp, __sv_type>::value)
2891 __sv_type __sv = __svt;
2892 return __sv_type(*
this)
2893 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2944 size_type __pos2, size_type __n2)
const;
2961 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2985 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3012 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3013 size_type __n2)
const;
3016 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3018 _GLIBCXX_END_NAMESPACE_CXX11
3019 #else // !_GLIBCXX_USE_CXX11_ABI 3084 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3087 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3091 typedef _Traits traits_type;
3092 typedef typename _Traits::char_type value_type;
3093 typedef _Alloc allocator_type;
3094 typedef typename _CharT_alloc_type::size_type size_type;
3095 typedef typename _CharT_alloc_type::difference_type difference_type;
3096 typedef typename _CharT_alloc_type::reference reference;
3097 typedef typename _CharT_alloc_type::const_reference const_reference;
3098 typedef typename _CharT_alloc_type::pointer pointer;
3099 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3100 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3101 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3123 size_type _M_length;
3124 size_type _M_capacity;
3125 _Atomic_word _M_refcount;
3128 struct _Rep : _Rep_base
3131 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3146 static const size_type _S_max_size;
3147 static const _CharT _S_terminal;
3151 static size_type _S_empty_rep_storage[];
3154 _S_empty_rep() _GLIBCXX_NOEXCEPT
3159 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3160 return *
reinterpret_cast<_Rep*
>(__p);
3164 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3166 #if defined(__GTHREADS) 3171 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3173 return this->_M_refcount < 0;
3178 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3180 #if defined(__GTHREADS) 3186 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3188 return this->_M_refcount > 0;
3193 _M_set_leaked() _GLIBCXX_NOEXCEPT
3194 { this->_M_refcount = -1; }
3197 _M_set_sharable() _GLIBCXX_NOEXCEPT
3198 { this->_M_refcount = 0; }
3201 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3203 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3204 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3207 this->_M_set_sharable();
3208 this->_M_length = __n;
3209 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3216 _M_refdata()
throw()
3217 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3220 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3222 return (!_M_is_leaked() && __alloc1 == __alloc2)
3223 ? _M_refcopy() : _M_clone(__alloc1);
3228 _S_create(size_type, size_type,
const _Alloc&);
3231 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3233 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3234 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3238 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3247 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3250 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3257 _M_destroy(
const _Alloc&)
throw();
3260 _M_refcopy()
throw()
3262 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3263 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3265 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3266 return _M_refdata();
3270 _M_clone(
const _Alloc&, size_type __res = 0);
3274 struct _Alloc_hider : _Alloc
3276 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3277 : _Alloc(__a), _M_p(__dat) { }
3287 static const size_type
npos =
static_cast<size_type
>(-1);
3291 mutable _Alloc_hider _M_dataplus;
3294 _M_data() const _GLIBCXX_NOEXCEPT
3295 {
return _M_dataplus._M_p; }
3298 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3299 {
return (_M_dataplus._M_p = __p); }
3302 _M_rep() const _GLIBCXX_NOEXCEPT
3303 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3308 _M_ibegin() const _GLIBCXX_NOEXCEPT
3309 {
return iterator(_M_data()); }
3312 _M_iend() const _GLIBCXX_NOEXCEPT
3313 {
return iterator(_M_data() + this->
size()); }
3318 if (!_M_rep()->_M_is_leaked())
3323 _M_check(size_type __pos,
const char* __s)
const 3325 if (__pos > this->
size())
3326 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3327 "this->size() (which is %zu)"),
3328 __s, __pos, this->
size());
3333 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3336 __throw_length_error(__N(__s));
3341 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3343 const bool __testoff = __off < this->
size() - __pos;
3344 return __testoff ? __off : this->
size() - __pos;
3349 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3351 return (less<const _CharT*>()(__s, _M_data())
3352 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3358 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3361 traits_type::assign(*__d, *__s);
3363 traits_type::copy(__d, __s, __n);
3367 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3370 traits_type::assign(*__d, *__s);
3372 traits_type::move(__d, __s, __n);
3376 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3379 traits_type::assign(*__d, __c);
3381 traits_type::assign(__d, __n, __c);
3386 template<
class _Iterator>
3388 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3390 for (; __k1 != __k2; ++__k1, (void)++__p)
3391 traits_type::assign(*__p, *__k1);
3395 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3396 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3399 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3401 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3404 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3405 { _M_copy(__p, __k1, __k2 - __k1); }
3408 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3410 { _M_copy(__p, __k1, __k2 - __k1); }
3413 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3415 const difference_type __d = difference_type(__n1 - __n2);
3417 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3418 return __gnu_cxx::__numeric_traits<int>::__max;
3419 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3420 return __gnu_cxx::__numeric_traits<int>::__min;
3426 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3432 _S_empty_rep() _GLIBCXX_NOEXCEPT
3433 {
return _Rep::_S_empty_rep(); }
3435 #if __cplusplus > 201402L 3437 typedef basic_string_view<_CharT, _Traits> __sv_type;
3439 template<
typename _Tp,
typename _Res>
3441 __and_<is_convertible<const _Tp&, __sv_type>,
3442 __not_<is_convertible<const _Tp*, const basic_string*>>,
3443 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3448 _S_to_string_view(__sv_type __svt) noexcept
3457 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3471 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3472 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3474 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3499 const _Alloc& __a = _Alloc());
3517 size_type __n,
const _Alloc& __a);
3529 const _Alloc& __a = _Alloc());
3535 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3542 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3544 #if __cplusplus >= 201103L 3553 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3556 : _M_dataplus(__str._M_dataplus)
3558 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3559 __str._M_data(_S_empty_rep()._M_refdata());
3561 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3579 template<
class _InputIterator>
3580 basic_string(_InputIterator __beg, _InputIterator __end,
3581 const _Alloc& __a = _Alloc());
3583 #if __cplusplus > 201402L 3591 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3592 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3593 const _Alloc& __a = _Alloc())
3601 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3603 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3604 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3629 {
return this->
assign(__str); }
3637 {
return this->
assign(__s); }
3653 #if __cplusplus >= 201103L 3677 this->
assign(__l.begin(), __l.size());
3682 #if __cplusplus > 201402L 3687 template<
typename _Tp>
3688 _If_sv<_Tp, basic_string&>
3690 {
return this->
assign(__svt); }
3696 operator __sv_type() const noexcept
3697 {
return __sv_type(
data(),
size()); }
3709 return iterator(_M_data());
3718 {
return const_iterator(_M_data()); }
3728 return iterator(_M_data() + this->
size());
3737 {
return const_iterator(_M_data() + this->
size()); }
3753 const_reverse_iterator
3771 const_reverse_iterator
3775 #if __cplusplus >= 201103L 3782 {
return const_iterator(this->_M_data()); }
3790 {
return const_iterator(this->_M_data() + this->
size()); }
3797 const_reverse_iterator
3806 const_reverse_iterator
3817 {
return _M_rep()->_M_length; }
3823 {
return _M_rep()->_M_length; }
3828 {
return _Rep::_S_max_size; }
3841 resize(size_type __n, _CharT __c);
3855 { this->
resize(__n, _CharT()); }
3857 #if __cplusplus >= 201103L 3862 #if __cpp_exceptions 3880 {
return _M_rep()->_M_capacity; }
3900 reserve(size_type __res_arg = 0);
3905 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3909 if (_M_rep()->_M_is_shared())
3912 _M_data(_S_empty_rep()._M_refdata());
3915 _M_rep()->_M_set_length_and_sharable(0);
3921 { _M_mutate(0, this->
size(), 0); }
3930 {
return this->
size() == 0; }
3946 __glibcxx_assert(__pos <=
size());
3947 return _M_data()[__pos];
3965 __glibcxx_assert(__pos <=
size());
3967 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3969 return _M_data()[__pos];
3985 if (__n >= this->
size())
3986 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3987 "(which is %zu) >= this->size() " 3990 return _M_data()[__n];
4008 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4009 "(which is %zu) >= this->size() " 4013 return _M_data()[__n];
4016 #if __cplusplus >= 201103L 4024 __glibcxx_assert(!
empty());
4035 __glibcxx_assert(!
empty());
4046 __glibcxx_assert(!
empty());
4057 __glibcxx_assert(!
empty());
4070 {
return this->
append(__str); }
4079 {
return this->
append(__s); }
4093 #if __cplusplus >= 201103L 4101 {
return this->
append(__l.begin(), __l.size()); }
4104 #if __cplusplus > 201402L 4110 template<
typename _Tp>
4111 _If_sv<_Tp, basic_string&>
4113 {
return this->
append(__svt); }
4147 append(
const _CharT* __s, size_type __n);
4157 __glibcxx_requires_string(__s);
4158 return this->
append(__s, traits_type::length(__s));
4170 append(size_type __n, _CharT __c);
4172 #if __cplusplus >= 201103L 4180 {
return this->
append(__l.begin(), __l.size()); }
4191 template<
class _InputIterator>
4193 append(_InputIterator __first, _InputIterator __last)
4194 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4196 #if __cplusplus > 201402L 4202 template<
typename _Tp>
4203 _If_sv<_Tp, basic_string&>
4206 __sv_type __sv = __svt;
4207 return this->
append(__sv.data(), __sv.size());
4218 template<
typename _Tp>
4219 _If_sv<_Tp, basic_string&>
4220 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4222 __sv_type __sv = __svt;
4223 return append(__sv.data()
4224 + __sv._M_check(__pos,
"basic_string::append"),
4225 __sv._M_limit(__pos, __n));
4236 const size_type __len = 1 + this->
size();
4237 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4239 traits_type::assign(_M_data()[this->
size()], __c);
4240 _M_rep()->_M_set_length_and_sharable(__len);
4251 #if __cplusplus >= 201103L 4284 {
return this->
assign(__str._M_data()
4285 + __str._M_check(__pos,
"basic_string::assign"),
4286 __str._M_limit(__pos, __n)); }
4299 assign(
const _CharT* __s, size_type __n);
4313 __glibcxx_requires_string(__s);
4314 return this->
assign(__s, traits_type::length(__s));
4328 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4338 template<
class _InputIterator>
4340 assign(_InputIterator __first, _InputIterator __last)
4341 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4343 #if __cplusplus >= 201103L 4351 {
return this->
assign(__l.begin(), __l.size()); }
4354 #if __cplusplus > 201402L 4360 template<
typename _Tp>
4361 _If_sv<_Tp, basic_string&>
4364 __sv_type __sv = __svt;
4365 return this->
assign(__sv.data(), __sv.size());
4375 template<
typename _Tp>
4376 _If_sv<_Tp, basic_string&>
4377 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4379 __sv_type __sv = __svt;
4380 return assign(__sv.data()
4381 + __sv._M_check(__pos,
"basic_string::assign"),
4382 __sv._M_limit(__pos, __n));
4400 insert(iterator __p, size_type __n, _CharT __c)
4401 { this->
replace(__p, __p, __n, __c); }
4415 template<
class _InputIterator>
4417 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4418 { this->
replace(__p, __p, __beg, __end); }
4420 #if __cplusplus >= 201103L 4430 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4431 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4449 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4471 size_type __pos2, size_type __n)
4472 {
return this->
insert(__pos1, __str._M_data()
4473 + __str._M_check(__pos2,
"basic_string::insert"),
4474 __str._M_limit(__pos2, __n)); }
4493 insert(size_type __pos,
const _CharT* __s, size_type __n);
4513 __glibcxx_requires_string(__s);
4514 return this->
insert(__pos, __s, traits_type::length(__s));
4534 insert(size_type __pos, size_type __n, _CharT __c)
4535 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4536 size_type(0), __n, __c); }
4554 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4555 const size_type __pos = __p - _M_ibegin();
4556 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4557 _M_rep()->_M_set_leaked();
4558 return iterator(_M_data() + __pos);
4561 #if __cplusplus > 201402L 4568 template<
typename _Tp>
4569 _If_sv<_Tp, basic_string&>
4570 insert(size_type __pos,
const _Tp& __svt)
4572 __sv_type __sv = __svt;
4573 return this->
insert(__pos, __sv.data(), __sv.size());
4585 template<
typename _Tp>
4586 _If_sv<_Tp, basic_string&>
4587 insert(size_type __pos1,
const _Tp& __svt,
4588 size_type __pos2, size_type __n =
npos)
4590 __sv_type __sv = __svt;
4591 return this->
replace(__pos1, size_type(0), __sv.data()
4592 + __sv._M_check(__pos2,
"basic_string::insert"),
4593 __sv._M_limit(__pos2, __n));
4615 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4616 _M_limit(__pos, __n), size_type(0));
4631 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4632 && __position < _M_iend());
4633 const size_type __pos = __position - _M_ibegin();
4634 _M_mutate(__pos, size_type(1), size_type(0));
4635 _M_rep()->_M_set_leaked();
4636 return iterator(_M_data() + __pos);
4651 #if __cplusplus >= 201103L 4660 __glibcxx_assert(!
empty());
4684 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4706 size_type __pos2, size_type __n2)
4707 {
return this->
replace(__pos1, __n1, __str._M_data()
4708 + __str._M_check(__pos2,
"basic_string::replace"),
4709 __str._M_limit(__pos2, __n2)); }
4730 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4750 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4752 __glibcxx_requires_string(__s);
4753 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4774 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4775 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4776 _M_limit(__pos, __n1), __n2, __c); }
4793 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4811 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4813 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4814 && __i2 <= _M_iend());
4815 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4832 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4834 __glibcxx_requires_string(__s);
4835 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4853 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4855 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4856 && __i2 <= _M_iend());
4857 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4875 template<
class _InputIterator>
4878 _InputIterator __k1, _InputIterator __k2)
4880 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4881 && __i2 <= _M_iend());
4882 __glibcxx_requires_valid_range(__k1, __k2);
4883 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4884 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4892 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4893 && __i2 <= _M_iend());
4894 __glibcxx_requires_valid_range(__k1, __k2);
4895 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4900 replace(iterator __i1, iterator __i2,
4901 const _CharT* __k1,
const _CharT* __k2)
4903 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4904 && __i2 <= _M_iend());
4905 __glibcxx_requires_valid_range(__k1, __k2);
4906 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4911 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4913 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4914 && __i2 <= _M_iend());
4915 __glibcxx_requires_valid_range(__k1, __k2);
4916 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4917 __k1.base(), __k2 - __k1);
4921 replace(iterator __i1, iterator __i2,
4922 const_iterator __k1, const_iterator __k2)
4924 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4925 && __i2 <= _M_iend());
4926 __glibcxx_requires_valid_range(__k1, __k2);
4927 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4928 __k1.base(), __k2 - __k1);
4931 #if __cplusplus >= 201103L 4948 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4951 #if __cplusplus > 201402L 4959 template<
typename _Tp>
4960 _If_sv<_Tp, basic_string&>
4961 replace(size_type __pos, size_type __n,
const _Tp& __svt)
4963 __sv_type __sv = __svt;
4964 return this->
replace(__pos, __n, __sv.data(), __sv.size());
4976 template<
typename _Tp>
4977 _If_sv<_Tp, basic_string&>
4978 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4979 size_type __pos2, size_type __n2 =
npos)
4981 __sv_type __sv = __svt;
4982 return this->
replace(__pos1, __n1,
4983 __sv.data() + __sv._M_check(__pos2,
"basic_string::replace"),
4984 __sv._M_limit(__pos2, __n2));
4996 template<
typename _Tp>
4997 _If_sv<_Tp, basic_string&>
4998 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5000 __sv_type __sv = __svt;
5001 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5006 template<
class _Integer>
5008 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5009 _Integer __val, __true_type)
5010 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5012 template<
class _InputIterator>
5014 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5015 _InputIterator __k2, __false_type);
5018 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5022 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5027 template<
class _InIterator>
5029 _S_construct_aux(_InIterator __beg, _InIterator __end,
5030 const _Alloc& __a, __false_type)
5032 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5033 return _S_construct(__beg, __end, __a, _Tag());
5038 template<
class _Integer>
5040 _S_construct_aux(_Integer __beg, _Integer __end,
5041 const _Alloc& __a, __true_type)
5042 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5046 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5047 {
return _S_construct(__req, __c, __a); }
5049 template<
class _InIterator>
5051 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5053 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5054 return _S_construct_aux(__beg, __end, __a, _Integral());
5058 template<
class _InIterator>
5060 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5061 input_iterator_tag);
5065 template<
class _FwdIterator>
5067 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5068 forward_iterator_tag);
5071 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5088 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5110 {
return _M_data(); }
5122 {
return _M_data(); }
5124 #if __cplusplus > 201402L 5133 {
return _M_data(); }
5141 {
return _M_dataplus; }
5156 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5172 {
return this->
find(__str.data(), __pos, __str.size()); }
5185 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5187 __glibcxx_requires_string(__s);
5188 return this->
find(__s, __pos, traits_type::length(__s));
5202 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5204 #if __cplusplus > 201402L 5211 template<
typename _Tp>
5212 _If_sv<_Tp, size_type>
5213 find(
const _Tp& __svt, size_type __pos = 0) const
5214 noexcept(
is_same<_Tp, __sv_type>::value)
5216 __sv_type __sv = __svt;
5217 return this->
find(__sv.data(), __pos, __sv.size());
5234 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5249 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5263 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5265 __glibcxx_requires_string(__s);
5266 return this->
rfind(__s, __pos, traits_type::length(__s));
5280 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5282 #if __cplusplus > 201402L 5289 template<
typename _Tp>
5290 _If_sv<_Tp, size_type>
5291 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 5294 __sv_type __sv = __svt;
5295 return this->
rfind(__sv.data(), __pos, __sv.size());
5313 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5328 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5345 __glibcxx_requires_string(__s);
5346 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5363 {
return this->
find(__c, __pos); }
5365 #if __cplusplus > 201402L 5373 template<
typename _Tp>
5374 _If_sv<_Tp, size_type>
5376 noexcept(
is_same<_Tp, __sv_type>::value)
5378 __sv_type __sv = __svt;
5379 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5397 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5412 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5429 __glibcxx_requires_string(__s);
5430 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5447 {
return this->
rfind(__c, __pos); }
5449 #if __cplusplus > 201402L 5457 template<
typename _Tp>
5458 _If_sv<_Tp, size_type>
5462 __sv_type __sv = __svt;
5463 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5496 size_type __n)
const _GLIBCXX_NOEXCEPT;
5512 __glibcxx_requires_string(__s);
5530 #if __cplusplus > 201402L 5538 template<
typename _Tp>
5539 _If_sv<_Tp, size_type>
5541 noexcept(
is_same<_Tp, __sv_type>::value)
5543 __sv_type __sv = __svt;
5578 size_type __n)
const _GLIBCXX_NOEXCEPT;
5594 __glibcxx_requires_string(__s);
5612 #if __cplusplus > 201402L 5620 template<
typename _Tp>
5621 _If_sv<_Tp, size_type>
5625 __sv_type __sv = __svt;
5645 _M_check(__pos,
"basic_string::substr"), __n); }
5664 const size_type __size = this->
size();
5665 const size_type __osize = __str.size();
5666 const size_type __len =
std::min(__size, __osize);
5668 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5670 __r = _S_compare(__size, __osize);
5674 #if __cplusplus > 201402L 5680 template<
typename _Tp>
5682 compare(
const _Tp& __svt)
const 5685 __sv_type __sv = __svt;
5686 const size_type __size = this->
size();
5687 const size_type __osize = __sv.size();
5688 const size_type __len =
std::min(__size, __osize);
5690 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5692 __r = _S_compare(__size, __osize);
5704 template<
typename _Tp>
5706 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5707 noexcept(is_same<_Tp, __sv_type>::value)
5709 __sv_type __sv = __svt;
5710 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5723 template<
typename _Tp>
5725 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5726 size_type __pos2, size_type __n2 =
npos)
const 5727 noexcept(is_same<_Tp, __sv_type>::value)
5729 __sv_type __sv = __svt;
5730 return __sv_type(*
this)
5731 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5782 size_type __pos2, size_type __n2)
const;
5799 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5823 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5850 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5851 size_type __n2)
const;
5853 # ifdef _GLIBCXX_TM_TS_INTERNAL 5855 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5858 ::_txnal_cow_string_c_str(
const void *that);
5860 ::_txnal_cow_string_D1(
void *that);
5862 ::_txnal_cow_string_D1_commit(
void *that);
5865 #endif // !_GLIBCXX_USE_CXX11_ABI 5867 #if __cpp_deduction_guides >= 201606 5868 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5869 template<
typename _InputIterator,
typename _CharT
5870 =
typename iterator_traits<_InputIterator>::value_type,
5871 typename _Allocator = allocator<_CharT>,
5872 typename = _RequireInputIter<_InputIterator>,
5873 typename = _RequireAllocator<_Allocator>>
5874 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5875 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5876 _GLIBCXX_END_NAMESPACE_CXX11
5886 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5887 basic_string<_CharT, _Traits, _Alloc>
5892 __str.append(__rhs);
5902 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5903 basic_string<_CharT,_Traits,_Alloc>
5905 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5913 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5914 basic_string<_CharT,_Traits,_Alloc>
5915 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5923 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5924 inline basic_string<_CharT, _Traits, _Alloc>
5926 const _CharT* __rhs)
5929 __str.append(__rhs);
5939 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5940 inline basic_string<_CharT, _Traits, _Alloc>
5944 typedef typename __string_type::size_type __size_type;
5945 __string_type __str(__lhs);
5946 __str.append(__size_type(1), __rhs);
5950 #if __cplusplus >= 201103L 5951 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5952 inline basic_string<_CharT, _Traits, _Alloc>
5953 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5954 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
5955 {
return std::move(__lhs.append(__rhs)); }
5957 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5958 inline basic_string<_CharT, _Traits, _Alloc>
5959 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5960 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5961 {
return std::move(__rhs.insert(0, __lhs)); }
5963 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5964 inline basic_string<_CharT, _Traits, _Alloc>
5965 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5966 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5968 const auto __size = __lhs.size() + __rhs.size();
5969 const bool __cond = (__size > __lhs.capacity()
5970 && __size <= __rhs.capacity());
5971 return __cond ? std::move(__rhs.insert(0, __lhs))
5972 : std::move(__lhs.append(__rhs));
5975 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5976 inline basic_string<_CharT, _Traits, _Alloc>
5978 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5979 {
return std::move(__rhs.insert(0, __lhs)); }
5981 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5982 inline basic_string<_CharT, _Traits, _Alloc>
5984 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5985 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5987 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5988 inline basic_string<_CharT, _Traits, _Alloc>
5989 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5990 const _CharT* __rhs)
5991 {
return std::move(__lhs.append(__rhs)); }
5993 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5994 inline basic_string<_CharT, _Traits, _Alloc>
5995 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5997 {
return std::move(__lhs.append(1, __rhs)); }
6007 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6012 {
return __lhs.compare(__rhs) == 0; }
6014 template<
typename _CharT>
6016 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6017 operator==(
const basic_string<_CharT>& __lhs,
6018 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6019 {
return (__lhs.size() == __rhs.size()
6029 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6031 operator==(
const _CharT* __lhs,
6033 {
return __rhs.compare(__lhs) == 0; }
6041 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6044 const _CharT* __rhs)
6045 {
return __lhs.compare(__rhs) == 0; }
6054 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6059 {
return !(__lhs == __rhs); }
6067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6069 operator!=(
const _CharT* __lhs,
6071 {
return !(__lhs == __rhs); }
6079 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6082 const _CharT* __rhs)
6083 {
return !(__lhs == __rhs); }
6092 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6094 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6097 {
return __lhs.
compare(__rhs) < 0; }
6105 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6107 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6108 const _CharT* __rhs)
6109 {
return __lhs.compare(__rhs) < 0; }
6117 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6119 operator<(
const _CharT* __lhs,
6121 {
return __rhs.compare(__lhs) > 0; }
6130 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6135 {
return __lhs.compare(__rhs) > 0; }
6143 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6146 const _CharT* __rhs)
6147 {
return __lhs.compare(__rhs) > 0; }
6155 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6157 operator>(
const _CharT* __lhs,
6159 {
return __rhs.compare(__lhs) < 0; }
6168 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6170 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6173 {
return __lhs.
compare(__rhs) <= 0; }
6181 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6183 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6184 const _CharT* __rhs)
6185 {
return __lhs.compare(__rhs) <= 0; }
6193 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6195 operator<=(
const _CharT* __lhs,
6197 {
return __rhs.compare(__lhs) >= 0; }
6206 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6211 {
return __lhs.compare(__rhs) >= 0; }
6219 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6222 const _CharT* __rhs)
6223 {
return __lhs.compare(__rhs) >= 0; }
6231 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6233 operator>=(
const _CharT* __lhs,
6235 {
return __rhs.compare(__lhs) <= 0; }
6244 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6248 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6249 { __lhs.swap(__rhs); }
6264 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6265 basic_istream<_CharT, _Traits>&
6266 operator>>(basic_istream<_CharT, _Traits>& __is,
6267 basic_string<_CharT, _Traits, _Alloc>& __str);
6270 basic_istream<char>&
6271 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6282 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6283 inline basic_ostream<_CharT, _Traits>&
6284 operator<<(basic_ostream<_CharT, _Traits>& __os,
6289 return __ostream_insert(__os, __str.data(), __str.size());
6305 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6306 basic_istream<_CharT, _Traits>&
6307 getline(basic_istream<_CharT, _Traits>& __is,
6308 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6322 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6323 inline basic_istream<_CharT, _Traits>&
6328 #if __cplusplus >= 201103L 6330 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6331 inline basic_istream<_CharT, _Traits>&
6337 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6338 inline basic_istream<_CharT, _Traits>&
6345 basic_istream<char>&
6346 getline(basic_istream<char>& __in, basic_string<char>& __str,
6349 #ifdef _GLIBCXX_USE_WCHAR_T 6351 basic_istream<wchar_t>&
6352 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6356 _GLIBCXX_END_NAMESPACE_VERSION
6359 #if __cplusplus >= 201103L 6363 namespace std _GLIBCXX_VISIBILITY(default)
6365 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6366 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6368 #if _GLIBCXX_USE_C99_STDLIB 6371 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6372 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6376 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6377 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6380 inline unsigned long 6381 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6382 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6386 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6387 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6390 inline unsigned long long 6391 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6392 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6397 stof(
const string& __str,
size_t* __idx = 0)
6398 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6401 stod(
const string& __str,
size_t* __idx = 0)
6402 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6405 stold(
const string& __str,
size_t* __idx = 0)
6406 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6407 #endif // _GLIBCXX_USE_C99_STDLIB 6409 #if _GLIBCXX_USE_C99_STDIO 6414 to_string(
int __val)
6415 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6419 to_string(
unsigned __val)
6420 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6421 4 *
sizeof(unsigned),
6425 to_string(
long __val)
6426 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6430 to_string(
unsigned long __val)
6431 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6432 4 *
sizeof(
unsigned long),
6436 to_string(
long long __val)
6437 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6438 4 *
sizeof(
long long),
6442 to_string(
unsigned long long __val)
6443 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6444 4 *
sizeof(
unsigned long long),
6448 to_string(
float __val)
6451 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6452 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6457 to_string(
double __val)
6460 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6461 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6466 to_string(
long double __val)
6469 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6470 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6473 #endif // _GLIBCXX_USE_C99_STDIO 6475 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6477 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6478 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6482 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6483 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6486 inline unsigned long 6487 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6488 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6492 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6493 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6496 inline unsigned long long 6497 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6498 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6503 stof(
const wstring& __str,
size_t* __idx = 0)
6504 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6507 stod(
const wstring& __str,
size_t* __idx = 0)
6508 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6511 stold(
const wstring& __str,
size_t* __idx = 0)
6512 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6514 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6517 to_wstring(
int __val)
6518 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6522 to_wstring(
unsigned __val)
6523 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6524 4 *
sizeof(unsigned),
6528 to_wstring(
long __val)
6529 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6533 to_wstring(
unsigned long __val)
6534 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6535 4 *
sizeof(
unsigned long),
6539 to_wstring(
long long __val)
6540 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6541 4 *
sizeof(
long long),
6545 to_wstring(
unsigned long long __val)
6546 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6547 4 *
sizeof(
unsigned long long),
6551 to_wstring(
float __val)
6554 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6555 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6560 to_wstring(
double __val)
6563 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6564 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6569 to_wstring(
long double __val)
6572 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6573 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6576 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6577 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6579 _GLIBCXX_END_NAMESPACE_CXX11
6580 _GLIBCXX_END_NAMESPACE_VERSION
6585 #if __cplusplus >= 201103L 6589 namespace std _GLIBCXX_VISIBILITY(default)
6591 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6595 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6599 :
public __hash_base<size_t, string>
6602 operator()(
const string& __s)
const noexcept
6603 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6610 #ifdef _GLIBCXX_USE_WCHAR_T 6614 :
public __hash_base<size_t, wstring>
6617 operator()(
const wstring& __s)
const noexcept
6618 {
return std::_Hash_impl::hash(__s.
data(),
6619 __s.
length() *
sizeof(wchar_t)); }
6628 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6632 :
public __hash_base<size_t, u16string>
6635 operator()(
const u16string& __s)
const noexcept
6636 {
return std::_Hash_impl::hash(__s.
data(),
6637 __s.
length() *
sizeof(char16_t)); }
6647 :
public __hash_base<size_t, u32string>
6650 operator()(
const u32string& __s)
const noexcept
6651 {
return std::_Hash_impl::hash(__s.
data(),
6652 __s.
length() *
sizeof(char32_t)); }
6660 #if __cplusplus > 201103L 6662 #define __cpp_lib_string_udls 201304 6664 inline namespace literals
6666 inline namespace string_literals
6668 #pragma GCC diagnostic push 6669 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6670 _GLIBCXX_DEFAULT_ABI_TAG
6671 inline basic_string<char>
6672 operator""s(
const char* __str,
size_t __len)
6673 {
return basic_string<char>{__str, __len}; }
6675 #ifdef _GLIBCXX_USE_WCHAR_T 6676 _GLIBCXX_DEFAULT_ABI_TAG
6677 inline basic_string<wchar_t>
6678 operator""s(
const wchar_t* __str,
size_t __len)
6679 {
return basic_string<wchar_t>{__str, __len}; }
6682 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6683 _GLIBCXX_DEFAULT_ABI_TAG
6684 inline basic_string<char16_t>
6685 operator""s(
const char16_t* __str,
size_t __len)
6686 {
return basic_string<char16_t>{__str, __len}; }
6688 _GLIBCXX_DEFAULT_ABI_TAG
6689 inline basic_string<char32_t>
6690 operator""s(
const char32_t* __str,
size_t __len)
6691 {
return basic_string<char32_t>{__str, __len}; }
6694 #pragma GCC diagnostic pop 6698 #endif // __cplusplus > 201103L 6700 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & append(const basic_string &__str)
Append a string to this 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 & operator=(_CharT __c)
Set value to string of length 1.
size_type size() 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.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
Primary class template hash.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
iterator erase(iterator __position)
Remove one character.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
Template class basic_istream.
iterator insert(iterator __p, _CharT __c)
Insert one character.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void push_back(_CharT __c)
Append a single character.
const _CharT * data() const noexcept
Return const pointer to contents.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & append(const _CharT *__s)
Append a C string.
basic_string()
Default constructor creates an empty string.
size_type capacity() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
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 & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_reference back() const noexcept
const_reverse_iterator crend() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
void pop_back()
Remove the last character.
char_type widen(char __c) const
Widens characters.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
int compare(const basic_string &__str) const
Compare to a string.
ISO C++ entities toplevel namespace is std.
Uniform interface to C++98 and C++11 allocators.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const_reference operator[](size_type __pos) const noexcept
Subscript 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 substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
const_reverse_iterator rend() const noexcept
const_reference front() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
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.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
reverse_iterator rbegin()
const_iterator end() const noexcept
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple 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.
const_iterator cend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
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.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
Basis for explicit traits specializations.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string< wchar_t > wstring
A string of wchar_t.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
Forward iterators support a superset of input iterator operations.
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.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
bool empty() const noexcept
const_iterator begin() const noexcept
reference at(size_type __n)
Provides access to the data contained in the string.
Uniform interface to all pointer-like types.
static const size_type npos
Value returned by various member functions when they fail.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
~basic_string() noexcept
Destroy the string instance.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_iterator cbegin() const noexcept