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;
2923 template<
typename,
typename,
typename>
friend class basic_stringbuf;
2925 _GLIBCXX_END_NAMESPACE_CXX11
2926 #else // !_GLIBCXX_USE_CXX11_ABI 2991 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2994 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2998 typedef _Traits traits_type;
2999 typedef typename _Traits::char_type value_type;
3000 typedef _Alloc allocator_type;
3001 typedef typename _CharT_alloc_type::size_type size_type;
3002 typedef typename _CharT_alloc_type::difference_type difference_type;
3003 typedef typename _CharT_alloc_type::reference reference;
3004 typedef typename _CharT_alloc_type::const_reference const_reference;
3005 typedef typename _CharT_alloc_type::pointer pointer;
3006 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3007 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3008 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3030 size_type _M_length;
3031 size_type _M_capacity;
3032 _Atomic_word _M_refcount;
3035 struct _Rep : _Rep_base
3038 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3053 static const size_type _S_max_size;
3054 static const _CharT _S_terminal;
3058 static size_type _S_empty_rep_storage[];
3061 _S_empty_rep() _GLIBCXX_NOEXCEPT
3066 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3067 return *
reinterpret_cast<_Rep*
>(__p);
3071 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3073 #if defined(__GTHREADS) 3078 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3080 return this->_M_refcount < 0;
3085 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3087 #if defined(__GTHREADS) 3093 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3095 return this->_M_refcount > 0;
3100 _M_set_leaked() _GLIBCXX_NOEXCEPT
3101 { this->_M_refcount = -1; }
3104 _M_set_sharable() _GLIBCXX_NOEXCEPT
3105 { this->_M_refcount = 0; }
3108 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3110 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3111 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3114 this->_M_set_sharable();
3115 this->_M_length = __n;
3116 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3123 _M_refdata()
throw()
3124 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3127 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3129 return (!_M_is_leaked() && __alloc1 == __alloc2)
3130 ? _M_refcopy() : _M_clone(__alloc1);
3135 _S_create(size_type, size_type,
const _Alloc&);
3138 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3140 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3141 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3145 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3154 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3157 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3164 _M_destroy(
const _Alloc&)
throw();
3167 _M_refcopy()
throw()
3169 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3170 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3172 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3173 return _M_refdata();
3177 _M_clone(
const _Alloc&, size_type __res = 0);
3181 struct _Alloc_hider : _Alloc
3183 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3184 : _Alloc(__a), _M_p(__dat) { }
3194 static const size_type npos =
static_cast<size_type
>(-1);
3198 mutable _Alloc_hider _M_dataplus;
3201 _M_data() const _GLIBCXX_NOEXCEPT
3202 {
return _M_dataplus._M_p; }
3205 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3206 {
return (_M_dataplus._M_p = __p); }
3209 _M_rep()
const _GLIBCXX_NOEXCEPT
3210 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3215 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3216 {
return iterator(_M_data()); }
3219 _M_iend()
const _GLIBCXX_NOEXCEPT
3220 {
return iterator(_M_data() + this->
size()); }
3225 if (!_M_rep()->_M_is_leaked())
3230 _M_check(size_type __pos,
const char* __s)
const 3232 if (__pos > this->
size())
3233 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3234 "this->size() (which is %zu)"),
3235 __s, __pos, this->
size());
3240 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3243 __throw_length_error(__N(__s));
3248 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3250 const bool __testoff = __off < this->
size() - __pos;
3251 return __testoff ? __off : this->
size() - __pos;
3256 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3265 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3268 traits_type::assign(*__d, *__s);
3270 traits_type::copy(__d, __s, __n);
3274 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3277 traits_type::assign(*__d, *__s);
3279 traits_type::move(__d, __s, __n);
3283 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3286 traits_type::assign(*__d, __c);
3288 traits_type::assign(__d, __n, __c);
3293 template<
class _Iterator>
3295 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3297 for (; __k1 != __k2; ++__k1, (void)++__p)
3298 traits_type::assign(*__p, *__k1);
3302 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3303 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3306 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3308 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3311 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3312 { _M_copy(__p, __k1, __k2 - __k1); }
3315 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3317 { _M_copy(__p, __k1, __k2 - __k1); }
3320 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3322 const difference_type __d = difference_type(__n1 - __n2);
3324 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3325 return __gnu_cxx::__numeric_traits<int>::__max;
3326 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3327 return __gnu_cxx::__numeric_traits<int>::__min;
3333 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3339 _S_empty_rep() _GLIBCXX_NOEXCEPT
3340 {
return _Rep::_S_empty_rep(); }
3342 #if __cplusplus > 201402L 3344 typedef basic_string_view<_CharT, _Traits> __sv_type;
3346 template<
typename _Tp,
typename _Res>
3347 using _If_sv = enable_if_t<
3348 __and_<is_convertible<const _Tp&, __sv_type>,
3349 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3362 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3363 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3365 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3389 basic_string(
const basic_string& __str, size_type __pos,
3390 const _Alloc& __a = _Alloc());
3398 basic_string(
const basic_string& __str, size_type __pos,
3407 basic_string(
const basic_string& __str, size_type __pos,
3408 size_type __n,
const _Alloc& __a);
3420 const _Alloc& __a = _Alloc());
3426 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3433 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3435 #if __cplusplus >= 201103L 3444 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3447 : _M_dataplus(__str._M_dataplus)
3449 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3450 __str._M_data(_S_empty_rep()._M_refdata());
3452 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3470 template<
class _InputIterator>
3471 basic_string(_InputIterator __beg, _InputIterator __end,
3472 const _Alloc& __a = _Alloc());
3474 #if __cplusplus > 201402L 3482 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3483 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3484 const _Alloc& __a = _Alloc())
3493 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
3509 {
return this->
assign(__str); }
3517 {
return this->
assign(__s); }
3533 #if __cplusplus >= 201103L 3557 this->
assign(__l.begin(), __l.size());
3562 #if __cplusplus > 201402L 3567 template<
typename _Tp>
3568 _If_sv<_Tp, basic_string&>
3570 {
return this->
assign(__sv); }
3576 operator __sv_type()
const noexcept
3577 {
return __sv_type(
data(),
size()); }
3589 return iterator(_M_data());
3598 {
return const_iterator(_M_data()); }
3608 return iterator(_M_data() + this->
size());
3617 {
return const_iterator(_M_data() + this->
size()); }
3626 {
return reverse_iterator(this->
end()); }
3633 const_reverse_iterator
3635 {
return const_reverse_iterator(this->
end()); }
3644 {
return reverse_iterator(this->
begin()); }
3651 const_reverse_iterator
3653 {
return const_reverse_iterator(this->
begin()); }
3655 #if __cplusplus >= 201103L 3662 {
return const_iterator(this->_M_data()); }
3670 {
return const_iterator(this->_M_data() + this->
size()); }
3677 const_reverse_iterator
3679 {
return const_reverse_iterator(this->
end()); }
3686 const_reverse_iterator
3688 {
return const_reverse_iterator(this->
begin()); }
3697 {
return _M_rep()->_M_length; }
3703 {
return _M_rep()->_M_length; }
3708 {
return _Rep::_S_max_size; }
3721 resize(size_type __n, _CharT __c);
3735 { this->
resize(__n, _CharT()); }
3737 #if __cplusplus >= 201103L 3742 #if __cpp_exceptions 3760 {
return _M_rep()->_M_capacity; }
3780 reserve(size_type __res_arg = 0);
3785 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3789 if (_M_rep()->_M_is_shared())
3792 _M_data(_S_empty_rep()._M_refdata());
3795 _M_rep()->_M_set_length_and_sharable(0);
3801 { _M_mutate(0, this->
size(), 0); }
3810 {
return this->
size() == 0; }
3826 __glibcxx_assert(__pos <=
size());
3827 return _M_data()[__pos];
3845 __glibcxx_assert(__pos <=
size());
3847 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3849 return _M_data()[__pos];
3865 if (__n >= this->
size())
3866 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3867 "(which is %zu) >= this->size() " 3870 return _M_data()[__n];
3888 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3889 "(which is %zu) >= this->size() " 3893 return _M_data()[__n];
3896 #if __cplusplus >= 201103L 3904 __glibcxx_assert(!
empty());
3915 __glibcxx_assert(!
empty());
3926 __glibcxx_assert(!
empty());
3937 __glibcxx_assert(!
empty());
3950 {
return this->
append(__str); }
3959 {
return this->
append(__s); }
3973 #if __cplusplus >= 201103L 3981 {
return this->
append(__l.begin(), __l.size()); }
3984 #if __cplusplus > 201402L 3992 {
return this->
append(__sv); }
4001 append(
const basic_string& __str);
4017 append(
const basic_string& __str, size_type __pos, size_type __n);
4026 append(
const _CharT* __s, size_type __n);
4036 __glibcxx_requires_string(__s);
4037 return this->
append(__s, traits_type::length(__s));
4049 append(size_type __n, _CharT __c);
4051 #if __cplusplus >= 201103L 4059 {
return this->
append(__l.begin(), __l.size()); }
4070 template<
class _InputIterator>
4072 append(_InputIterator __first, _InputIterator __last)
4073 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4075 #if __cplusplus > 201402L 4083 {
return this->
append(__sv.data(), __sv.size()); }
4092 template <
typename _Tp>
4093 _If_sv<_Tp, basic_string&>
4094 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4096 __sv_type __sv = __svt;
4097 return append(__sv.data()
4098 + __sv._M_check(__pos,
"basic_string::append"),
4099 __sv._M_limit(__pos, __n));
4110 const size_type __len = 1 + this->
size();
4111 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4113 traits_type::assign(_M_data()[this->
size()], __c);
4114 _M_rep()->_M_set_length_and_sharable(__len);
4123 assign(
const basic_string& __str);
4125 #if __cplusplus >= 201103L 4157 assign(
const basic_string& __str, size_type __pos, size_type __n)
4158 {
return this->
assign(__str._M_data()
4159 + __str._M_check(__pos,
"basic_string::assign"),
4160 __str._M_limit(__pos, __n)); }
4173 assign(
const _CharT* __s, size_type __n);
4187 __glibcxx_requires_string(__s);
4188 return this->
assign(__s, traits_type::length(__s));
4202 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4212 template<
class _InputIterator>
4214 assign(_InputIterator __first, _InputIterator __last)
4215 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4217 #if __cplusplus >= 201103L 4225 {
return this->
assign(__l.begin(), __l.size()); }
4228 #if __cplusplus > 201402L 4236 {
return this->
assign(__sv.data(), __sv.size()); }
4245 template <
typename _Tp>
4246 _If_sv<_Tp, basic_string&>
4247 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4249 __sv_type __sv = __svt;
4250 return assign(__sv.data()
4251 + __sv._M_check(__pos,
"basic_string::assign"),
4252 __sv._M_limit(__pos, __n));
4270 insert(iterator __p, size_type __n, _CharT __c)
4271 { this->
replace(__p, __p, __n, __c); }
4285 template<
class _InputIterator>
4287 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4288 { this->
replace(__p, __p, __beg, __end); }
4290 #if __cplusplus >= 201103L 4300 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4301 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4318 insert(size_type __pos1,
const basic_string& __str)
4319 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4340 insert(size_type __pos1,
const basic_string& __str,
4341 size_type __pos2, size_type __n)
4342 {
return this->
insert(__pos1, __str._M_data()
4343 + __str._M_check(__pos2,
"basic_string::insert"),
4344 __str._M_limit(__pos2, __n)); }
4363 insert(size_type __pos,
const _CharT* __s, size_type __n);
4383 __glibcxx_requires_string(__s);
4384 return this->
insert(__pos, __s, traits_type::length(__s));
4404 insert(size_type __pos, size_type __n, _CharT __c)
4405 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4406 size_type(0), __n, __c); }
4424 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4425 const size_type __pos = __p - _M_ibegin();
4426 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4427 _M_rep()->_M_set_leaked();
4428 return iterator(_M_data() + __pos);
4431 #if __cplusplus > 201402L 4439 insert(size_type __pos, __sv_type __sv)
4440 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
4451 template <
typename _Tp>
4452 _If_sv<_Tp, basic_string&>
4453 insert(size_type __pos1,
const _Tp& __svt,
4454 size_type __pos2, size_type __n = npos)
4456 __sv_type __sv = __svt;
4457 return this->
replace(__pos1, size_type(0), __sv.data()
4458 + __sv._M_check(__pos2,
"basic_string::insert"),
4459 __sv._M_limit(__pos2, __n));
4479 erase(size_type __pos = 0, size_type __n = npos)
4481 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4482 _M_limit(__pos, __n), size_type(0));
4497 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4498 && __position < _M_iend());
4499 const size_type __pos = __position - _M_ibegin();
4500 _M_mutate(__pos, size_type(1), size_type(0));
4501 _M_rep()->_M_set_leaked();
4502 return iterator(_M_data() + __pos);
4515 erase(iterator __first, iterator __last);
4517 #if __cplusplus >= 201103L 4526 __glibcxx_assert(!
empty());
4549 replace(size_type __pos, size_type __n,
const basic_string& __str)
4550 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4571 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4572 size_type __pos2, size_type __n2)
4573 {
return this->
replace(__pos1, __n1, __str._M_data()
4574 + __str._M_check(__pos2,
"basic_string::replace"),
4575 __str._M_limit(__pos2, __n2)); }
4596 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4616 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4618 __glibcxx_requires_string(__s);
4619 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4640 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4641 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4642 _M_limit(__pos, __n1), __n2, __c); }
4658 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4659 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4677 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4679 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4680 && __i2 <= _M_iend());
4681 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4698 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4700 __glibcxx_requires_string(__s);
4701 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4719 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4721 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4722 && __i2 <= _M_iend());
4723 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4741 template<
class _InputIterator>
4744 _InputIterator __k1, _InputIterator __k2)
4746 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4747 && __i2 <= _M_iend());
4748 __glibcxx_requires_valid_range(__k1, __k2);
4749 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4750 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4756 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4758 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4759 && __i2 <= _M_iend());
4760 __glibcxx_requires_valid_range(__k1, __k2);
4761 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4766 replace(iterator __i1, iterator __i2,
4767 const _CharT* __k1,
const _CharT* __k2)
4769 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4770 && __i2 <= _M_iend());
4771 __glibcxx_requires_valid_range(__k1, __k2);
4772 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4777 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4779 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4780 && __i2 <= _M_iend());
4781 __glibcxx_requires_valid_range(__k1, __k2);
4782 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4783 __k1.base(), __k2 - __k1);
4787 replace(iterator __i1, iterator __i2,
4788 const_iterator __k1, const_iterator __k2)
4790 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4791 && __i2 <= _M_iend());
4792 __glibcxx_requires_valid_range(__k1, __k2);
4793 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4794 __k1.base(), __k2 - __k1);
4797 #if __cplusplus >= 201103L 4812 basic_string&
replace(iterator __i1, iterator __i2,
4814 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4817 #if __cplusplus > 201402L 4826 replace(size_type __pos, size_type __n, __sv_type __sv)
4827 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
4838 template <
typename _Tp>
4839 _If_sv<_Tp, basic_string&>
4840 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4841 size_type __pos2, size_type __n2 = npos)
4843 __sv_type __sv = __svt;
4844 return this->
replace(__pos1, __n1, __sv.data()
4845 + __sv._M_check(__pos2,
"basic_string::replace"),
4846 __sv._M_limit(__pos2, __n2));
4859 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
4860 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
4864 template<
class _Integer>
4866 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4867 _Integer __val, __true_type)
4868 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4870 template<
class _InputIterator>
4872 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4873 _InputIterator __k2, __false_type);
4876 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4880 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4885 template<
class _InIterator>
4887 _S_construct_aux(_InIterator __beg, _InIterator __end,
4888 const _Alloc& __a, __false_type)
4890 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4891 return _S_construct(__beg, __end, __a, _Tag());
4896 template<
class _Integer>
4898 _S_construct_aux(_Integer __beg, _Integer __end,
4899 const _Alloc& __a, __true_type)
4900 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4904 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4905 {
return _S_construct(__req, __c, __a); }
4907 template<
class _InIterator>
4909 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4911 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4912 return _S_construct_aux(__beg, __end, __a, _Integral());
4916 template<
class _InIterator>
4918 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4923 template<
class _FwdIterator>
4925 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4929 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4946 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4957 swap(basic_string& __s);
4968 {
return _M_data(); }
4980 {
return _M_data(); }
4982 #if __cplusplus > 201402L 4991 {
return _M_data(); }
4999 {
return _M_dataplus; }
5014 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5028 find(
const basic_string& __str, size_type __pos = 0) const
5030 {
return this->
find(__str.data(), __pos, __str.size()); }
5043 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5045 __glibcxx_requires_string(__s);
5046 return this->
find(__s, __pos, traits_type::length(__s));
5060 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5062 #if __cplusplus > 201402L 5070 find(__sv_type __sv, size_type __pos = 0)
const noexcept
5071 {
return this->
find(__sv.data(), __pos, __sv.size()); }
5085 rfind(
const basic_string& __str, size_type __pos = npos)
const 5087 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5102 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5116 rfind(
const _CharT* __s, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
5118 __glibcxx_requires_string(__s);
5119 return this->
rfind(__s, __pos, traits_type::length(__s));
5133 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5135 #if __cplusplus > 201402L 5143 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
5144 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
5161 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5176 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5193 __glibcxx_requires_string(__s);
5194 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5211 {
return this->
find(__c, __pos); }
5213 #if __cplusplus > 201402L 5221 find_first_of(__sv_type __sv, size_type __pos = 0)
const noexcept
5222 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
5239 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5254 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5271 __glibcxx_requires_string(__s);
5272 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5289 {
return this->
rfind(__c, __pos); }
5291 #if __cplusplus > 201402L 5299 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
5300 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
5332 size_type __n)
const _GLIBCXX_NOEXCEPT;
5348 __glibcxx_requires_string(__s);
5366 #if __cplusplus > 201402L 5408 size_type __n)
const _GLIBCXX_NOEXCEPT;
5424 __glibcxx_requires_string(__s);
5442 #if __cplusplus > 201402L 5467 substr(size_type __pos = 0, size_type __n = npos)
const 5469 _M_check(__pos,
"basic_string::substr"), __n); }
5488 const size_type __size = this->
size();
5489 const size_type __osize = __str.size();
5490 const size_type __len =
std::min(__size, __osize);
5492 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5494 __r = _S_compare(__size, __osize);
5498 #if __cplusplus > 201402L 5507 const size_type __size = this->
size();
5508 const size_type __osize = __sv.size();
5509 const size_type __len =
std::min(__size, __osize);
5511 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5513 __r = _S_compare(__size, __osize);
5525 compare(size_type __pos, size_type __n, __sv_type __sv)
const 5526 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
5537 template <
typename _Tp>
5539 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5540 size_type __pos2, size_type __n2 = npos)
const 5542 __sv_type __sv = __svt;
5543 return __sv_type(*
this)
5544 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5568 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5594 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5595 size_type __pos2, size_type __n2)
const;
5612 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5636 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5663 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5664 size_type __n2)
const;
5666 # ifdef _GLIBCXX_TM_TS_INTERNAL 5668 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5671 ::_txnal_cow_string_c_str(
const void *that);
5673 ::_txnal_cow_string_D1(
void *that);
5675 ::_txnal_cow_string_D1_commit(
void *that);
5678 #endif // !_GLIBCXX_USE_CXX11_ABI 5687 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5693 __str.append(__rhs);
5703 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5714 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5724 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5727 const _CharT* __rhs)
5730 __str.append(__rhs);
5740 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5745 typedef typename __string_type::size_type __size_type;
5746 __string_type __str(__lhs);
5747 __str.append(__size_type(1), __rhs);
5751 #if __cplusplus >= 201103L 5752 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5756 {
return std::move(__lhs.append(__rhs)); }
5758 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5762 {
return std::move(__rhs.insert(0, __lhs)); }
5764 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5769 const auto __size = __lhs.size() + __rhs.size();
5770 const bool __cond = (__size > __lhs.capacity()
5771 && __size <= __rhs.capacity());
5772 return __cond ? std::move(__rhs.insert(0, __lhs))
5773 : std::move(__lhs.append(__rhs));
5776 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5780 {
return std::move(__rhs.insert(0, __lhs)); }
5782 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5786 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5788 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5791 const _CharT* __rhs)
5792 {
return std::move(__lhs.append(__rhs)); }
5794 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5798 {
return std::move(__lhs.append(1, __rhs)); }
5808 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5813 {
return __lhs.compare(__rhs) == 0; }
5815 template<
typename _CharT>
5817 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5820 {
return (__lhs.
size() == __rhs.
size()
5830 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5832 operator==(
const _CharT* __lhs,
5834 {
return __rhs.compare(__lhs) == 0; }
5842 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5845 const _CharT* __rhs)
5846 {
return __lhs.compare(__rhs) == 0; }
5855 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5860 {
return !(__lhs == __rhs); }
5868 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5870 operator!=(
const _CharT* __lhs,
5872 {
return !(__lhs == __rhs); }
5880 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5883 const _CharT* __rhs)
5884 {
return !(__lhs == __rhs); }
5893 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5895 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5898 {
return __lhs.
compare(__rhs) < 0; }
5906 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5908 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5909 const _CharT* __rhs)
5910 {
return __lhs.
compare(__rhs) < 0; }
5918 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5920 operator<(
const _CharT* __lhs,
5922 {
return __rhs.compare(__lhs) > 0; }
5931 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5936 {
return __lhs.compare(__rhs) > 0; }
5944 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5947 const _CharT* __rhs)
5948 {
return __lhs.compare(__rhs) > 0; }
5956 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5958 operator>(
const _CharT* __lhs,
5960 {
return __rhs.compare(__lhs) < 0; }
5969 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5971 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5974 {
return __lhs.
compare(__rhs) <= 0; }
5982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5984 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5985 const _CharT* __rhs)
5986 {
return __lhs.
compare(__rhs) <= 0; }
5994 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5996 operator<=(
const _CharT* __lhs,
5998 {
return __rhs.compare(__lhs) >= 0; }
6007 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6012 {
return __lhs.compare(__rhs) >= 0; }
6020 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6023 const _CharT* __rhs)
6024 {
return __lhs.compare(__rhs) >= 0; }
6032 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6034 operator>=(
const _CharT* __lhs,
6036 {
return __rhs.compare(__lhs) <= 0; }
6045 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6049 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6050 { __lhs.swap(__rhs); }
6065 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6083 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6085 operator<<(basic_ostream<_CharT, _Traits>& __os,
6090 return __ostream_insert(__os, __str.
data(), __str.
size());
6106 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6123 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6129 #if __cplusplus >= 201103L 6131 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6150 #ifdef _GLIBCXX_USE_WCHAR_T 6157 _GLIBCXX_END_NAMESPACE_VERSION
6160 #if __cplusplus >= 201103L 6164 namespace std _GLIBCXX_VISIBILITY(default)
6166 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6167 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6169 #if _GLIBCXX_USE_C99_STDLIB 6172 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6173 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
6177 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6178 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
6181 inline unsigned long 6182 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6183 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
6187 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6188 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
6191 inline unsigned long long 6192 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6193 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
6198 stof(
const string& __str,
size_t* __idx = 0)
6199 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
6202 stod(
const string& __str,
size_t* __idx = 0)
6203 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
6206 stold(
const string& __str,
size_t* __idx = 0)
6207 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
6208 #endif // _GLIBCXX_USE_C99_STDLIB 6210 #if _GLIBCXX_USE_C99_STDIO 6215 to_string(
int __val)
6216 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6220 to_string(
unsigned __val)
6221 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6222 4 *
sizeof(unsigned),
6226 to_string(
long __val)
6227 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6231 to_string(
unsigned long __val)
6232 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6233 4 *
sizeof(
unsigned long),
6237 to_string(
long long __val)
6238 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6239 4 *
sizeof(
long long),
6243 to_string(
unsigned long long __val)
6244 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6245 4 *
sizeof(
unsigned long long),
6249 to_string(
float __val)
6252 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6253 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6258 to_string(
double __val)
6261 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6262 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6267 to_string(
long double __val)
6270 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6271 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6274 #endif // _GLIBCXX_USE_C99_STDIO 6276 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6278 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6279 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6283 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6284 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6287 inline unsigned long 6288 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6289 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6293 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6294 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6297 inline unsigned long long 6298 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6299 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6304 stof(
const wstring& __str,
size_t* __idx = 0)
6305 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6308 stod(
const wstring& __str,
size_t* __idx = 0)
6309 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6312 stold(
const wstring& __str,
size_t* __idx = 0)
6313 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6315 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6318 to_wstring(
int __val)
6319 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6323 to_wstring(
unsigned __val)
6324 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6325 4 *
sizeof(unsigned),
6329 to_wstring(
long __val)
6330 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6334 to_wstring(
unsigned long __val)
6335 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6336 4 *
sizeof(
unsigned long),
6340 to_wstring(
long long __val)
6341 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6342 4 *
sizeof(
long long),
6346 to_wstring(
unsigned long long __val)
6347 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6348 4 *
sizeof(
unsigned long long),
6352 to_wstring(
float __val)
6355 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6356 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6361 to_wstring(
double __val)
6364 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6365 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6370 to_wstring(
long double __val)
6373 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6374 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6377 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6378 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6380 _GLIBCXX_END_NAMESPACE_CXX11
6381 _GLIBCXX_END_NAMESPACE_VERSION
6386 #if __cplusplus >= 201103L 6390 namespace std _GLIBCXX_VISIBILITY(default)
6392 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6396 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6400 :
public __hash_base<size_t, string>
6403 operator()(
const string& __s)
const noexcept
6404 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6411 #ifdef _GLIBCXX_USE_WCHAR_T 6415 :
public __hash_base<size_t, wstring>
6418 operator()(
const wstring& __s)
const noexcept
6419 {
return std::_Hash_impl::hash(__s.
data(),
6420 __s.
length() *
sizeof(wchar_t)); }
6429 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6433 :
public __hash_base<size_t, u16string>
6436 operator()(
const u16string& __s)
const noexcept
6437 {
return std::_Hash_impl::hash(__s.
data(),
6438 __s.
length() *
sizeof(char16_t)); }
6448 :
public __hash_base<size_t, u32string>
6451 operator()(
const u32string& __s)
const noexcept
6452 {
return std::_Hash_impl::hash(__s.
data(),
6453 __s.
length() *
sizeof(char32_t)); }
6461 _GLIBCXX_END_NAMESPACE_VERSION
6463 #if __cplusplus > 201103L 6465 #define __cpp_lib_string_udls 201304 6467 inline namespace literals
6469 inline namespace string_literals
6471 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6473 _GLIBCXX_DEFAULT_ABI_TAG
6475 operator""s(
const char* __str,
size_t __len)
6478 #ifdef _GLIBCXX_USE_WCHAR_T 6479 _GLIBCXX_DEFAULT_ABI_TAG
6481 operator""s(
const wchar_t* __str,
size_t __len)
6485 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6486 _GLIBCXX_DEFAULT_ABI_TAG
6488 operator""s(
const char16_t* __str,
size_t __len)
6491 _GLIBCXX_DEFAULT_ABI_TAG
6493 operator""s(
const char32_t* __str,
size_t __len)
6497 _GLIBCXX_END_NAMESPACE_VERSION
6501 #endif // __cplusplus > 201103L basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_iterator cbegin() const noexcept
Uniform interface to C++98 and C++11 allocators.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct 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_iterator begin() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
char_type widen(char __c) const
Widens characters.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number 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.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
void pop_back()
Remove the last character.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & append(const _CharT *__s)
Append a C string.
void push_back(_CharT __c)
Append a single character.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
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.
const_reverse_iterator crbegin() const noexcept
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
reference at(size_type __n)
Provides access to the data contained in the string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
ISO C++ entities toplevel namespace is std.
const_reverse_iterator rend() const noexcept
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 & assign(const basic_string &__str)
Set value to contents of another string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
reverse_iterator rbegin()
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
basic_string(basic_string &&__str) noexcept
Move construct string.
Template class basic_ostream.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const_reverse_iterator crend() const noexcept
~basic_string() noexcept
Destroy the string instance.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_iterator cend() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
const_iterator end() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
bool empty() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
const_reference back() const noexcept
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string()
Default constructor creates an empty string.
Managing sequences of characters and character-like objects.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & append(const basic_string &__str)
Append a string to this string.
One of the comparison functors.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
Forward iterators support a superset of input iterator operations.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
static const size_type npos
Value returned by various member functions when they fail.
Uniform interface to all pointer-like types.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
Basis for explicit traits specializations.
int compare(const basic_string &__str) const
Compare to a string.
void swap(basic_string &__s)
Swap contents with another string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
Primary class template hash.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
iterator erase(iterator __position)
Remove one character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
const_reference front() const noexcept
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
Template class basic_istream.
basic_string & operator+=(const _CharT *__s)
Append a C string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of 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.
const_reverse_iterator rbegin() const noexcept
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.