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 763 {
return this->
assign(__sv); }
769 operator __sv_type() const noexcept
770 {
return __sv_type(
data(),
size()); }
779 begin() _GLIBCXX_NOEXCEPT
780 {
return iterator(_M_data()); }
787 begin() const _GLIBCXX_NOEXCEPT
788 {
return const_iterator(_M_data()); }
795 end() _GLIBCXX_NOEXCEPT
796 {
return iterator(_M_data() + this->
size()); }
803 end() const _GLIBCXX_NOEXCEPT
804 {
return const_iterator(_M_data() + this->
size()); }
812 rbegin() _GLIBCXX_NOEXCEPT
813 {
return reverse_iterator(this->
end()); }
820 const_reverse_iterator
821 rbegin() const _GLIBCXX_NOEXCEPT
822 {
return const_reverse_iterator(this->
end()); }
830 rend() _GLIBCXX_NOEXCEPT
831 {
return reverse_iterator(this->
begin()); }
838 const_reverse_iterator
839 rend() const _GLIBCXX_NOEXCEPT
840 {
return const_reverse_iterator(this->
begin()); }
842 #if __cplusplus >= 201103L 849 {
return const_iterator(this->_M_data()); }
856 cend() const noexcept
857 {
return const_iterator(this->_M_data() + this->
size()); }
864 const_reverse_iterator
866 {
return const_reverse_iterator(this->
end()); }
873 const_reverse_iterator
874 crend() const noexcept
875 {
return const_reverse_iterator(this->
begin()); }
883 size() const _GLIBCXX_NOEXCEPT
884 {
return _M_string_length; }
889 length() const _GLIBCXX_NOEXCEPT
890 {
return _M_string_length; }
895 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
908 resize(size_type __n, _CharT __c);
922 { this->
resize(__n, _CharT()); }
924 #if __cplusplus >= 201103L 948 return _M_is_local() ? size_type(_S_local_capacity)
949 : _M_allocated_capacity;
970 reserve(size_type __res_arg = 0);
976 clear() _GLIBCXX_NOEXCEPT
977 { _M_set_length(0); }
984 empty() const _GLIBCXX_NOEXCEPT
985 {
return this->
size() == 0; }
999 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1001 __glibcxx_assert(__pos <=
size());
1002 return _M_data()[__pos];
1020 __glibcxx_assert(__pos <=
size());
1022 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1023 return _M_data()[__pos];
1037 at(size_type __n)
const 1039 if (__n >= this->
size())
1040 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1041 "(which is %zu) >= this->size() " 1044 return _M_data()[__n];
1061 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1062 "(which is %zu) >= this->size() " 1065 return _M_data()[__n];
1068 #if __cplusplus >= 201103L 1076 __glibcxx_assert(!
empty());
1085 front() const noexcept
1087 __glibcxx_assert(!
empty());
1098 __glibcxx_assert(!
empty());
1107 back() const noexcept
1109 __glibcxx_assert(!
empty());
1122 {
return this->
append(__str); }
1131 {
return this->
append(__s); }
1145 #if __cplusplus >= 201103L 1153 {
return this->
append(__l.begin(), __l.size()); }
1156 #if __cplusplus > 201402L 1164 {
return this->
append(__sv); }
1173 append(
const basic_string& __str)
1174 {
return _M_append(__str._M_data(), __str.size()); }
1190 append(
const basic_string& __str, size_type __pos, size_type __n)
1191 {
return _M_append(__str._M_data()
1192 + __str._M_check(__pos,
"basic_string::append"),
1193 __str._M_limit(__pos, __n)); }
1202 append(
const _CharT* __s, size_type __n)
1204 __glibcxx_requires_string_len(__s, __n);
1205 _M_check_length(size_type(0), __n,
"basic_string::append");
1206 return _M_append(__s, __n);
1215 append(
const _CharT* __s)
1217 __glibcxx_requires_string(__s);
1218 const size_type __n = traits_type::length(__s);
1219 _M_check_length(size_type(0), __n,
"basic_string::append");
1220 return _M_append(__s, __n);
1232 append(size_type __n, _CharT __c)
1233 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1235 #if __cplusplus >= 201103L 1242 append(initializer_list<_CharT> __l)
1243 {
return this->
append(__l.begin(), __l.size()); }
1254 #if __cplusplus >= 201103L 1255 template<
class _InputIterator,
1256 typename = std::_RequireInputIter<_InputIterator>>
1258 template<
class _InputIterator>
1261 append(_InputIterator __first, _InputIterator __last)
1264 #if __cplusplus > 201402L 1272 {
return this->
append(__sv.data(), __sv.size()); }
1281 template <
typename _Tp>
1282 _If_sv<_Tp, basic_string&>
1283 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1285 __sv_type __sv = __svt;
1286 return _M_append(__sv.data()
1287 + __sv._M_check(__pos,
"basic_string::append"),
1288 __sv._M_limit(__pos, __n));
1299 const size_type __size = this->
size();
1301 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1302 traits_type::assign(this->_M_data()[__size], __c);
1303 this->_M_set_length(__size + 1);
1312 assign(
const basic_string& __str)
1314 this->_M_assign(__str);
1318 #if __cplusplus >= 201103L 1328 assign(basic_string&& __str)
1329 noexcept(_Alloc_traits::_S_nothrow_move())
1333 return *
this = std::move(__str);
1351 assign(
const basic_string& __str, size_type __pos, size_type __n)
1352 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1353 + __str._M_check(__pos,
"basic_string::assign"),
1354 __str._M_limit(__pos, __n)); }
1367 assign(
const _CharT* __s, size_type __n)
1369 __glibcxx_requires_string_len(__s, __n);
1370 return _M_replace(size_type(0), this->
size(), __s, __n);
1383 assign(
const _CharT* __s)
1385 __glibcxx_requires_string(__s);
1386 return _M_replace(size_type(0), this->
size(), __s,
1387 traits_type::length(__s));
1400 assign(size_type __n, _CharT __c)
1401 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1411 #if __cplusplus >= 201103L 1412 template<
class _InputIterator,
1413 typename = std::_RequireInputIter<_InputIterator>>
1415 template<
class _InputIterator>
1418 assign(_InputIterator __first, _InputIterator __last)
1421 #if __cplusplus >= 201103L 1428 assign(initializer_list<_CharT> __l)
1429 {
return this->
assign(__l.begin(), __l.size()); }
1432 #if __cplusplus > 201402L 1440 {
return this->
assign(__sv.data(), __sv.size()); }
1449 template <
typename _Tp>
1450 _If_sv<_Tp, basic_string&>
1451 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1453 __sv_type __sv = __svt;
1454 return _M_replace(size_type(0), this->
size(), __sv.data()
1455 + __sv._M_check(__pos,
"basic_string::assign"),
1456 __sv._M_limit(__pos, __n));
1460 #if __cplusplus >= 201103L 1477 insert(const_iterator __p, size_type __n, _CharT __c)
1479 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1480 const size_type __pos = __p -
begin();
1481 this->
replace(__p, __p, __n, __c);
1482 return iterator(this->_M_data() + __pos);
1499 insert(iterator __p, size_type __n, _CharT __c)
1500 { this->
replace(__p, __p, __n, __c); }
1503 #if __cplusplus >= 201103L 1518 template<
class _InputIterator,
1519 typename = std::_RequireInputIter<_InputIterator>>
1521 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1523 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1524 const size_type __pos = __p -
begin();
1525 this->
replace(__p, __p, __beg, __end);
1526 return iterator(this->_M_data() + __pos);
1541 template<
class _InputIterator>
1543 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1544 { this->
replace(__p, __p, __beg, __end); }
1547 #if __cplusplus >= 201103L 1555 insert(iterator __p, initializer_list<_CharT> __l)
1557 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1558 this->
insert(__p -
begin(), __l.begin(), __l.size());
1575 insert(size_type __pos1,
const basic_string& __str)
1576 {
return this->
replace(__pos1, size_type(0),
1577 __str._M_data(), __str.size()); }
1598 insert(size_type __pos1,
const basic_string& __str,
1599 size_type __pos2, size_type __n)
1600 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1601 + __str._M_check(__pos2,
"basic_string::insert"),
1602 __str._M_limit(__pos2, __n)); }
1621 insert(size_type __pos,
const _CharT* __s, size_type __n)
1622 {
return this->
replace(__pos, size_type(0), __s, __n); }
1640 insert(size_type __pos,
const _CharT* __s)
1642 __glibcxx_requires_string(__s);
1643 return this->
replace(__pos, size_type(0), __s,
1644 traits_type::length(__s));
1664 insert(size_type __pos, size_type __n, _CharT __c)
1665 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1666 size_type(0), __n, __c); }
1682 insert(__const_iterator __p, _CharT __c)
1684 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1685 const size_type __pos = __p -
begin();
1686 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1687 return iterator(_M_data() + __pos);
1690 #if __cplusplus > 201402L 1698 insert(size_type __pos, __sv_type __sv)
1699 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
1710 template <
typename _Tp>
1711 _If_sv<_Tp, basic_string&>
1712 insert(size_type __pos1,
const _Tp& __svt,
1713 size_type __pos2, size_type __n = npos)
1715 __sv_type __sv = __svt;
1716 return this->
replace(__pos1, size_type(0), __sv.data()
1717 + __sv._M_check(__pos2,
"basic_string::insert"),
1718 __sv._M_limit(__pos2, __n));
1738 erase(size_type __pos = 0, size_type __n = npos)
1740 _M_check(__pos,
"basic_string::erase");
1742 this->_M_set_length(__pos);
1744 this->_M_erase(__pos, _M_limit(__pos, __n));
1757 erase(__const_iterator __position)
1759 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1760 && __position <
end());
1761 const size_type __pos = __position -
begin();
1762 this->_M_erase(__pos, size_type(1));
1763 return iterator(_M_data() + __pos);
1776 erase(__const_iterator __first, __const_iterator __last)
1778 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1779 && __last <=
end());
1780 const size_type __pos = __first -
begin();
1781 if (__last ==
end())
1782 this->_M_set_length(__pos);
1784 this->_M_erase(__pos, __last - __first);
1785 return iterator(this->_M_data() + __pos);
1788 #if __cplusplus >= 201103L 1797 __glibcxx_assert(!
empty());
1798 _M_erase(
size() - 1, 1);
1820 replace(size_type __pos, size_type __n,
const basic_string& __str)
1821 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1842 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1843 size_type __pos2, size_type __n2)
1844 {
return this->
replace(__pos1, __n1, __str._M_data()
1845 + __str._M_check(__pos2,
"basic_string::replace"),
1846 __str._M_limit(__pos2, __n2)); }
1867 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1870 __glibcxx_requires_string_len(__s, __n2);
1871 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1872 _M_limit(__pos, __n1), __s, __n2);
1892 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1894 __glibcxx_requires_string(__s);
1895 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1916 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1917 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1918 _M_limit(__pos, __n1), __n2, __c); }
1934 replace(__const_iterator __i1, __const_iterator __i2,
1935 const basic_string& __str)
1936 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1954 replace(__const_iterator __i1, __const_iterator __i2,
1955 const _CharT* __s, size_type __n)
1957 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1959 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1976 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1978 __glibcxx_requires_string(__s);
1979 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1997 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2000 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2002 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2020 #if __cplusplus >= 201103L 2021 template<
class _InputIterator,
2022 typename = std::_RequireInputIter<_InputIterator>>
2024 replace(const_iterator __i1, const_iterator __i2,
2025 _InputIterator __k1, _InputIterator __k2)
2027 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2029 __glibcxx_requires_valid_range(__k1, __k2);
2030 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2031 std::__false_type());
2034 template<
class _InputIterator>
2035 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2036 typename __enable_if_not_native_iterator<_InputIterator>::__type
2040 replace(iterator __i1, iterator __i2,
2041 _InputIterator __k1, _InputIterator __k2)
2043 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2045 __glibcxx_requires_valid_range(__k1, __k2);
2046 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2047 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2054 replace(__const_iterator __i1, __const_iterator __i2,
2055 _CharT* __k1, _CharT* __k2)
2057 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2059 __glibcxx_requires_valid_range(__k1, __k2);
2065 replace(__const_iterator __i1, __const_iterator __i2,
2066 const _CharT* __k1,
const _CharT* __k2)
2068 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2070 __glibcxx_requires_valid_range(__k1, __k2);
2076 replace(__const_iterator __i1, __const_iterator __i2,
2077 iterator __k1, iterator __k2)
2079 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2081 __glibcxx_requires_valid_range(__k1, __k2);
2083 __k1.base(), __k2 - __k1);
2087 replace(__const_iterator __i1, __const_iterator __i2,
2088 const_iterator __k1, const_iterator __k2)
2090 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2092 __glibcxx_requires_valid_range(__k1, __k2);
2094 __k1.base(), __k2 - __k1);
2097 #if __cplusplus >= 201103L 2112 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2113 initializer_list<_CharT> __l)
2114 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2117 #if __cplusplus > 201402L 2126 replace(size_type __pos, size_type __n, __sv_type __sv)
2127 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
2138 template <
typename _Tp>
2139 _If_sv<_Tp, basic_string&>
2140 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2141 size_type __pos2, size_type __n2 = npos)
2143 __sv_type __sv = __svt;
2144 return this->
replace(__pos1, __n1, __sv.data()
2145 + __sv._M_check(__pos2,
"basic_string::replace"),
2146 __sv._M_limit(__pos2, __n2));
2159 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
2160 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
2164 template<
class _Integer>
2166 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2167 _Integer __n, _Integer __val, __true_type)
2168 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2170 template<
class _InputIterator>
2172 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2173 _InputIterator __k1, _InputIterator __k2,
2177 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2181 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2182 const size_type __len2);
2185 _M_append(
const _CharT* __s, size_type __n);
2202 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2212 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2222 c_str() const _GLIBCXX_NOEXCEPT
2223 {
return _M_data(); }
2234 data() const _GLIBCXX_NOEXCEPT
2235 {
return _M_data(); }
2237 #if __cplusplus > 201402L 2246 {
return _M_data(); }
2254 {
return _M_get_allocator(); }
2269 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2283 find(
const basic_string& __str, size_type __pos = 0) const
2285 {
return this->
find(__str.data(), __pos, __str.size()); }
2287 #if __cplusplus > 201402L 2295 find(__sv_type __sv, size_type __pos = 0) const noexcept
2296 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2310 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2312 __glibcxx_requires_string(__s);
2313 return this->
find(__s, __pos, traits_type::length(__s));
2327 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2340 rfind(const basic_string& __str, size_type __pos = npos) const
2342 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2344 #if __cplusplus > 201402L 2352 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
2353 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2369 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2383 rfind(
const _CharT* __s, size_type __pos = npos)
const 2385 __glibcxx_requires_string(__s);
2386 return this->
rfind(__s, __pos, traits_type::length(__s));
2400 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
2414 find_first_of(
const basic_string& __str, size_type __pos = 0) const
2416 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2418 #if __cplusplus > 201402L 2426 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2427 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2443 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2460 __glibcxx_requires_string(__s);
2461 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2477 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2478 {
return this->
find(__c, __pos); }
2492 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 2494 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2496 #if __cplusplus > 201402L 2504 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
2505 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2521 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2535 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2538 __glibcxx_requires_string(__s);
2539 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2555 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
2556 {
return this->
rfind(__c, __pos); }
2573 #if __cplusplus > 201402L 2599 size_type __n)
const _GLIBCXX_NOEXCEPT;
2615 __glibcxx_requires_string(__s);
2649 #if __cplusplus > 201402L 2675 size_type __n)
const _GLIBCXX_NOEXCEPT;
2691 __glibcxx_requires_string(__s);
2722 substr(size_type __pos = 0, size_type __n = npos)
const 2724 _M_check(__pos,
"basic_string::substr"), __n); }
2741 compare(
const basic_string& __str)
const 2743 const size_type __size = this->
size();
2744 const size_type __osize = __str.size();
2745 const size_type __len =
std::min(__size, __osize);
2747 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2749 __r = _S_compare(__size, __osize);
2753 #if __cplusplus > 201402L 2762 const size_type __size = this->
size();
2763 const size_type __osize = __sv.size();
2764 const size_type __len =
std::min(__size, __osize);
2766 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2768 __r = _S_compare(__size, __osize);
2780 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2781 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2792 template <
typename _Tp>
2794 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2795 size_type __pos2, size_type __n2 = npos)
const 2797 __sv_type __sv = __svt;
2798 return __sv_type(*
this)
2799 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2823 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2849 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2850 size_type __pos2, size_type __n2)
const;
2867 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2891 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2918 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2919 size_type __n2)
const;
2921 _GLIBCXX_END_NAMESPACE_CXX11
2922 #else // !_GLIBCXX_USE_CXX11_ABI 2987 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2990 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2994 typedef _Traits traits_type;
2995 typedef typename _Traits::char_type value_type;
2996 typedef _Alloc allocator_type;
2997 typedef typename _CharT_alloc_type::size_type size_type;
2998 typedef typename _CharT_alloc_type::difference_type difference_type;
2999 typedef typename _CharT_alloc_type::reference reference;
3000 typedef typename _CharT_alloc_type::const_reference const_reference;
3001 typedef typename _CharT_alloc_type::pointer pointer;
3002 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3003 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3004 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3026 size_type _M_length;
3027 size_type _M_capacity;
3028 _Atomic_word _M_refcount;
3031 struct _Rep : _Rep_base
3034 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3049 static const size_type _S_max_size;
3050 static const _CharT _S_terminal;
3054 static size_type _S_empty_rep_storage[];
3057 _S_empty_rep() _GLIBCXX_NOEXCEPT
3062 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3063 return *
reinterpret_cast<_Rep*
>(__p);
3067 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3069 #if defined(__GTHREADS) 3074 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3076 return this->_M_refcount < 0;
3081 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3083 #if defined(__GTHREADS) 3089 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3091 return this->_M_refcount > 0;
3096 _M_set_leaked() _GLIBCXX_NOEXCEPT
3097 { this->_M_refcount = -1; }
3100 _M_set_sharable() _GLIBCXX_NOEXCEPT
3101 { this->_M_refcount = 0; }
3104 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3106 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3107 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3110 this->_M_set_sharable();
3111 this->_M_length = __n;
3112 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3119 _M_refdata()
throw()
3120 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3123 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3125 return (!_M_is_leaked() && __alloc1 == __alloc2)
3126 ? _M_refcopy() : _M_clone(__alloc1);
3131 _S_create(size_type, size_type,
const _Alloc&);
3134 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3136 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3137 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3141 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3150 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3153 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3160 _M_destroy(
const _Alloc&)
throw();
3163 _M_refcopy()
throw()
3165 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3166 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3168 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3169 return _M_refdata();
3173 _M_clone(
const _Alloc&, size_type __res = 0);
3177 struct _Alloc_hider : _Alloc
3179 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3180 : _Alloc(__a), _M_p(__dat) { }
3190 static const size_type npos =
static_cast<size_type
>(-1);
3194 mutable _Alloc_hider _M_dataplus;
3197 _M_data() const _GLIBCXX_NOEXCEPT
3198 {
return _M_dataplus._M_p; }
3201 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3202 {
return (_M_dataplus._M_p = __p); }
3205 _M_rep()
const _GLIBCXX_NOEXCEPT
3206 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3211 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3212 {
return iterator(_M_data()); }
3215 _M_iend()
const _GLIBCXX_NOEXCEPT
3216 {
return iterator(_M_data() + this->
size()); }
3221 if (!_M_rep()->_M_is_leaked())
3226 _M_check(size_type __pos,
const char* __s)
const 3228 if (__pos > this->
size())
3229 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3230 "this->size() (which is %zu)"),
3231 __s, __pos, this->
size());
3236 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3239 __throw_length_error(__N(__s));
3244 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3246 const bool __testoff = __off < this->
size() - __pos;
3247 return __testoff ? __off : this->
size() - __pos;
3252 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3261 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3264 traits_type::assign(*__d, *__s);
3266 traits_type::copy(__d, __s, __n);
3270 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3273 traits_type::assign(*__d, *__s);
3275 traits_type::move(__d, __s, __n);
3279 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3282 traits_type::assign(*__d, __c);
3284 traits_type::assign(__d, __n, __c);
3289 template<
class _Iterator>
3291 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3293 for (; __k1 != __k2; ++__k1, (void)++__p)
3294 traits_type::assign(*__p, *__k1);
3298 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3299 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3302 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3304 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3307 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3308 { _M_copy(__p, __k1, __k2 - __k1); }
3311 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3313 { _M_copy(__p, __k1, __k2 - __k1); }
3316 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3318 const difference_type __d = difference_type(__n1 - __n2);
3320 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3321 return __gnu_cxx::__numeric_traits<int>::__max;
3322 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3323 return __gnu_cxx::__numeric_traits<int>::__min;
3329 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3335 _S_empty_rep() _GLIBCXX_NOEXCEPT
3336 {
return _Rep::_S_empty_rep(); }
3338 #if __cplusplus > 201402L 3340 typedef basic_string_view<_CharT, _Traits> __sv_type;
3342 template<
typename _Tp,
typename _Res>
3343 using _If_sv = enable_if_t<
3344 __and_<is_convertible<const _Tp&, __sv_type>,
3345 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3358 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3359 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3361 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3385 basic_string(
const basic_string& __str, size_type __pos,
3386 const _Alloc& __a = _Alloc());
3394 basic_string(
const basic_string& __str, size_type __pos,
3403 basic_string(
const basic_string& __str, size_type __pos,
3404 size_type __n,
const _Alloc& __a);
3416 const _Alloc& __a = _Alloc());
3422 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3429 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3431 #if __cplusplus >= 201103L 3440 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3443 : _M_dataplus(__str._M_dataplus)
3445 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3446 __str._M_data(_S_empty_rep()._M_refdata());
3448 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3466 template<
class _InputIterator>
3467 basic_string(_InputIterator __beg, _InputIterator __end,
3468 const _Alloc& __a = _Alloc());
3470 #if __cplusplus > 201402L 3478 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3479 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3480 const _Alloc& __a = _Alloc())
3489 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
3505 {
return this->
assign(__str); }
3513 {
return this->
assign(__s); }
3529 #if __cplusplus >= 201103L 3553 this->
assign(__l.begin(), __l.size());
3558 #if __cplusplus > 201402L 3565 {
return this->
assign(__sv); }
3571 operator __sv_type()
const noexcept
3572 {
return __sv_type(
data(),
size()); }
3584 return iterator(_M_data());
3593 {
return const_iterator(_M_data()); }
3603 return iterator(_M_data() + this->
size());
3612 {
return const_iterator(_M_data() + this->
size()); }
3621 {
return reverse_iterator(this->
end()); }
3628 const_reverse_iterator
3630 {
return const_reverse_iterator(this->
end()); }
3639 {
return reverse_iterator(this->
begin()); }
3646 const_reverse_iterator
3648 {
return const_reverse_iterator(this->
begin()); }
3650 #if __cplusplus >= 201103L 3657 {
return const_iterator(this->_M_data()); }
3665 {
return const_iterator(this->_M_data() + this->
size()); }
3672 const_reverse_iterator
3674 {
return const_reverse_iterator(this->
end()); }
3681 const_reverse_iterator
3683 {
return const_reverse_iterator(this->
begin()); }
3692 {
return _M_rep()->_M_length; }
3698 {
return _M_rep()->_M_length; }
3703 {
return _Rep::_S_max_size; }
3716 resize(size_type __n, _CharT __c);
3730 { this->
resize(__n, _CharT()); }
3732 #if __cplusplus >= 201103L 3737 #if __cpp_exceptions 3755 {
return _M_rep()->_M_capacity; }
3775 reserve(size_type __res_arg = 0);
3780 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3784 if (_M_rep()->_M_is_shared())
3787 _M_data(_S_empty_rep()._M_refdata());
3790 _M_rep()->_M_set_length_and_sharable(0);
3796 { _M_mutate(0, this->
size(), 0); }
3805 {
return this->
size() == 0; }
3821 __glibcxx_assert(__pos <=
size());
3822 return _M_data()[__pos];
3840 __glibcxx_assert(__pos <=
size());
3842 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3844 return _M_data()[__pos];
3860 if (__n >= this->
size())
3861 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3862 "(which is %zu) >= this->size() " 3865 return _M_data()[__n];
3883 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3884 "(which is %zu) >= this->size() " 3888 return _M_data()[__n];
3891 #if __cplusplus >= 201103L 3899 __glibcxx_assert(!
empty());
3910 __glibcxx_assert(!
empty());
3921 __glibcxx_assert(!
empty());
3932 __glibcxx_assert(!
empty());
3945 {
return this->
append(__str); }
3954 {
return this->
append(__s); }
3968 #if __cplusplus >= 201103L 3976 {
return this->
append(__l.begin(), __l.size()); }
3979 #if __cplusplus > 201402L 3987 {
return this->
append(__sv); }
3996 append(
const basic_string& __str);
4012 append(
const basic_string& __str, size_type __pos, size_type __n);
4021 append(
const _CharT* __s, size_type __n);
4031 __glibcxx_requires_string(__s);
4032 return this->
append(__s, traits_type::length(__s));
4044 append(size_type __n, _CharT __c);
4046 #if __cplusplus >= 201103L 4054 {
return this->
append(__l.begin(), __l.size()); }
4065 template<
class _InputIterator>
4067 append(_InputIterator __first, _InputIterator __last)
4068 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4070 #if __cplusplus > 201402L 4078 {
return this->
append(__sv.data(), __sv.size()); }
4087 template <
typename _Tp>
4088 _If_sv<_Tp, basic_string&>
4089 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4091 __sv_type __sv = __svt;
4092 return append(__sv.data()
4093 + __sv._M_check(__pos,
"basic_string::append"),
4094 __sv._M_limit(__pos, __n));
4105 const size_type __len = 1 + this->
size();
4106 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4108 traits_type::assign(_M_data()[this->
size()], __c);
4109 _M_rep()->_M_set_length_and_sharable(__len);
4118 assign(
const basic_string& __str);
4120 #if __cplusplus >= 201103L 4152 assign(
const basic_string& __str, size_type __pos, size_type __n)
4153 {
return this->
assign(__str._M_data()
4154 + __str._M_check(__pos,
"basic_string::assign"),
4155 __str._M_limit(__pos, __n)); }
4168 assign(
const _CharT* __s, size_type __n);
4182 __glibcxx_requires_string(__s);
4183 return this->
assign(__s, traits_type::length(__s));
4197 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4207 template<
class _InputIterator>
4209 assign(_InputIterator __first, _InputIterator __last)
4210 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4212 #if __cplusplus >= 201103L 4220 {
return this->
assign(__l.begin(), __l.size()); }
4223 #if __cplusplus > 201402L 4231 {
return this->
assign(__sv.data(), __sv.size()); }
4240 template <
typename _Tp>
4241 _If_sv<_Tp, basic_string&>
4242 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4244 __sv_type __sv = __svt;
4245 return assign(__sv.data()
4246 + __sv._M_check(__pos,
"basic_string::assign"),
4247 __sv._M_limit(__pos, __n));
4265 insert(iterator __p, size_type __n, _CharT __c)
4266 { this->
replace(__p, __p, __n, __c); }
4280 template<
class _InputIterator>
4282 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4283 { this->
replace(__p, __p, __beg, __end); }
4285 #if __cplusplus >= 201103L 4295 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4296 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4313 insert(size_type __pos1,
const basic_string& __str)
4314 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4335 insert(size_type __pos1,
const basic_string& __str,
4336 size_type __pos2, size_type __n)
4337 {
return this->
insert(__pos1, __str._M_data()
4338 + __str._M_check(__pos2,
"basic_string::insert"),
4339 __str._M_limit(__pos2, __n)); }
4358 insert(size_type __pos,
const _CharT* __s, size_type __n);
4378 __glibcxx_requires_string(__s);
4379 return this->
insert(__pos, __s, traits_type::length(__s));
4399 insert(size_type __pos, size_type __n, _CharT __c)
4400 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4401 size_type(0), __n, __c); }
4419 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4420 const size_type __pos = __p - _M_ibegin();
4421 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4422 _M_rep()->_M_set_leaked();
4423 return iterator(_M_data() + __pos);
4426 #if __cplusplus > 201402L 4434 insert(size_type __pos, __sv_type __sv)
4435 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
4446 template <
typename _Tp>
4447 _If_sv<_Tp, basic_string&>
4448 insert(size_type __pos1,
const _Tp& __svt,
4449 size_type __pos2, size_type __n = npos)
4451 __sv_type __sv = __svt;
4452 return this->
replace(__pos1, size_type(0), __sv.data()
4453 + __sv._M_check(__pos2,
"basic_string::insert"),
4454 __sv._M_limit(__pos2, __n));
4474 erase(size_type __pos = 0, size_type __n = npos)
4476 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4477 _M_limit(__pos, __n), size_type(0));
4492 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4493 && __position < _M_iend());
4494 const size_type __pos = __position - _M_ibegin();
4495 _M_mutate(__pos, size_type(1), size_type(0));
4496 _M_rep()->_M_set_leaked();
4497 return iterator(_M_data() + __pos);
4510 erase(iterator __first, iterator __last);
4512 #if __cplusplus >= 201103L 4521 __glibcxx_assert(!
empty());
4544 replace(size_type __pos, size_type __n,
const basic_string& __str)
4545 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4566 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4567 size_type __pos2, size_type __n2)
4568 {
return this->
replace(__pos1, __n1, __str._M_data()
4569 + __str._M_check(__pos2,
"basic_string::replace"),
4570 __str._M_limit(__pos2, __n2)); }
4591 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4611 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4613 __glibcxx_requires_string(__s);
4614 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4635 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4636 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4637 _M_limit(__pos, __n1), __n2, __c); }
4653 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4654 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4672 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4674 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4675 && __i2 <= _M_iend());
4676 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4693 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4695 __glibcxx_requires_string(__s);
4696 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4714 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4716 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4717 && __i2 <= _M_iend());
4718 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4736 template<
class _InputIterator>
4739 _InputIterator __k1, _InputIterator __k2)
4741 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4742 && __i2 <= _M_iend());
4743 __glibcxx_requires_valid_range(__k1, __k2);
4744 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4745 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4751 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4753 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4754 && __i2 <= _M_iend());
4755 __glibcxx_requires_valid_range(__k1, __k2);
4756 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4761 replace(iterator __i1, iterator __i2,
4762 const _CharT* __k1,
const _CharT* __k2)
4764 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4765 && __i2 <= _M_iend());
4766 __glibcxx_requires_valid_range(__k1, __k2);
4767 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4772 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4774 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4775 && __i2 <= _M_iend());
4776 __glibcxx_requires_valid_range(__k1, __k2);
4777 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4778 __k1.base(), __k2 - __k1);
4782 replace(iterator __i1, iterator __i2,
4783 const_iterator __k1, const_iterator __k2)
4785 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4786 && __i2 <= _M_iend());
4787 __glibcxx_requires_valid_range(__k1, __k2);
4788 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4789 __k1.base(), __k2 - __k1);
4792 #if __cplusplus >= 201103L 4807 basic_string&
replace(iterator __i1, iterator __i2,
4809 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4812 #if __cplusplus > 201402L 4821 replace(size_type __pos, size_type __n, __sv_type __sv)
4822 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
4833 template <
typename _Tp>
4834 _If_sv<_Tp, basic_string&>
4835 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4836 size_type __pos2, size_type __n2 = npos)
4838 __sv_type __sv = __svt;
4839 return this->
replace(__pos1, __n1, __sv.data()
4840 + __sv._M_check(__pos2,
"basic_string::replace"),
4841 __sv._M_limit(__pos2, __n2));
4854 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
4855 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
4859 template<
class _Integer>
4861 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4862 _Integer __val, __true_type)
4863 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4865 template<
class _InputIterator>
4867 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4868 _InputIterator __k2, __false_type);
4871 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4875 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4880 template<
class _InIterator>
4882 _S_construct_aux(_InIterator __beg, _InIterator __end,
4883 const _Alloc& __a, __false_type)
4885 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4886 return _S_construct(__beg, __end, __a, _Tag());
4891 template<
class _Integer>
4893 _S_construct_aux(_Integer __beg, _Integer __end,
4894 const _Alloc& __a, __true_type)
4895 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4899 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4900 {
return _S_construct(__req, __c, __a); }
4902 template<
class _InIterator>
4904 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4906 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4907 return _S_construct_aux(__beg, __end, __a, _Integral());
4911 template<
class _InIterator>
4913 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4918 template<
class _FwdIterator>
4920 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4924 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4941 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4952 swap(basic_string& __s);
4963 {
return _M_data(); }
4975 {
return _M_data(); }
4977 #if __cplusplus > 201402L 4986 {
return _M_data(); }
4994 {
return _M_dataplus; }
5009 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5023 find(
const basic_string& __str, size_type __pos = 0) const
5025 {
return this->
find(__str.data(), __pos, __str.size()); }
5038 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5040 __glibcxx_requires_string(__s);
5041 return this->
find(__s, __pos, traits_type::length(__s));
5055 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5057 #if __cplusplus > 201402L 5065 find(__sv_type __sv, size_type __pos = 0)
const noexcept
5066 {
return this->
find(__sv.data(), __pos, __sv.size()); }
5080 rfind(
const basic_string& __str, size_type __pos = npos)
const 5082 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5097 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5111 rfind(
const _CharT* __s, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
5113 __glibcxx_requires_string(__s);
5114 return this->
rfind(__s, __pos, traits_type::length(__s));
5128 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5130 #if __cplusplus > 201402L 5138 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
5139 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
5156 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5171 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5188 __glibcxx_requires_string(__s);
5189 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5206 {
return this->
find(__c, __pos); }
5208 #if __cplusplus > 201402L 5216 find_first_of(__sv_type __sv, size_type __pos = 0)
const noexcept
5217 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
5234 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5249 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5266 __glibcxx_requires_string(__s);
5267 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5284 {
return this->
rfind(__c, __pos); }
5286 #if __cplusplus > 201402L 5294 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
5295 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
5327 size_type __n)
const _GLIBCXX_NOEXCEPT;
5343 __glibcxx_requires_string(__s);
5361 #if __cplusplus > 201402L 5403 size_type __n)
const _GLIBCXX_NOEXCEPT;
5419 __glibcxx_requires_string(__s);
5437 #if __cplusplus > 201402L 5462 substr(size_type __pos = 0, size_type __n = npos)
const 5464 _M_check(__pos,
"basic_string::substr"), __n); }
5483 const size_type __size = this->
size();
5484 const size_type __osize = __str.size();
5485 const size_type __len =
std::min(__size, __osize);
5487 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5489 __r = _S_compare(__size, __osize);
5493 #if __cplusplus > 201402L 5502 const size_type __size = this->
size();
5503 const size_type __osize = __sv.size();
5504 const size_type __len =
std::min(__size, __osize);
5506 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5508 __r = _S_compare(__size, __osize);
5520 compare(size_type __pos, size_type __n, __sv_type __sv)
const 5521 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
5532 template <
typename _Tp>
5534 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5535 size_type __pos2, size_type __n2 = npos)
const 5537 __sv_type __sv = __svt;
5538 return __sv_type(*
this)
5539 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5563 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5589 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5590 size_type __pos2, size_type __n2)
const;
5607 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5631 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5658 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5659 size_type __n2)
const;
5661 # ifdef _GLIBCXX_TM_TS_INTERNAL 5663 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5666 ::_txnal_cow_string_c_str(
const void *that);
5668 ::_txnal_cow_string_D1(
void *that);
5670 ::_txnal_cow_string_D1_commit(
void *that);
5673 #endif // !_GLIBCXX_USE_CXX11_ABI 5682 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5688 __str.append(__rhs);
5698 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5709 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5719 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5722 const _CharT* __rhs)
5725 __str.append(__rhs);
5735 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5740 typedef typename __string_type::size_type __size_type;
5741 __string_type __str(__lhs);
5742 __str.append(__size_type(1), __rhs);
5746 #if __cplusplus >= 201103L 5747 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5751 {
return std::move(__lhs.append(__rhs)); }
5753 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5757 {
return std::move(__rhs.insert(0, __lhs)); }
5759 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5764 const auto __size = __lhs.size() + __rhs.size();
5765 const bool __cond = (__size > __lhs.capacity()
5766 && __size <= __rhs.capacity());
5767 return __cond ? std::move(__rhs.insert(0, __lhs))
5768 : std::move(__lhs.append(__rhs));
5771 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5775 {
return std::move(__rhs.insert(0, __lhs)); }
5777 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5781 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5783 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5786 const _CharT* __rhs)
5787 {
return std::move(__lhs.append(__rhs)); }
5789 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5793 {
return std::move(__lhs.append(1, __rhs)); }
5803 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5808 {
return __lhs.compare(__rhs) == 0; }
5810 template<
typename _CharT>
5812 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5815 {
return (__lhs.
size() == __rhs.
size()
5825 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5827 operator==(
const _CharT* __lhs,
5829 {
return __rhs.compare(__lhs) == 0; }
5837 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5840 const _CharT* __rhs)
5841 {
return __lhs.compare(__rhs) == 0; }
5850 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5855 {
return !(__lhs == __rhs); }
5863 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5865 operator!=(
const _CharT* __lhs,
5867 {
return !(__lhs == __rhs); }
5875 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5878 const _CharT* __rhs)
5879 {
return !(__lhs == __rhs); }
5888 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5890 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5893 {
return __lhs.
compare(__rhs) < 0; }
5901 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5903 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5904 const _CharT* __rhs)
5905 {
return __lhs.
compare(__rhs) < 0; }
5913 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5915 operator<(
const _CharT* __lhs,
5917 {
return __rhs.compare(__lhs) > 0; }
5926 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5931 {
return __lhs.compare(__rhs) > 0; }
5939 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5942 const _CharT* __rhs)
5943 {
return __lhs.compare(__rhs) > 0; }
5951 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5953 operator>(
const _CharT* __lhs,
5955 {
return __rhs.compare(__lhs) < 0; }
5964 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5966 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5969 {
return __lhs.
compare(__rhs) <= 0; }
5977 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5979 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5980 const _CharT* __rhs)
5981 {
return __lhs.
compare(__rhs) <= 0; }
5989 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5991 operator<=(
const _CharT* __lhs,
5993 {
return __rhs.compare(__lhs) >= 0; }
6002 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6007 {
return __lhs.compare(__rhs) >= 0; }
6015 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6018 const _CharT* __rhs)
6019 {
return __lhs.compare(__rhs) >= 0; }
6027 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6029 operator>=(
const _CharT* __lhs,
6031 {
return __rhs.compare(__lhs) <= 0; }
6040 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6044 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6045 { __lhs.swap(__rhs); }
6060 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6080 operator<<(basic_ostream<_CharT, _Traits>& __os,
6085 return __ostream_insert(__os, __str.
data(), __str.
size());
6101 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6118 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6124 #if __cplusplus >= 201103L 6126 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6133 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6145 #ifdef _GLIBCXX_USE_WCHAR_T 6152 _GLIBCXX_END_NAMESPACE_VERSION
6155 #if __cplusplus >= 201103L 6159 namespace std _GLIBCXX_VISIBILITY(default)
6161 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6162 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6164 #if _GLIBCXX_USE_C99_STDLIB 6167 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6168 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
6172 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6173 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
6176 inline unsigned long 6177 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6178 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
6182 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6183 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
6186 inline unsigned long long 6187 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6188 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
6193 stof(
const string& __str,
size_t* __idx = 0)
6194 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
6197 stod(
const string& __str,
size_t* __idx = 0)
6198 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
6201 stold(
const string& __str,
size_t* __idx = 0)
6202 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
6203 #endif // _GLIBCXX_USE_C99_STDLIB 6205 #if _GLIBCXX_USE_C99_STDIO 6210 to_string(
int __val)
6211 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6215 to_string(
unsigned __val)
6216 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6217 4 *
sizeof(unsigned),
6221 to_string(
long __val)
6222 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6226 to_string(
unsigned long __val)
6227 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6228 4 *
sizeof(
unsigned long),
6232 to_string(
long long __val)
6233 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6234 4 *
sizeof(
long long),
6238 to_string(
unsigned long long __val)
6239 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6240 4 *
sizeof(
unsigned long long),
6244 to_string(
float __val)
6247 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6248 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6253 to_string(
double __val)
6256 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6257 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6262 to_string(
long double __val)
6265 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6266 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6269 #endif // _GLIBCXX_USE_C99_STDIO 6271 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6273 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6274 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6278 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6279 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6282 inline unsigned long 6283 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6284 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6288 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6289 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6292 inline unsigned long long 6293 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6294 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6299 stof(
const wstring& __str,
size_t* __idx = 0)
6300 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6303 stod(
const wstring& __str,
size_t* __idx = 0)
6304 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6307 stold(
const wstring& __str,
size_t* __idx = 0)
6308 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6310 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6313 to_wstring(
int __val)
6314 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6318 to_wstring(
unsigned __val)
6319 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6320 4 *
sizeof(unsigned),
6324 to_wstring(
long __val)
6325 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6329 to_wstring(
unsigned long __val)
6330 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6331 4 *
sizeof(
unsigned long),
6335 to_wstring(
long long __val)
6336 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6337 4 *
sizeof(
long long),
6341 to_wstring(
unsigned long long __val)
6342 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6343 4 *
sizeof(
unsigned long long),
6347 to_wstring(
float __val)
6350 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6351 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6356 to_wstring(
double __val)
6359 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6360 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6365 to_wstring(
long double __val)
6368 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6369 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6372 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6373 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6375 _GLIBCXX_END_NAMESPACE_CXX11
6376 _GLIBCXX_END_NAMESPACE_VERSION
6381 #if __cplusplus >= 201103L 6385 namespace std _GLIBCXX_VISIBILITY(default)
6387 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6391 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6395 :
public __hash_base<size_t, string>
6398 operator()(
const string& __s)
const noexcept
6399 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6406 #ifdef _GLIBCXX_USE_WCHAR_T 6410 :
public __hash_base<size_t, wstring>
6413 operator()(
const wstring& __s)
const noexcept
6414 {
return std::_Hash_impl::hash(__s.
data(),
6415 __s.
length() *
sizeof(wchar_t)); }
6424 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6428 :
public __hash_base<size_t, u16string>
6431 operator()(
const u16string& __s)
const noexcept
6432 {
return std::_Hash_impl::hash(__s.
data(),
6433 __s.
length() *
sizeof(char16_t)); }
6443 :
public __hash_base<size_t, u32string>
6446 operator()(
const u32string& __s)
const noexcept
6447 {
return std::_Hash_impl::hash(__s.
data(),
6448 __s.
length() *
sizeof(char32_t)); }
6456 _GLIBCXX_END_NAMESPACE_VERSION
6458 #if __cplusplus > 201103L 6460 #define __cpp_lib_string_udls 201304 6462 inline namespace literals
6464 inline namespace string_literals
6466 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6468 _GLIBCXX_DEFAULT_ABI_TAG
6470 operator""s(
const char* __str,
size_t __len)
6473 #ifdef _GLIBCXX_USE_WCHAR_T 6474 _GLIBCXX_DEFAULT_ABI_TAG
6476 operator""s(
const wchar_t* __str,
size_t __len)
6480 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6481 _GLIBCXX_DEFAULT_ABI_TAG
6483 operator""s(
const char16_t* __str,
size_t __len)
6486 _GLIBCXX_DEFAULT_ABI_TAG
6488 operator""s(
const char32_t* __str,
size_t __len)
6492 _GLIBCXX_END_NAMESPACE_VERSION
6496 #endif // __cplusplus > 201103L basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
Uniform interface to all pointer-like types.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
const_reference front() const noexcept
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
char_type widen(char __c) const
Widens characters.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
Basis for explicit traits specializations.
void pop_back()
Remove the last character.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
reference at(size_type __n)
Provides access to the data contained in the string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
~basic_string() noexcept
Destroy the string instance.
Primary class template hash.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
const_reverse_iterator crbegin() const noexcept
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
ISO C++ entities toplevel namespace is std.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
iterator erase(iterator __position)
Remove one character.
const_iterator begin() const noexcept
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
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.
Template class basic_ostream.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
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 & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_iterator end() const noexcept
Managing sequences of characters and character-like objects.
basic_string & append(const _CharT *__s)
Append a C string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
const_iterator cbegin() const noexcept
void push_back(_CharT __c)
Append a single character.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
size_type capacity() const noexcept
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & operator+=(const _CharT *__s)
Append a C string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
const_reverse_iterator rend() const noexcept
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
const_iterator cend() const noexcept
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of 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.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string()
Default constructor creates an empty string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
bool empty() const noexcept
void swap(basic_string &__s)
Swap contents with another string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
reverse_iterator rbegin()
static const size_type npos
Value returned by various member functions when they fail.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
const_reference back() const noexcept
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.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
Uniform interface to C++98 and C++11 allocators.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
Template class basic_istream.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
One of the comparison functors.
Forward iterators support a superset of input iterator operations.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.