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>
116 using _If_sv = enable_if_t<
117 __and_<is_convertible<const _Tp&, __sv_type>,
118 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
123 struct _Alloc_hider : allocator_type
125 #if __cplusplus < 201103L 126 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
127 : allocator_type(__a), _M_p(__dat) { }
129 _Alloc_hider(pointer __dat,
const _Alloc& __a)
130 : allocator_type(__a), _M_p(__dat) { }
132 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
133 : allocator_type(
std::move(__a)), _M_p(__dat) { }
139 _Alloc_hider _M_dataplus;
140 size_type _M_string_length;
142 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
146 _CharT _M_local_buf[_S_local_capacity + 1];
147 size_type _M_allocated_capacity;
152 { _M_dataplus._M_p = __p; }
155 _M_length(size_type __length)
156 { _M_string_length = __length; }
160 {
return _M_dataplus._M_p; }
165 #if __cplusplus >= 201103L 168 return pointer(_M_local_buf);
173 _M_local_data()
const 175 #if __cplusplus >= 201103L 178 return const_pointer(_M_local_buf);
183 _M_capacity(size_type __capacity)
184 { _M_allocated_capacity = __capacity; }
187 _M_set_length(size_type __n)
190 traits_type::assign(_M_data()[__n], _CharT());
195 {
return _M_data() == _M_local_data(); }
199 _M_create(size_type&, size_type);
205 _M_destroy(_M_allocated_capacity);
209 _M_destroy(size_type __size)
throw()
210 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
214 template<
typename _InIterator>
216 _M_construct_aux(_InIterator __beg, _InIterator __end,
219 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
220 _M_construct(__beg, __end, _Tag());
225 template<
typename _Integer>
227 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
228 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
231 _M_construct_aux_2(size_type __req, _CharT __c)
232 { _M_construct(__req, __c); }
234 template<
typename _InIterator>
236 _M_construct(_InIterator __beg, _InIterator __end)
238 typedef typename std::__is_integer<_InIterator>::__type _Integral;
239 _M_construct_aux(__beg, __end, _Integral());
243 template<
typename _InIterator>
245 _M_construct(_InIterator __beg, _InIterator __end,
250 template<
typename _FwdIterator>
252 _M_construct(_FwdIterator __beg, _FwdIterator __end,
256 _M_construct(size_type __req, _CharT __c);
260 {
return _M_dataplus; }
262 const allocator_type&
263 _M_get_allocator()
const 264 {
return _M_dataplus; }
268 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 271 template<
typename _Tp,
bool _Requires =
272 !__are_same<_Tp, _CharT*>::__value
273 && !__are_same<_Tp, const _CharT*>::__value
274 && !__are_same<_Tp, iterator>::__value
275 && !__are_same<_Tp, const_iterator>::__value>
276 struct __enable_if_not_native_iterator
278 template<
typename _Tp>
279 struct __enable_if_not_native_iterator<_Tp, false> { };
283 _M_check(size_type __pos,
const char* __s)
const 285 if (__pos > this->
size())
286 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 287 "this->size() (which is %zu)"),
288 __s, __pos, this->
size());
293 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 296 __throw_length_error(__N(__s));
302 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
304 const bool __testoff = __off < this->
size() - __pos;
305 return __testoff ? __off : this->
size() - __pos;
310 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
312 return (less<const _CharT*>()(__s, _M_data())
313 || less<const _CharT*>()(_M_data() + this->
size(), __s));
319 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
322 traits_type::assign(*__d, *__s);
324 traits_type::copy(__d, __s, __n);
328 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
331 traits_type::assign(*__d, *__s);
333 traits_type::move(__d, __s, __n);
337 _S_assign(_CharT* __d, size_type __n, _CharT __c)
340 traits_type::assign(*__d, __c);
342 traits_type::assign(__d, __n, __c);
347 template<
class _Iterator>
349 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
351 for (; __k1 != __k2; ++__k1, (void)++__p)
352 traits_type::assign(*__p, *__k1);
356 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
357 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
360 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
362 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
365 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
366 { _S_copy(__p, __k1, __k2 - __k1); }
369 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
371 { _S_copy(__p, __k1, __k2 - __k1); }
374 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
376 const difference_type __d = difference_type(__n1 - __n2);
378 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
379 return __gnu_cxx::__numeric_traits<int>::__max;
380 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
381 return __gnu_cxx::__numeric_traits<int>::__min;
390 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
394 _M_erase(size_type __pos, size_type __n);
405 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
406 : _M_dataplus(_M_local_data())
407 { _M_set_length(0); }
414 : _M_dataplus(_M_local_data(), __a)
415 { _M_set_length(0); }
422 : _M_dataplus(_M_local_data(),
423 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
424 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
435 const _Alloc& __a = _Alloc())
436 : _M_dataplus(_M_local_data(), __a)
438 const _CharT* __start = __str._M_data()
439 + __str._M_check(__pos,
"basic_string::basic_string");
440 _M_construct(__start, __start + __str._M_limit(__pos, npos));
449 basic_string(
const basic_string& __str, size_type __pos,
451 : _M_dataplus(_M_local_data())
453 const _CharT* __start = __str._M_data()
454 + __str._M_check(__pos,
"basic_string::basic_string");
455 _M_construct(__start, __start + __str._M_limit(__pos, __n));
465 basic_string(
const basic_string& __str, size_type __pos,
466 size_type __n,
const _Alloc& __a)
467 : _M_dataplus(_M_local_data(), __a)
469 const _CharT* __start
470 = __str._M_data() + __str._M_check(__pos,
"string::string");
471 _M_construct(__start, __start + __str._M_limit(__pos, __n));
484 const _Alloc& __a = _Alloc())
485 : _M_dataplus(_M_local_data(), __a)
486 { _M_construct(__s, __s + __n); }
493 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
494 : _M_dataplus(_M_local_data(), __a)
495 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
503 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
504 : _M_dataplus(_M_local_data(), __a)
505 { _M_construct(__n, __c); }
507 #if __cplusplus >= 201103L 516 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
518 if (__str._M_is_local())
520 traits_type::copy(_M_local_buf, __str._M_local_buf,
521 _S_local_capacity + 1);
525 _M_data(__str._M_data());
526 _M_capacity(__str._M_allocated_capacity);
532 _M_length(__str.length());
533 __str._M_data(__str._M_local_data());
534 __str._M_set_length(0);
542 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
543 : _M_dataplus(_M_local_data(), __a)
544 { _M_construct(__l.begin(), __l.end()); }
546 basic_string(
const basic_string& __str,
const _Alloc& __a)
547 : _M_dataplus(_M_local_data(), __a)
548 { _M_construct(__str.begin(), __str.end()); }
551 noexcept(_Alloc_traits::_S_always_equal())
552 : _M_dataplus(_M_local_data(), __a)
554 if (__str._M_is_local())
556 traits_type::copy(_M_local_buf, __str._M_local_buf,
557 _S_local_capacity + 1);
558 _M_length(__str.length());
559 __str._M_set_length(0);
561 else if (_Alloc_traits::_S_always_equal()
562 || __str.get_allocator() == __a)
564 _M_data(__str._M_data());
565 _M_length(__str.length());
566 _M_capacity(__str._M_allocated_capacity);
567 __str._M_data(__str._M_local_buf);
568 __str._M_set_length(0);
571 _M_construct(__str.begin(), __str.end());
582 #if __cplusplus >= 201103L 583 template<
typename _InputIterator,
584 typename = std::_RequireInputIter<_InputIterator>>
586 template<
typename _InputIterator>
588 basic_string(_InputIterator __beg, _InputIterator __end,
589 const _Alloc& __a = _Alloc())
590 : _M_dataplus(_M_local_data(), __a)
591 { _M_construct(__beg, __end); }
593 #if __cplusplus > 201402L 601 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
602 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
603 const _Alloc& __a = _Alloc())
604 : basic_string(__sv_type(__t).
substr(__pos, __n), __a) { }
612 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
613 : basic_string(__sv.
data(), __sv.
size(), __a) { }
629 #if __cplusplus >= 201103L 630 if (_Alloc_traits::_S_propagate_on_copy_assign())
632 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
633 && _M_get_allocator() != __str._M_get_allocator())
637 if (__str.size() <= _S_local_capacity)
639 _M_destroy(_M_allocated_capacity);
640 _M_data(_M_local_data());
645 const auto __len = __str.size();
646 auto __alloc = __str._M_get_allocator();
648 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
649 _M_destroy(_M_allocated_capacity);
652 _M_set_length(__len);
655 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
658 return this->
assign(__str);
667 {
return this->
assign(__s); }
683 #if __cplusplus >= 201103L 696 noexcept(_Alloc_traits::_S_nothrow_move())
698 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
699 && !_Alloc_traits::_S_always_equal()
700 && _M_get_allocator() != __str._M_get_allocator())
703 _M_destroy(_M_allocated_capacity);
704 _M_data(_M_local_data());
708 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
710 if (!__str._M_is_local()
711 && (_Alloc_traits::_S_propagate_on_move_assign()
712 || _Alloc_traits::_S_always_equal()))
714 pointer __data =
nullptr;
715 size_type __capacity;
718 if (_Alloc_traits::_S_always_equal())
721 __capacity = _M_allocated_capacity;
724 _M_destroy(_M_allocated_capacity);
727 _M_data(__str._M_data());
728 _M_length(__str.length());
729 _M_capacity(__str._M_allocated_capacity);
732 __str._M_data(__data);
733 __str._M_capacity(__capacity);
736 __str._M_data(__str._M_local_buf);
751 this->
assign(__l.begin(), __l.size());
756 #if __cplusplus > 201402L 761 template<
typename _Tp>
762 _If_sv<_Tp, basic_string&>
764 {
return this->
assign(__sv); }
770 operator __sv_type() const noexcept
771 {
return __sv_type(
data(),
size()); }
780 begin() _GLIBCXX_NOEXCEPT
781 {
return iterator(_M_data()); }
788 begin() const _GLIBCXX_NOEXCEPT
789 {
return const_iterator(_M_data()); }
796 end() _GLIBCXX_NOEXCEPT
797 {
return iterator(_M_data() + this->
size()); }
804 end() const _GLIBCXX_NOEXCEPT
805 {
return const_iterator(_M_data() + this->
size()); }
813 rbegin() _GLIBCXX_NOEXCEPT
814 {
return reverse_iterator(this->
end()); }
821 const_reverse_iterator
822 rbegin() const _GLIBCXX_NOEXCEPT
823 {
return const_reverse_iterator(this->
end()); }
831 rend() _GLIBCXX_NOEXCEPT
832 {
return reverse_iterator(this->
begin()); }
839 const_reverse_iterator
840 rend() const _GLIBCXX_NOEXCEPT
841 {
return const_reverse_iterator(this->
begin()); }
843 #if __cplusplus >= 201103L 850 {
return const_iterator(this->_M_data()); }
857 cend() const noexcept
858 {
return const_iterator(this->_M_data() + this->
size()); }
865 const_reverse_iterator
867 {
return const_reverse_iterator(this->
end()); }
874 const_reverse_iterator
875 crend() const noexcept
876 {
return const_reverse_iterator(this->
begin()); }
884 size() const _GLIBCXX_NOEXCEPT
885 {
return _M_string_length; }
890 length() const _GLIBCXX_NOEXCEPT
891 {
return _M_string_length; }
896 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
909 resize(size_type __n, _CharT __c);
923 { this->
resize(__n, _CharT()); }
925 #if __cplusplus >= 201103L 949 return _M_is_local() ? size_type(_S_local_capacity)
950 : _M_allocated_capacity;
971 reserve(size_type __res_arg = 0);
977 clear() _GLIBCXX_NOEXCEPT
978 { _M_set_length(0); }
985 empty() const _GLIBCXX_NOEXCEPT
986 {
return this->
size() == 0; }
1000 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1002 __glibcxx_assert(__pos <=
size());
1003 return _M_data()[__pos];
1021 __glibcxx_assert(__pos <=
size());
1023 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1024 return _M_data()[__pos];
1038 at(size_type __n)
const 1040 if (__n >= this->
size())
1041 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1042 "(which is %zu) >= this->size() " 1045 return _M_data()[__n];
1062 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1063 "(which is %zu) >= this->size() " 1066 return _M_data()[__n];
1069 #if __cplusplus >= 201103L 1077 __glibcxx_assert(!
empty());
1086 front() const noexcept
1088 __glibcxx_assert(!
empty());
1099 __glibcxx_assert(!
empty());
1108 back() const noexcept
1110 __glibcxx_assert(!
empty());
1123 {
return this->
append(__str); }
1132 {
return this->
append(__s); }
1146 #if __cplusplus >= 201103L 1154 {
return this->
append(__l.begin(), __l.size()); }
1157 #if __cplusplus > 201402L 1165 {
return this->
append(__sv); }
1174 append(
const basic_string& __str)
1175 {
return _M_append(__str._M_data(), __str.size()); }
1191 append(
const basic_string& __str, size_type __pos, size_type __n)
1192 {
return _M_append(__str._M_data()
1193 + __str._M_check(__pos,
"basic_string::append"),
1194 __str._M_limit(__pos, __n)); }
1203 append(
const _CharT* __s, size_type __n)
1205 __glibcxx_requires_string_len(__s, __n);
1206 _M_check_length(size_type(0), __n,
"basic_string::append");
1207 return _M_append(__s, __n);
1216 append(
const _CharT* __s)
1218 __glibcxx_requires_string(__s);
1219 const size_type __n = traits_type::length(__s);
1220 _M_check_length(size_type(0), __n,
"basic_string::append");
1221 return _M_append(__s, __n);
1233 append(size_type __n, _CharT __c)
1234 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1236 #if __cplusplus >= 201103L 1243 append(initializer_list<_CharT> __l)
1244 {
return this->
append(__l.begin(), __l.size()); }
1255 #if __cplusplus >= 201103L 1256 template<
class _InputIterator,
1257 typename = std::_RequireInputIter<_InputIterator>>
1259 template<
class _InputIterator>
1262 append(_InputIterator __first, _InputIterator __last)
1265 #if __cplusplus > 201402L 1273 {
return this->
append(__sv.data(), __sv.size()); }
1282 template <
typename _Tp>
1283 _If_sv<_Tp, basic_string&>
1284 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1286 __sv_type __sv = __svt;
1287 return _M_append(__sv.data()
1288 + __sv._M_check(__pos,
"basic_string::append"),
1289 __sv._M_limit(__pos, __n));
1300 const size_type __size = this->
size();
1302 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1303 traits_type::assign(this->_M_data()[__size], __c);
1304 this->_M_set_length(__size + 1);
1313 assign(
const basic_string& __str)
1315 this->_M_assign(__str);
1319 #if __cplusplus >= 201103L 1329 assign(basic_string&& __str)
1330 noexcept(_Alloc_traits::_S_nothrow_move())
1334 return *
this = std::move(__str);
1352 assign(
const basic_string& __str, size_type __pos, size_type __n)
1353 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1354 + __str._M_check(__pos,
"basic_string::assign"),
1355 __str._M_limit(__pos, __n)); }
1368 assign(
const _CharT* __s, size_type __n)
1370 __glibcxx_requires_string_len(__s, __n);
1371 return _M_replace(size_type(0), this->
size(), __s, __n);
1384 assign(
const _CharT* __s)
1386 __glibcxx_requires_string(__s);
1387 return _M_replace(size_type(0), this->
size(), __s,
1388 traits_type::length(__s));
1401 assign(size_type __n, _CharT __c)
1402 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1412 #if __cplusplus >= 201103L 1413 template<
class _InputIterator,
1414 typename = std::_RequireInputIter<_InputIterator>>
1416 template<
class _InputIterator>
1419 assign(_InputIterator __first, _InputIterator __last)
1422 #if __cplusplus >= 201103L 1429 assign(initializer_list<_CharT> __l)
1430 {
return this->
assign(__l.begin(), __l.size()); }
1433 #if __cplusplus > 201402L 1441 {
return this->
assign(__sv.data(), __sv.size()); }
1450 template <
typename _Tp>
1451 _If_sv<_Tp, basic_string&>
1452 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1454 __sv_type __sv = __svt;
1455 return _M_replace(size_type(0), this->
size(), __sv.data()
1456 + __sv._M_check(__pos,
"basic_string::assign"),
1457 __sv._M_limit(__pos, __n));
1461 #if __cplusplus >= 201103L 1478 insert(const_iterator __p, size_type __n, _CharT __c)
1480 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1481 const size_type __pos = __p -
begin();
1482 this->
replace(__p, __p, __n, __c);
1483 return iterator(this->_M_data() + __pos);
1500 insert(iterator __p, size_type __n, _CharT __c)
1501 { this->
replace(__p, __p, __n, __c); }
1504 #if __cplusplus >= 201103L 1519 template<
class _InputIterator,
1520 typename = std::_RequireInputIter<_InputIterator>>
1522 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1524 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1525 const size_type __pos = __p -
begin();
1526 this->
replace(__p, __p, __beg, __end);
1527 return iterator(this->_M_data() + __pos);
1542 template<
class _InputIterator>
1544 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1545 { this->
replace(__p, __p, __beg, __end); }
1548 #if __cplusplus >= 201103L 1556 insert(iterator __p, initializer_list<_CharT> __l)
1558 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1559 this->
insert(__p -
begin(), __l.begin(), __l.size());
1576 insert(size_type __pos1,
const basic_string& __str)
1577 {
return this->
replace(__pos1, size_type(0),
1578 __str._M_data(), __str.size()); }
1599 insert(size_type __pos1,
const basic_string& __str,
1600 size_type __pos2, size_type __n)
1601 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1602 + __str._M_check(__pos2,
"basic_string::insert"),
1603 __str._M_limit(__pos2, __n)); }
1622 insert(size_type __pos,
const _CharT* __s, size_type __n)
1623 {
return this->
replace(__pos, size_type(0), __s, __n); }
1641 insert(size_type __pos,
const _CharT* __s)
1643 __glibcxx_requires_string(__s);
1644 return this->
replace(__pos, size_type(0), __s,
1645 traits_type::length(__s));
1665 insert(size_type __pos, size_type __n, _CharT __c)
1666 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1667 size_type(0), __n, __c); }
1683 insert(__const_iterator __p, _CharT __c)
1685 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1686 const size_type __pos = __p -
begin();
1687 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1688 return iterator(_M_data() + __pos);
1691 #if __cplusplus > 201402L 1699 insert(size_type __pos, __sv_type __sv)
1700 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
1711 template <
typename _Tp>
1712 _If_sv<_Tp, basic_string&>
1713 insert(size_type __pos1,
const _Tp& __svt,
1714 size_type __pos2, size_type __n = npos)
1716 __sv_type __sv = __svt;
1717 return this->
replace(__pos1, size_type(0), __sv.data()
1718 + __sv._M_check(__pos2,
"basic_string::insert"),
1719 __sv._M_limit(__pos2, __n));
1739 erase(size_type __pos = 0, size_type __n = npos)
1741 _M_check(__pos,
"basic_string::erase");
1743 this->_M_set_length(__pos);
1745 this->_M_erase(__pos, _M_limit(__pos, __n));
1758 erase(__const_iterator __position)
1760 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1761 && __position <
end());
1762 const size_type __pos = __position -
begin();
1763 this->_M_erase(__pos, size_type(1));
1764 return iterator(_M_data() + __pos);
1777 erase(__const_iterator __first, __const_iterator __last)
1779 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1780 && __last <=
end());
1781 const size_type __pos = __first -
begin();
1782 if (__last ==
end())
1783 this->_M_set_length(__pos);
1785 this->_M_erase(__pos, __last - __first);
1786 return iterator(this->_M_data() + __pos);
1789 #if __cplusplus >= 201103L 1798 __glibcxx_assert(!
empty());
1799 _M_erase(
size() - 1, 1);
1821 replace(size_type __pos, size_type __n,
const basic_string& __str)
1822 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1843 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1844 size_type __pos2, size_type __n2)
1845 {
return this->
replace(__pos1, __n1, __str._M_data()
1846 + __str._M_check(__pos2,
"basic_string::replace"),
1847 __str._M_limit(__pos2, __n2)); }
1868 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1871 __glibcxx_requires_string_len(__s, __n2);
1872 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1873 _M_limit(__pos, __n1), __s, __n2);
1893 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1895 __glibcxx_requires_string(__s);
1896 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1917 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1918 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1919 _M_limit(__pos, __n1), __n2, __c); }
1935 replace(__const_iterator __i1, __const_iterator __i2,
1936 const basic_string& __str)
1937 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1955 replace(__const_iterator __i1, __const_iterator __i2,
1956 const _CharT* __s, size_type __n)
1958 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1960 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1977 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1979 __glibcxx_requires_string(__s);
1980 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1998 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2001 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2003 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2021 #if __cplusplus >= 201103L 2022 template<
class _InputIterator,
2023 typename = std::_RequireInputIter<_InputIterator>>
2025 replace(const_iterator __i1, const_iterator __i2,
2026 _InputIterator __k1, _InputIterator __k2)
2028 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2030 __glibcxx_requires_valid_range(__k1, __k2);
2031 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2032 std::__false_type());
2035 template<
class _InputIterator>
2036 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2037 typename __enable_if_not_native_iterator<_InputIterator>::__type
2041 replace(iterator __i1, iterator __i2,
2042 _InputIterator __k1, _InputIterator __k2)
2044 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2046 __glibcxx_requires_valid_range(__k1, __k2);
2047 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2048 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2055 replace(__const_iterator __i1, __const_iterator __i2,
2056 _CharT* __k1, _CharT* __k2)
2058 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2060 __glibcxx_requires_valid_range(__k1, __k2);
2066 replace(__const_iterator __i1, __const_iterator __i2,
2067 const _CharT* __k1,
const _CharT* __k2)
2069 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2071 __glibcxx_requires_valid_range(__k1, __k2);
2077 replace(__const_iterator __i1, __const_iterator __i2,
2078 iterator __k1, iterator __k2)
2080 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2082 __glibcxx_requires_valid_range(__k1, __k2);
2084 __k1.base(), __k2 - __k1);
2088 replace(__const_iterator __i1, __const_iterator __i2,
2089 const_iterator __k1, const_iterator __k2)
2091 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2093 __glibcxx_requires_valid_range(__k1, __k2);
2095 __k1.base(), __k2 - __k1);
2098 #if __cplusplus >= 201103L 2113 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2114 initializer_list<_CharT> __l)
2115 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2118 #if __cplusplus > 201402L 2127 replace(size_type __pos, size_type __n, __sv_type __sv)
2128 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
2139 template <
typename _Tp>
2140 _If_sv<_Tp, basic_string&>
2141 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2142 size_type __pos2, size_type __n2 = npos)
2144 __sv_type __sv = __svt;
2145 return this->
replace(__pos1, __n1, __sv.data()
2146 + __sv._M_check(__pos2,
"basic_string::replace"),
2147 __sv._M_limit(__pos2, __n2));
2160 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
2161 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
2165 template<
class _Integer>
2167 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2168 _Integer __n, _Integer __val, __true_type)
2169 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2171 template<
class _InputIterator>
2173 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2174 _InputIterator __k1, _InputIterator __k2,
2178 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2182 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2183 const size_type __len2);
2186 _M_append(
const _CharT* __s, size_type __n);
2203 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2213 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2223 c_str() const _GLIBCXX_NOEXCEPT
2224 {
return _M_data(); }
2235 data() const _GLIBCXX_NOEXCEPT
2236 {
return _M_data(); }
2238 #if __cplusplus > 201402L 2247 {
return _M_data(); }
2255 {
return _M_get_allocator(); }
2270 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2284 find(
const basic_string& __str, size_type __pos = 0) const
2286 {
return this->
find(__str.data(), __pos, __str.size()); }
2288 #if __cplusplus > 201402L 2296 find(__sv_type __sv, size_type __pos = 0) const noexcept
2297 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2311 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2313 __glibcxx_requires_string(__s);
2314 return this->
find(__s, __pos, traits_type::length(__s));
2328 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2341 rfind(const basic_string& __str, size_type __pos = npos) const
2343 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2345 #if __cplusplus > 201402L 2353 rfind(__sv_type __sv, size_type __pos = npos) const noexcept
2354 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2370 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2384 rfind(
const _CharT* __s, size_type __pos = npos)
const 2386 __glibcxx_requires_string(__s);
2387 return this->
rfind(__s, __pos, traits_type::length(__s));
2401 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2415 find_first_of(const basic_string& __str, size_type __pos = 0) const
2417 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2419 #if __cplusplus > 201402L 2427 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2428 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2444 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2461 __glibcxx_requires_string(__s);
2462 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2478 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2479 {
return this->
find(__c, __pos); }
2493 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2495 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2497 #if __cplusplus > 201402L 2505 find_last_of(__sv_type __sv, size_type __pos = npos) const noexcept
2506 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2522 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2536 find_last_of(
const _CharT* __s, size_type __pos = npos) const
2539 __glibcxx_requires_string(__s);
2540 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2556 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2557 {
return this->
rfind(__c, __pos); }
2574 #if __cplusplus > 201402L 2600 size_type __n)
const _GLIBCXX_NOEXCEPT;
2616 __glibcxx_requires_string(__s);
2650 #if __cplusplus > 201402L 2676 size_type __n)
const _GLIBCXX_NOEXCEPT;
2692 __glibcxx_requires_string(__s);
2723 substr(size_type __pos = 0, size_type __n = npos)
const 2725 _M_check(__pos,
"basic_string::substr"), __n); }
2742 compare(
const basic_string& __str)
const 2744 const size_type __size = this->
size();
2745 const size_type __osize = __str.size();
2746 const size_type __len =
std::min(__size, __osize);
2748 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2750 __r = _S_compare(__size, __osize);
2754 #if __cplusplus > 201402L 2763 const size_type __size = this->
size();
2764 const size_type __osize = __sv.size();
2765 const size_type __len =
std::min(__size, __osize);
2767 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2769 __r = _S_compare(__size, __osize);
2781 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2782 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2793 template <
typename _Tp>
2795 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2796 size_type __pos2, size_type __n2 = npos)
const 2798 __sv_type __sv = __svt;
2799 return __sv_type(*
this)
2800 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2824 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2850 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2851 size_type __pos2, size_type __n2)
const;
2868 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2892 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2919 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2920 size_type __n2)
const;
2922 _GLIBCXX_END_NAMESPACE_CXX11
2923 #else // !_GLIBCXX_USE_CXX11_ABI 2988 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2991 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2995 typedef _Traits traits_type;
2996 typedef typename _Traits::char_type value_type;
2997 typedef _Alloc allocator_type;
2998 typedef typename _CharT_alloc_type::size_type size_type;
2999 typedef typename _CharT_alloc_type::difference_type difference_type;
3000 typedef typename _CharT_alloc_type::reference reference;
3001 typedef typename _CharT_alloc_type::const_reference const_reference;
3002 typedef typename _CharT_alloc_type::pointer pointer;
3003 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3004 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3005 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3027 size_type _M_length;
3028 size_type _M_capacity;
3029 _Atomic_word _M_refcount;
3032 struct _Rep : _Rep_base
3035 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3050 static const size_type _S_max_size;
3051 static const _CharT _S_terminal;
3055 static size_type _S_empty_rep_storage[];
3058 _S_empty_rep() _GLIBCXX_NOEXCEPT
3063 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3064 return *
reinterpret_cast<_Rep*
>(__p);
3068 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3070 #if defined(__GTHREADS) 3075 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3077 return this->_M_refcount < 0;
3082 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3084 #if defined(__GTHREADS) 3090 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3092 return this->_M_refcount > 0;
3097 _M_set_leaked() _GLIBCXX_NOEXCEPT
3098 { this->_M_refcount = -1; }
3101 _M_set_sharable() _GLIBCXX_NOEXCEPT
3102 { this->_M_refcount = 0; }
3105 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3107 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3108 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3111 this->_M_set_sharable();
3112 this->_M_length = __n;
3113 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3120 _M_refdata()
throw()
3121 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3124 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3126 return (!_M_is_leaked() && __alloc1 == __alloc2)
3127 ? _M_refcopy() : _M_clone(__alloc1);
3132 _S_create(size_type, size_type,
const _Alloc&);
3135 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3137 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3138 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3142 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3151 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3154 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3161 _M_destroy(
const _Alloc&)
throw();
3164 _M_refcopy()
throw()
3166 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3167 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3169 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3170 return _M_refdata();
3174 _M_clone(
const _Alloc&, size_type __res = 0);
3178 struct _Alloc_hider : _Alloc
3180 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3181 : _Alloc(__a), _M_p(__dat) { }
3191 static const size_type npos =
static_cast<size_type
>(-1);
3195 mutable _Alloc_hider _M_dataplus;
3198 _M_data() const _GLIBCXX_NOEXCEPT
3199 {
return _M_dataplus._M_p; }
3202 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3203 {
return (_M_dataplus._M_p = __p); }
3206 _M_rep()
const _GLIBCXX_NOEXCEPT
3207 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3212 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3213 {
return iterator(_M_data()); }
3216 _M_iend()
const _GLIBCXX_NOEXCEPT
3217 {
return iterator(_M_data() + this->
size()); }
3222 if (!_M_rep()->_M_is_leaked())
3227 _M_check(size_type __pos,
const char* __s)
const 3229 if (__pos > this->
size())
3230 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3231 "this->size() (which is %zu)"),
3232 __s, __pos, this->
size());
3237 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3240 __throw_length_error(__N(__s));
3245 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3247 const bool __testoff = __off < this->
size() - __pos;
3248 return __testoff ? __off : this->
size() - __pos;
3253 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3262 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3265 traits_type::assign(*__d, *__s);
3267 traits_type::copy(__d, __s, __n);
3271 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3274 traits_type::assign(*__d, *__s);
3276 traits_type::move(__d, __s, __n);
3280 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3283 traits_type::assign(*__d, __c);
3285 traits_type::assign(__d, __n, __c);
3290 template<
class _Iterator>
3292 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3294 for (; __k1 != __k2; ++__k1, (void)++__p)
3295 traits_type::assign(*__p, *__k1);
3299 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3300 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3303 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3305 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3308 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3309 { _M_copy(__p, __k1, __k2 - __k1); }
3312 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3314 { _M_copy(__p, __k1, __k2 - __k1); }
3317 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3319 const difference_type __d = difference_type(__n1 - __n2);
3321 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3322 return __gnu_cxx::__numeric_traits<int>::__max;
3323 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3324 return __gnu_cxx::__numeric_traits<int>::__min;
3330 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3336 _S_empty_rep() _GLIBCXX_NOEXCEPT
3337 {
return _Rep::_S_empty_rep(); }
3339 #if __cplusplus > 201402L 3341 typedef basic_string_view<_CharT, _Traits> __sv_type;
3343 template<
typename _Tp,
typename _Res>
3344 using _If_sv = enable_if_t<
3345 __and_<is_convertible<const _Tp&, __sv_type>,
3346 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3359 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3360 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3362 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3386 basic_string(
const basic_string& __str, size_type __pos,
3387 const _Alloc& __a = _Alloc());
3395 basic_string(
const basic_string& __str, size_type __pos,
3404 basic_string(
const basic_string& __str, size_type __pos,
3405 size_type __n,
const _Alloc& __a);
3417 const _Alloc& __a = _Alloc());
3423 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3430 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3432 #if __cplusplus >= 201103L 3441 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3444 : _M_dataplus(__str._M_dataplus)
3446 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3447 __str._M_data(_S_empty_rep()._M_refdata());
3449 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3467 template<
class _InputIterator>
3468 basic_string(_InputIterator __beg, _InputIterator __end,
3469 const _Alloc& __a = _Alloc());
3471 #if __cplusplus > 201402L 3479 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3480 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3481 const _Alloc& __a = _Alloc())
3490 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
3506 {
return this->
assign(__str); }
3514 {
return this->
assign(__s); }
3530 #if __cplusplus >= 201103L 3554 this->
assign(__l.begin(), __l.size());
3559 #if __cplusplus > 201402L 3564 template<
typename _Tp>
3565 _If_sv<_Tp, basic_string&>
3567 {
return this->
assign(__sv); }
3573 operator __sv_type()
const noexcept
3574 {
return __sv_type(
data(),
size()); }
3586 return iterator(_M_data());
3595 {
return const_iterator(_M_data()); }
3605 return iterator(_M_data() + this->
size());
3614 {
return const_iterator(_M_data() + this->
size()); }
3623 {
return reverse_iterator(this->
end()); }
3630 const_reverse_iterator
3632 {
return const_reverse_iterator(this->
end()); }
3641 {
return reverse_iterator(this->
begin()); }
3648 const_reverse_iterator
3650 {
return const_reverse_iterator(this->
begin()); }
3652 #if __cplusplus >= 201103L 3659 {
return const_iterator(this->_M_data()); }
3667 {
return const_iterator(this->_M_data() + this->
size()); }
3674 const_reverse_iterator
3676 {
return const_reverse_iterator(this->
end()); }
3683 const_reverse_iterator
3685 {
return const_reverse_iterator(this->
begin()); }
3694 {
return _M_rep()->_M_length; }
3700 {
return _M_rep()->_M_length; }
3705 {
return _Rep::_S_max_size; }
3718 resize(size_type __n, _CharT __c);
3732 { this->
resize(__n, _CharT()); }
3734 #if __cplusplus >= 201103L 3739 #if __cpp_exceptions 3757 {
return _M_rep()->_M_capacity; }
3777 reserve(size_type __res_arg = 0);
3782 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3786 if (_M_rep()->_M_is_shared())
3789 _M_data(_S_empty_rep()._M_refdata());
3792 _M_rep()->_M_set_length_and_sharable(0);
3798 { _M_mutate(0, this->
size(), 0); }
3807 {
return this->
size() == 0; }
3823 __glibcxx_assert(__pos <=
size());
3824 return _M_data()[__pos];
3842 __glibcxx_assert(__pos <=
size());
3844 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3846 return _M_data()[__pos];
3862 if (__n >= this->
size())
3863 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3864 "(which is %zu) >= this->size() " 3867 return _M_data()[__n];
3885 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3886 "(which is %zu) >= this->size() " 3890 return _M_data()[__n];
3893 #if __cplusplus >= 201103L 3901 __glibcxx_assert(!
empty());
3912 __glibcxx_assert(!
empty());
3923 __glibcxx_assert(!
empty());
3934 __glibcxx_assert(!
empty());
3947 {
return this->
append(__str); }
3956 {
return this->
append(__s); }
3970 #if __cplusplus >= 201103L 3978 {
return this->
append(__l.begin(), __l.size()); }
3981 #if __cplusplus > 201402L 3989 {
return this->
append(__sv); }
3998 append(
const basic_string& __str);
4014 append(
const basic_string& __str, size_type __pos, size_type __n);
4023 append(
const _CharT* __s, size_type __n);
4033 __glibcxx_requires_string(__s);
4034 return this->
append(__s, traits_type::length(__s));
4046 append(size_type __n, _CharT __c);
4048 #if __cplusplus >= 201103L 4056 {
return this->
append(__l.begin(), __l.size()); }
4067 template<
class _InputIterator>
4069 append(_InputIterator __first, _InputIterator __last)
4070 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4072 #if __cplusplus > 201402L 4080 {
return this->
append(__sv.data(), __sv.size()); }
4089 template <
typename _Tp>
4090 _If_sv<_Tp, basic_string&>
4091 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4093 __sv_type __sv = __svt;
4094 return append(__sv.data()
4095 + __sv._M_check(__pos,
"basic_string::append"),
4096 __sv._M_limit(__pos, __n));
4107 const size_type __len = 1 + this->
size();
4108 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4110 traits_type::assign(_M_data()[this->
size()], __c);
4111 _M_rep()->_M_set_length_and_sharable(__len);
4120 assign(
const basic_string& __str);
4122 #if __cplusplus >= 201103L 4154 assign(
const basic_string& __str, size_type __pos, size_type __n)
4155 {
return this->
assign(__str._M_data()
4156 + __str._M_check(__pos,
"basic_string::assign"),
4157 __str._M_limit(__pos, __n)); }
4170 assign(
const _CharT* __s, size_type __n);
4184 __glibcxx_requires_string(__s);
4185 return this->
assign(__s, traits_type::length(__s));
4199 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4209 template<
class _InputIterator>
4211 assign(_InputIterator __first, _InputIterator __last)
4212 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4214 #if __cplusplus >= 201103L 4222 {
return this->
assign(__l.begin(), __l.size()); }
4225 #if __cplusplus > 201402L 4233 {
return this->
assign(__sv.data(), __sv.size()); }
4242 template <
typename _Tp>
4243 _If_sv<_Tp, basic_string&>
4244 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4246 __sv_type __sv = __svt;
4247 return assign(__sv.data()
4248 + __sv._M_check(__pos,
"basic_string::assign"),
4249 __sv._M_limit(__pos, __n));
4267 insert(iterator __p, size_type __n, _CharT __c)
4268 { this->
replace(__p, __p, __n, __c); }
4282 template<
class _InputIterator>
4284 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4285 { this->
replace(__p, __p, __beg, __end); }
4287 #if __cplusplus >= 201103L 4297 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4298 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4315 insert(size_type __pos1,
const basic_string& __str)
4316 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4337 insert(size_type __pos1,
const basic_string& __str,
4338 size_type __pos2, size_type __n)
4339 {
return this->
insert(__pos1, __str._M_data()
4340 + __str._M_check(__pos2,
"basic_string::insert"),
4341 __str._M_limit(__pos2, __n)); }
4360 insert(size_type __pos,
const _CharT* __s, size_type __n);
4380 __glibcxx_requires_string(__s);
4381 return this->
insert(__pos, __s, traits_type::length(__s));
4401 insert(size_type __pos, size_type __n, _CharT __c)
4402 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4403 size_type(0), __n, __c); }
4421 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4422 const size_type __pos = __p - _M_ibegin();
4423 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4424 _M_rep()->_M_set_leaked();
4425 return iterator(_M_data() + __pos);
4428 #if __cplusplus > 201402L 4436 insert(size_type __pos, __sv_type __sv)
4437 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
4448 template <
typename _Tp>
4449 _If_sv<_Tp, basic_string&>
4450 insert(size_type __pos1,
const _Tp& __svt,
4451 size_type __pos2, size_type __n = npos)
4453 __sv_type __sv = __svt;
4454 return this->
replace(__pos1, size_type(0), __sv.data()
4455 + __sv._M_check(__pos2,
"basic_string::insert"),
4456 __sv._M_limit(__pos2, __n));
4476 erase(size_type __pos = 0, size_type __n = npos)
4478 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4479 _M_limit(__pos, __n), size_type(0));
4494 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4495 && __position < _M_iend());
4496 const size_type __pos = __position - _M_ibegin();
4497 _M_mutate(__pos, size_type(1), size_type(0));
4498 _M_rep()->_M_set_leaked();
4499 return iterator(_M_data() + __pos);
4512 erase(iterator __first, iterator __last);
4514 #if __cplusplus >= 201103L 4523 __glibcxx_assert(!
empty());
4546 replace(size_type __pos, size_type __n,
const basic_string& __str)
4547 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4568 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4569 size_type __pos2, size_type __n2)
4570 {
return this->
replace(__pos1, __n1, __str._M_data()
4571 + __str._M_check(__pos2,
"basic_string::replace"),
4572 __str._M_limit(__pos2, __n2)); }
4593 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4613 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4615 __glibcxx_requires_string(__s);
4616 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4637 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4638 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4639 _M_limit(__pos, __n1), __n2, __c); }
4655 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4656 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4674 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4676 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4677 && __i2 <= _M_iend());
4678 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4695 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4697 __glibcxx_requires_string(__s);
4698 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4716 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4718 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4719 && __i2 <= _M_iend());
4720 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4738 template<
class _InputIterator>
4741 _InputIterator __k1, _InputIterator __k2)
4743 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4744 && __i2 <= _M_iend());
4745 __glibcxx_requires_valid_range(__k1, __k2);
4746 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4747 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4753 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4755 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4756 && __i2 <= _M_iend());
4757 __glibcxx_requires_valid_range(__k1, __k2);
4758 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4763 replace(iterator __i1, iterator __i2,
4764 const _CharT* __k1,
const _CharT* __k2)
4766 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4767 && __i2 <= _M_iend());
4768 __glibcxx_requires_valid_range(__k1, __k2);
4769 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4774 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4776 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4777 && __i2 <= _M_iend());
4778 __glibcxx_requires_valid_range(__k1, __k2);
4779 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4780 __k1.base(), __k2 - __k1);
4784 replace(iterator __i1, iterator __i2,
4785 const_iterator __k1, const_iterator __k2)
4787 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4788 && __i2 <= _M_iend());
4789 __glibcxx_requires_valid_range(__k1, __k2);
4790 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4791 __k1.base(), __k2 - __k1);
4794 #if __cplusplus >= 201103L 4809 basic_string&
replace(iterator __i1, iterator __i2,
4811 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4814 #if __cplusplus > 201402L 4823 replace(size_type __pos, size_type __n, __sv_type __sv)
4824 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
4835 template <
typename _Tp>
4836 _If_sv<_Tp, basic_string&>
4837 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4838 size_type __pos2, size_type __n2 = npos)
4840 __sv_type __sv = __svt;
4841 return this->
replace(__pos1, __n1, __sv.data()
4842 + __sv._M_check(__pos2,
"basic_string::replace"),
4843 __sv._M_limit(__pos2, __n2));
4856 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
4857 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
4861 template<
class _Integer>
4863 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4864 _Integer __val, __true_type)
4865 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4867 template<
class _InputIterator>
4869 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4870 _InputIterator __k2, __false_type);
4873 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4877 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4882 template<
class _InIterator>
4884 _S_construct_aux(_InIterator __beg, _InIterator __end,
4885 const _Alloc& __a, __false_type)
4887 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4888 return _S_construct(__beg, __end, __a, _Tag());
4893 template<
class _Integer>
4895 _S_construct_aux(_Integer __beg, _Integer __end,
4896 const _Alloc& __a, __true_type)
4897 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4901 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4902 {
return _S_construct(__req, __c, __a); }
4904 template<
class _InIterator>
4906 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4908 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4909 return _S_construct_aux(__beg, __end, __a, _Integral());
4913 template<
class _InIterator>
4915 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4920 template<
class _FwdIterator>
4922 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4926 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4943 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4954 swap(basic_string& __s);
4965 {
return _M_data(); }
4977 {
return _M_data(); }
4979 #if __cplusplus > 201402L 4988 {
return _M_data(); }
4996 {
return _M_dataplus; }
5011 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5025 find(
const basic_string& __str, size_type __pos = 0) const
5027 {
return this->
find(__str.data(), __pos, __str.size()); }
5040 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5042 __glibcxx_requires_string(__s);
5043 return this->
find(__s, __pos, traits_type::length(__s));
5057 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5059 #if __cplusplus > 201402L 5067 find(__sv_type __sv, size_type __pos = 0)
const noexcept
5068 {
return this->
find(__sv.data(), __pos, __sv.size()); }
5082 rfind(
const basic_string& __str, size_type __pos = npos) const
5084 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5099 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5113 rfind(
const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
5115 __glibcxx_requires_string(__s);
5116 return this->
rfind(__s, __pos, traits_type::length(__s));
5130 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5132 #if __cplusplus > 201402L 5140 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
5141 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
5158 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5173 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5190 __glibcxx_requires_string(__s);
5191 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5208 {
return this->
find(__c, __pos); }
5210 #if __cplusplus > 201402L 5218 find_first_of(__sv_type __sv, size_type __pos = 0)
const noexcept
5219 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
5236 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5251 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5268 __glibcxx_requires_string(__s);
5269 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5286 {
return this->
rfind(__c, __pos); }
5288 #if __cplusplus > 201402L 5296 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
5297 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
5329 size_type __n)
const _GLIBCXX_NOEXCEPT;
5345 __glibcxx_requires_string(__s);
5363 #if __cplusplus > 201402L 5405 size_type __n)
const _GLIBCXX_NOEXCEPT;
5421 __glibcxx_requires_string(__s);
5439 #if __cplusplus > 201402L 5464 substr(size_type __pos = 0, size_type __n = npos)
const 5466 _M_check(__pos,
"basic_string::substr"), __n); }
5485 const size_type __size = this->
size();
5486 const size_type __osize = __str.size();
5487 const size_type __len =
std::min(__size, __osize);
5489 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5491 __r = _S_compare(__size, __osize);
5495 #if __cplusplus > 201402L 5504 const size_type __size = this->
size();
5505 const size_type __osize = __sv.size();
5506 const size_type __len =
std::min(__size, __osize);
5508 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5510 __r = _S_compare(__size, __osize);
5522 compare(size_type __pos, size_type __n, __sv_type __sv)
const 5523 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
5534 template <
typename _Tp>
5536 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5537 size_type __pos2, size_type __n2 = npos)
const 5539 __sv_type __sv = __svt;
5540 return __sv_type(*
this)
5541 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5565 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5591 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5592 size_type __pos2, size_type __n2)
const;
5609 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5633 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5660 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5661 size_type __n2)
const;
5663 # ifdef _GLIBCXX_TM_TS_INTERNAL 5665 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5668 ::_txnal_cow_string_c_str(
const void *that);
5670 ::_txnal_cow_string_D1(
void *that);
5672 ::_txnal_cow_string_D1_commit(
void *that);
5675 #endif // !_GLIBCXX_USE_CXX11_ABI 5684 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5690 __str.append(__rhs);
5700 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5711 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5721 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5724 const _CharT* __rhs)
5727 __str.append(__rhs);
5737 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5742 typedef typename __string_type::size_type __size_type;
5743 __string_type __str(__lhs);
5744 __str.append(__size_type(1), __rhs);
5748 #if __cplusplus >= 201103L 5749 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5753 {
return std::move(__lhs.append(__rhs)); }
5755 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5759 {
return std::move(__rhs.insert(0, __lhs)); }
5761 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5766 const auto __size = __lhs.size() + __rhs.size();
5767 const bool __cond = (__size > __lhs.capacity()
5768 && __size <= __rhs.capacity());
5769 return __cond ? std::move(__rhs.insert(0, __lhs))
5770 : std::move(__lhs.append(__rhs));
5773 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5777 {
return std::move(__rhs.insert(0, __lhs)); }
5779 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5783 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5785 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5788 const _CharT* __rhs)
5789 {
return std::move(__lhs.append(__rhs)); }
5791 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5795 {
return std::move(__lhs.append(1, __rhs)); }
5805 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5810 {
return __lhs.compare(__rhs) == 0; }
5812 template<
typename _CharT>
5814 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5817 {
return (__lhs.
size() == __rhs.
size()
5827 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5829 operator==(
const _CharT* __lhs,
5831 {
return __rhs.compare(__lhs) == 0; }
5839 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5842 const _CharT* __rhs)
5843 {
return __lhs.compare(__rhs) == 0; }
5852 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5857 {
return !(__lhs == __rhs); }
5865 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5867 operator!=(
const _CharT* __lhs,
5869 {
return !(__lhs == __rhs); }
5877 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5880 const _CharT* __rhs)
5881 {
return !(__lhs == __rhs); }
5890 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5892 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5895 {
return __lhs.
compare(__rhs) < 0; }
5903 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5905 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5906 const _CharT* __rhs)
5907 {
return __lhs.
compare(__rhs) < 0; }
5915 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5917 operator<(
const _CharT* __lhs,
5919 {
return __rhs.compare(__lhs) > 0; }
5928 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5933 {
return __lhs.compare(__rhs) > 0; }
5941 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5944 const _CharT* __rhs)
5945 {
return __lhs.compare(__rhs) > 0; }
5953 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5955 operator>(
const _CharT* __lhs,
5957 {
return __rhs.compare(__lhs) < 0; }
5966 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5968 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5971 {
return __lhs.
compare(__rhs) <= 0; }
5979 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5981 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5982 const _CharT* __rhs)
5983 {
return __lhs.
compare(__rhs) <= 0; }
5991 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5993 operator<=(
const _CharT* __lhs,
5995 {
return __rhs.compare(__lhs) >= 0; }
6004 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6009 {
return __lhs.compare(__rhs) >= 0; }
6017 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6020 const _CharT* __rhs)
6021 {
return __lhs.compare(__rhs) >= 0; }
6029 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6031 operator>=(
const _CharT* __lhs,
6033 {
return __rhs.compare(__lhs) <= 0; }
6042 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6046 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6047 { __lhs.swap(__rhs); }
6062 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6080 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6082 operator<<(basic_ostream<_CharT, _Traits>& __os,
6087 return __ostream_insert(__os, __str.
data(), __str.
size());
6103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6120 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6126 #if __cplusplus >= 201103L 6128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6147 #ifdef _GLIBCXX_USE_WCHAR_T 6154 _GLIBCXX_END_NAMESPACE_VERSION
6157 #if __cplusplus >= 201103L 6161 namespace std _GLIBCXX_VISIBILITY(default)
6163 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6164 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6166 #if _GLIBCXX_USE_C99_STDLIB 6169 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6170 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
6174 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6175 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
6178 inline unsigned long 6179 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6180 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
6184 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6185 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
6188 inline unsigned long long 6189 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6190 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
6195 stof(
const string& __str,
size_t* __idx = 0)
6196 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
6199 stod(
const string& __str,
size_t* __idx = 0)
6200 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
6203 stold(
const string& __str,
size_t* __idx = 0)
6204 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
6205 #endif // _GLIBCXX_USE_C99_STDLIB 6207 #if _GLIBCXX_USE_C99_STDIO 6212 to_string(
int __val)
6213 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6217 to_string(
unsigned __val)
6218 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6219 4 *
sizeof(unsigned),
6223 to_string(
long __val)
6224 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6228 to_string(
unsigned long __val)
6229 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6230 4 *
sizeof(
unsigned long),
6234 to_string(
long long __val)
6235 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6236 4 *
sizeof(
long long),
6240 to_string(
unsigned long long __val)
6241 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6242 4 *
sizeof(
unsigned long long),
6246 to_string(
float __val)
6249 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6250 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6255 to_string(
double __val)
6258 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6259 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6264 to_string(
long double __val)
6267 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6268 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6271 #endif // _GLIBCXX_USE_C99_STDIO 6273 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6275 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6276 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6280 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6281 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6284 inline unsigned long 6285 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6286 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6290 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6291 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6294 inline unsigned long long 6295 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6296 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6301 stof(
const wstring& __str,
size_t* __idx = 0)
6302 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6305 stod(
const wstring& __str,
size_t* __idx = 0)
6306 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6309 stold(
const wstring& __str,
size_t* __idx = 0)
6310 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6312 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6315 to_wstring(
int __val)
6316 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6320 to_wstring(
unsigned __val)
6321 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6322 4 *
sizeof(unsigned),
6326 to_wstring(
long __val)
6327 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6331 to_wstring(
unsigned long __val)
6332 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6333 4 *
sizeof(
unsigned long),
6337 to_wstring(
long long __val)
6338 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6339 4 *
sizeof(
long long),
6343 to_wstring(
unsigned long long __val)
6344 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6345 4 *
sizeof(
unsigned long long),
6349 to_wstring(
float __val)
6352 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6353 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6358 to_wstring(
double __val)
6361 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6362 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6367 to_wstring(
long double __val)
6370 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6371 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6374 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6375 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6377 _GLIBCXX_END_NAMESPACE_CXX11
6378 _GLIBCXX_END_NAMESPACE_VERSION
6383 #if __cplusplus >= 201103L 6387 namespace std _GLIBCXX_VISIBILITY(default)
6389 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6393 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6397 :
public __hash_base<size_t, string>
6400 operator()(
const string& __s)
const noexcept
6401 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6408 #ifdef _GLIBCXX_USE_WCHAR_T 6412 :
public __hash_base<size_t, wstring>
6415 operator()(
const wstring& __s)
const noexcept
6416 {
return std::_Hash_impl::hash(__s.
data(),
6417 __s.
length() *
sizeof(wchar_t)); }
6426 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6430 :
public __hash_base<size_t, u16string>
6433 operator()(
const u16string& __s)
const noexcept
6434 {
return std::_Hash_impl::hash(__s.
data(),
6435 __s.
length() *
sizeof(char16_t)); }
6445 :
public __hash_base<size_t, u32string>
6448 operator()(
const u32string& __s)
const noexcept
6449 {
return std::_Hash_impl::hash(__s.
data(),
6450 __s.
length() *
sizeof(char32_t)); }
6458 _GLIBCXX_END_NAMESPACE_VERSION
6460 #if __cplusplus > 201103L 6462 #define __cpp_lib_string_udls 201304 6464 inline namespace literals
6466 inline namespace string_literals
6468 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6470 _GLIBCXX_DEFAULT_ABI_TAG
6472 operator""s(
const char* __str,
size_t __len)
6475 #ifdef _GLIBCXX_USE_WCHAR_T 6476 _GLIBCXX_DEFAULT_ABI_TAG
6478 operator""s(
const wchar_t* __str,
size_t __len)
6482 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6483 _GLIBCXX_DEFAULT_ABI_TAG
6485 operator""s(
const char16_t* __str,
size_t __len)
6488 _GLIBCXX_DEFAULT_ABI_TAG
6490 operator""s(
const char32_t* __str,
size_t __len)
6494 _GLIBCXX_END_NAMESPACE_VERSION
6498 #endif // __cplusplus > 201103L size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
static const size_type npos
Value returned by various member functions when they fail.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string()
Default constructor creates an empty string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
Uniform interface to C++98 and C++11 allocators.
Uniform interface to all pointer-like types.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
size_type capacity() const noexcept
const_iterator cend() const noexcept
const_reverse_iterator crbegin() const noexcept
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
const_reference back() 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.
const _CharT * data() const noexcept
Return const pointer to contents.
Managing sequences of characters and character-like objects.
Template class basic_ostream.
int compare(const basic_string &__str) const
Compare to a string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_iterator cbegin() const noexcept
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_reverse_iterator rbegin() const noexcept
reverse_iterator rbegin()
bool empty() const noexcept
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
const_reference front() const noexcept
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
void push_back(_CharT __c)
Append a single character.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
iterator erase(iterator __position)
Remove one character.
ISO C++ entities toplevel namespace is std.
Template class basic_istream.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
const_reverse_iterator rend() const noexcept
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.
Basis for explicit traits specializations.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
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.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
char_type widen(char __c) const
Widens characters.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
reference at(size_type __n)
Provides access to the data contained in the string.
const_iterator begin() const noexcept
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
One of the comparison functors.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
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 substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_reverse_iterator crend() const noexcept
Forward iterators support a superset of input iterator operations.
void pop_back()
Remove the last character.
const_iterator end() const noexcept
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & operator+=(const _CharT *__s)
Append a C string.
Primary class template hash.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
~basic_string() noexcept
Destroy the string instance.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.