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())
636 _M_destroy(_M_allocated_capacity);
637 _M_data(_M_local_data());
640 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
643 return this->
assign(__str);
652 {
return this->
assign(__s); }
668 #if __cplusplus >= 201103L 681 noexcept(_Alloc_traits::_S_nothrow_move())
683 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
684 && !_Alloc_traits::_S_always_equal()
685 && _M_get_allocator() != __str._M_get_allocator())
688 _M_destroy(_M_allocated_capacity);
689 _M_data(_M_local_data());
693 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
695 if (!__str._M_is_local()
696 && (_Alloc_traits::_S_propagate_on_move_assign()
697 || _Alloc_traits::_S_always_equal()))
699 pointer __data =
nullptr;
700 size_type __capacity;
703 if (_Alloc_traits::_S_always_equal())
706 __capacity = _M_allocated_capacity;
709 _M_destroy(_M_allocated_capacity);
712 _M_data(__str._M_data());
713 _M_length(__str.length());
714 _M_capacity(__str._M_allocated_capacity);
717 __str._M_data(__data);
718 __str._M_capacity(__capacity);
721 __str._M_data(__str._M_local_buf);
736 this->
assign(__l.begin(), __l.size());
741 #if __cplusplus > 201402L 748 {
return this->
assign(__sv); }
754 operator __sv_type() const noexcept
755 {
return __sv_type(
data(),
size()); }
764 begin() _GLIBCXX_NOEXCEPT
765 {
return iterator(_M_data()); }
772 begin() const _GLIBCXX_NOEXCEPT
773 {
return const_iterator(_M_data()); }
780 end() _GLIBCXX_NOEXCEPT
781 {
return iterator(_M_data() + this->
size()); }
788 end() const _GLIBCXX_NOEXCEPT
789 {
return const_iterator(_M_data() + this->
size()); }
797 rbegin() _GLIBCXX_NOEXCEPT
798 {
return reverse_iterator(this->
end()); }
805 const_reverse_iterator
806 rbegin() const _GLIBCXX_NOEXCEPT
807 {
return const_reverse_iterator(this->
end()); }
815 rend() _GLIBCXX_NOEXCEPT
816 {
return reverse_iterator(this->
begin()); }
823 const_reverse_iterator
824 rend() const _GLIBCXX_NOEXCEPT
825 {
return const_reverse_iterator(this->
begin()); }
827 #if __cplusplus >= 201103L 834 {
return const_iterator(this->_M_data()); }
841 cend() const noexcept
842 {
return const_iterator(this->_M_data() + this->
size()); }
849 const_reverse_iterator
851 {
return const_reverse_iterator(this->
end()); }
858 const_reverse_iterator
859 crend() const noexcept
860 {
return const_reverse_iterator(this->
begin()); }
868 size() const _GLIBCXX_NOEXCEPT
869 {
return _M_string_length; }
874 length() const _GLIBCXX_NOEXCEPT
875 {
return _M_string_length; }
880 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
893 resize(size_type __n, _CharT __c);
907 { this->
resize(__n, _CharT()); }
909 #if __cplusplus >= 201103L 933 return _M_is_local() ? size_type(_S_local_capacity)
934 : _M_allocated_capacity;
955 reserve(size_type __res_arg = 0);
961 clear() _GLIBCXX_NOEXCEPT
962 { _M_set_length(0); }
969 empty() const _GLIBCXX_NOEXCEPT
970 {
return this->
size() == 0; }
984 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
986 __glibcxx_assert(__pos <=
size());
987 return _M_data()[__pos];
1005 __glibcxx_assert(__pos <=
size());
1007 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1008 return _M_data()[__pos];
1022 at(size_type __n)
const 1024 if (__n >= this->
size())
1025 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1026 "(which is %zu) >= this->size() " 1029 return _M_data()[__n];
1046 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1047 "(which is %zu) >= this->size() " 1050 return _M_data()[__n];
1053 #if __cplusplus >= 201103L 1061 __glibcxx_assert(!
empty());
1070 front() const noexcept
1072 __glibcxx_assert(!
empty());
1083 __glibcxx_assert(!
empty());
1092 back() const noexcept
1094 __glibcxx_assert(!
empty());
1107 {
return this->
append(__str); }
1116 {
return this->
append(__s); }
1130 #if __cplusplus >= 201103L 1138 {
return this->
append(__l.begin(), __l.size()); }
1141 #if __cplusplus > 201402L 1149 {
return this->
append(__sv); }
1158 append(
const basic_string& __str)
1159 {
return _M_append(__str._M_data(), __str.size()); }
1175 append(
const basic_string& __str, size_type __pos, size_type __n)
1176 {
return _M_append(__str._M_data()
1177 + __str._M_check(__pos,
"basic_string::append"),
1178 __str._M_limit(__pos, __n)); }
1187 append(
const _CharT* __s, size_type __n)
1189 __glibcxx_requires_string_len(__s, __n);
1190 _M_check_length(size_type(0), __n,
"basic_string::append");
1191 return _M_append(__s, __n);
1200 append(
const _CharT* __s)
1202 __glibcxx_requires_string(__s);
1203 const size_type __n = traits_type::length(__s);
1204 _M_check_length(size_type(0), __n,
"basic_string::append");
1205 return _M_append(__s, __n);
1217 append(size_type __n, _CharT __c)
1218 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1220 #if __cplusplus >= 201103L 1227 append(initializer_list<_CharT> __l)
1228 {
return this->
append(__l.begin(), __l.size()); }
1239 #if __cplusplus >= 201103L 1240 template<
class _InputIterator,
1241 typename = std::_RequireInputIter<_InputIterator>>
1243 template<
class _InputIterator>
1246 append(_InputIterator __first, _InputIterator __last)
1249 #if __cplusplus > 201402L 1257 {
return this->
append(__sv.data(), __sv.size()); }
1266 template <
typename _Tp>
1267 _If_sv<_Tp, basic_string&>
1268 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1270 __sv_type __sv = __svt;
1271 return _M_append(__sv.data()
1272 + __sv._M_check(__pos,
"basic_string::append"),
1273 __sv._M_limit(__pos, __n));
1284 const size_type __size = this->
size();
1286 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1287 traits_type::assign(this->_M_data()[__size], __c);
1288 this->_M_set_length(__size + 1);
1297 assign(
const basic_string& __str)
1299 this->_M_assign(__str);
1303 #if __cplusplus >= 201103L 1313 assign(basic_string&& __str)
1314 noexcept(_Alloc_traits::_S_nothrow_move())
1318 return *
this = std::move(__str);
1336 assign(
const basic_string& __str, size_type __pos, size_type __n)
1337 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1338 + __str._M_check(__pos,
"basic_string::assign"),
1339 __str._M_limit(__pos, __n)); }
1352 assign(
const _CharT* __s, size_type __n)
1354 __glibcxx_requires_string_len(__s, __n);
1355 return _M_replace(size_type(0), this->
size(), __s, __n);
1368 assign(
const _CharT* __s)
1370 __glibcxx_requires_string(__s);
1371 return _M_replace(size_type(0), this->
size(), __s,
1372 traits_type::length(__s));
1385 assign(size_type __n, _CharT __c)
1386 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1396 #if __cplusplus >= 201103L 1397 template<
class _InputIterator,
1398 typename = std::_RequireInputIter<_InputIterator>>
1400 template<
class _InputIterator>
1403 assign(_InputIterator __first, _InputIterator __last)
1406 #if __cplusplus >= 201103L 1413 assign(initializer_list<_CharT> __l)
1414 {
return this->
assign(__l.begin(), __l.size()); }
1417 #if __cplusplus > 201402L 1425 {
return this->
assign(__sv.data(), __sv.size()); }
1434 template <
typename _Tp>
1435 _If_sv<_Tp, basic_string&>
1436 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1438 __sv_type __sv = __svt;
1439 return _M_replace(size_type(0), this->
size(), __sv.data()
1440 + __sv._M_check(__pos,
"basic_string::assign"),
1441 __sv._M_limit(__pos, __n));
1445 #if __cplusplus >= 201103L 1462 insert(const_iterator __p, size_type __n, _CharT __c)
1464 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1465 const size_type __pos = __p -
begin();
1466 this->
replace(__p, __p, __n, __c);
1467 return iterator(this->_M_data() + __pos);
1484 insert(iterator __p, size_type __n, _CharT __c)
1485 { this->
replace(__p, __p, __n, __c); }
1488 #if __cplusplus >= 201103L 1503 template<
class _InputIterator,
1504 typename = std::_RequireInputIter<_InputIterator>>
1506 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1508 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1509 const size_type __pos = __p -
begin();
1510 this->
replace(__p, __p, __beg, __end);
1511 return iterator(this->_M_data() + __pos);
1526 template<
class _InputIterator>
1528 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1529 { this->
replace(__p, __p, __beg, __end); }
1532 #if __cplusplus >= 201103L 1540 insert(iterator __p, initializer_list<_CharT> __l)
1542 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1543 this->
insert(__p -
begin(), __l.begin(), __l.size());
1560 insert(size_type __pos1,
const basic_string& __str)
1561 {
return this->
replace(__pos1, size_type(0),
1562 __str._M_data(), __str.size()); }
1583 insert(size_type __pos1,
const basic_string& __str,
1584 size_type __pos2, size_type __n)
1585 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1586 + __str._M_check(__pos2,
"basic_string::insert"),
1587 __str._M_limit(__pos2, __n)); }
1606 insert(size_type __pos,
const _CharT* __s, size_type __n)
1607 {
return this->
replace(__pos, size_type(0), __s, __n); }
1625 insert(size_type __pos,
const _CharT* __s)
1627 __glibcxx_requires_string(__s);
1628 return this->
replace(__pos, size_type(0), __s,
1629 traits_type::length(__s));
1649 insert(size_type __pos, size_type __n, _CharT __c)
1650 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1651 size_type(0), __n, __c); }
1667 insert(__const_iterator __p, _CharT __c)
1669 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1670 const size_type __pos = __p -
begin();
1671 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1672 return iterator(_M_data() + __pos);
1675 #if __cplusplus > 201402L 1683 insert(size_type __pos, __sv_type __sv)
1684 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
1695 template <
typename _Tp>
1696 _If_sv<_Tp, basic_string&>
1697 insert(size_type __pos1,
const _Tp& __svt,
1698 size_type __pos2, size_type __n = npos)
1700 __sv_type __sv = __svt;
1701 return this->
replace(__pos1, size_type(0), __sv.data()
1702 + __sv._M_check(__pos2,
"basic_string::insert"),
1703 __sv._M_limit(__pos2, __n));
1723 erase(size_type __pos = 0, size_type __n = npos)
1725 _M_check(__pos,
"basic_string::erase");
1727 this->_M_set_length(__pos);
1729 this->_M_erase(__pos, _M_limit(__pos, __n));
1742 erase(__const_iterator __position)
1744 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1745 && __position <
end());
1746 const size_type __pos = __position -
begin();
1747 this->_M_erase(__pos, size_type(1));
1748 return iterator(_M_data() + __pos);
1761 erase(__const_iterator __first, __const_iterator __last)
1763 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1764 && __last <=
end());
1765 const size_type __pos = __first -
begin();
1766 if (__last ==
end())
1767 this->_M_set_length(__pos);
1769 this->_M_erase(__pos, __last - __first);
1770 return iterator(this->_M_data() + __pos);
1773 #if __cplusplus >= 201103L 1782 __glibcxx_assert(!
empty());
1783 _M_erase(
size() - 1, 1);
1805 replace(size_type __pos, size_type __n,
const basic_string& __str)
1806 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1827 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1828 size_type __pos2, size_type __n2)
1829 {
return this->
replace(__pos1, __n1, __str._M_data()
1830 + __str._M_check(__pos2,
"basic_string::replace"),
1831 __str._M_limit(__pos2, __n2)); }
1852 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1855 __glibcxx_requires_string_len(__s, __n2);
1856 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1857 _M_limit(__pos, __n1), __s, __n2);
1877 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1879 __glibcxx_requires_string(__s);
1880 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1901 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1902 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1903 _M_limit(__pos, __n1), __n2, __c); }
1919 replace(__const_iterator __i1, __const_iterator __i2,
1920 const basic_string& __str)
1921 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1939 replace(__const_iterator __i1, __const_iterator __i2,
1940 const _CharT* __s, size_type __n)
1942 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1944 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1961 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1963 __glibcxx_requires_string(__s);
1964 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1982 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1985 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1987 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2005 #if __cplusplus >= 201103L 2006 template<
class _InputIterator,
2007 typename = std::_RequireInputIter<_InputIterator>>
2009 replace(const_iterator __i1, const_iterator __i2,
2010 _InputIterator __k1, _InputIterator __k2)
2012 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2014 __glibcxx_requires_valid_range(__k1, __k2);
2015 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2016 std::__false_type());
2019 template<
class _InputIterator>
2020 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2021 typename __enable_if_not_native_iterator<_InputIterator>::__type
2025 replace(iterator __i1, iterator __i2,
2026 _InputIterator __k1, _InputIterator __k2)
2028 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2030 __glibcxx_requires_valid_range(__k1, __k2);
2031 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2032 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2039 replace(__const_iterator __i1, __const_iterator __i2,
2040 _CharT* __k1, _CharT* __k2)
2042 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2044 __glibcxx_requires_valid_range(__k1, __k2);
2050 replace(__const_iterator __i1, __const_iterator __i2,
2051 const _CharT* __k1,
const _CharT* __k2)
2053 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2055 __glibcxx_requires_valid_range(__k1, __k2);
2061 replace(__const_iterator __i1, __const_iterator __i2,
2062 iterator __k1, iterator __k2)
2064 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2066 __glibcxx_requires_valid_range(__k1, __k2);
2068 __k1.base(), __k2 - __k1);
2072 replace(__const_iterator __i1, __const_iterator __i2,
2073 const_iterator __k1, const_iterator __k2)
2075 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2077 __glibcxx_requires_valid_range(__k1, __k2);
2079 __k1.base(), __k2 - __k1);
2082 #if __cplusplus >= 201103L 2097 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2098 initializer_list<_CharT> __l)
2099 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2102 #if __cplusplus > 201402L 2111 replace(size_type __pos, size_type __n, __sv_type __sv)
2112 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
2123 template <
typename _Tp>
2124 _If_sv<_Tp, basic_string&>
2125 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2126 size_type __pos2, size_type __n2 = npos)
2128 __sv_type __sv = __svt;
2129 return this->
replace(__pos1, __n1, __sv.data()
2130 + __sv._M_check(__pos2,
"basic_string::replace"),
2131 __sv._M_limit(__pos2, __n2));
2144 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
2145 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
2149 template<
class _Integer>
2151 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2152 _Integer __n, _Integer __val, __true_type)
2153 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2155 template<
class _InputIterator>
2157 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2158 _InputIterator __k1, _InputIterator __k2,
2162 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2166 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2167 const size_type __len2);
2170 _M_append(
const _CharT* __s, size_type __n);
2187 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2197 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2207 c_str() const _GLIBCXX_NOEXCEPT
2208 {
return _M_data(); }
2219 data() const _GLIBCXX_NOEXCEPT
2220 {
return _M_data(); }
2222 #if __cplusplus > 201402L 2231 {
return _M_data(); }
2239 {
return _M_get_allocator(); }
2254 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2268 find(
const basic_string& __str, size_type __pos = 0) const
2270 {
return this->
find(__str.data(), __pos, __str.size()); }
2272 #if __cplusplus > 201402L 2280 find(__sv_type __sv, size_type __pos = 0) const noexcept
2281 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2295 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2297 __glibcxx_requires_string(__s);
2298 return this->
find(__s, __pos, traits_type::length(__s));
2312 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2325 rfind(const basic_string& __str, size_type __pos = npos) const
2327 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2329 #if __cplusplus > 201402L 2337 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
2338 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2354 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2368 rfind(
const _CharT* __s, size_type __pos = npos)
const 2370 __glibcxx_requires_string(__s);
2371 return this->
rfind(__s, __pos, traits_type::length(__s));
2385 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
2399 find_first_of(
const basic_string& __str, size_type __pos = 0) const
2401 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2403 #if __cplusplus > 201402L 2411 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2412 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2428 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2445 __glibcxx_requires_string(__s);
2446 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2462 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2463 {
return this->
find(__c, __pos); }
2477 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 2479 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2481 #if __cplusplus > 201402L 2489 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
2490 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2506 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2520 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2523 __glibcxx_requires_string(__s);
2524 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2540 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
2541 {
return this->
rfind(__c, __pos); }
2558 #if __cplusplus > 201402L 2584 size_type __n)
const _GLIBCXX_NOEXCEPT;
2600 __glibcxx_requires_string(__s);
2634 #if __cplusplus > 201402L 2660 size_type __n)
const _GLIBCXX_NOEXCEPT;
2676 __glibcxx_requires_string(__s);
2707 substr(size_type __pos = 0, size_type __n = npos)
const 2709 _M_check(__pos,
"basic_string::substr"), __n); }
2726 compare(
const basic_string& __str)
const 2728 const size_type __size = this->
size();
2729 const size_type __osize = __str.size();
2730 const size_type __len =
std::min(__size, __osize);
2732 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2734 __r = _S_compare(__size, __osize);
2738 #if __cplusplus > 201402L 2747 const size_type __size = this->
size();
2748 const size_type __osize = __sv.size();
2749 const size_type __len =
std::min(__size, __osize);
2751 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2753 __r = _S_compare(__size, __osize);
2765 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2766 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2777 template <
typename _Tp>
2779 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2780 size_type __pos2, size_type __n2 = npos)
const 2782 __sv_type __sv = __svt;
2783 return __sv_type(*
this)
2784 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2808 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2834 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2835 size_type __pos2, size_type __n2)
const;
2852 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2876 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2903 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2904 size_type __n2)
const;
2906 _GLIBCXX_END_NAMESPACE_CXX11
2907 #else // !_GLIBCXX_USE_CXX11_ABI 2972 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2975 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2979 typedef _Traits traits_type;
2980 typedef typename _Traits::char_type value_type;
2981 typedef _Alloc allocator_type;
2982 typedef typename _CharT_alloc_type::size_type size_type;
2983 typedef typename _CharT_alloc_type::difference_type difference_type;
2984 typedef typename _CharT_alloc_type::reference reference;
2985 typedef typename _CharT_alloc_type::const_reference const_reference;
2986 typedef typename _CharT_alloc_type::pointer pointer;
2987 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2988 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2989 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3011 size_type _M_length;
3012 size_type _M_capacity;
3013 _Atomic_word _M_refcount;
3016 struct _Rep : _Rep_base
3019 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3034 static const size_type _S_max_size;
3035 static const _CharT _S_terminal;
3039 static size_type _S_empty_rep_storage[];
3042 _S_empty_rep() _GLIBCXX_NOEXCEPT
3047 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3048 return *
reinterpret_cast<_Rep*
>(__p);
3052 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3054 #if defined(__GTHREADS) 3059 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3061 return this->_M_refcount < 0;
3066 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3068 #if defined(__GTHREADS) 3074 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3076 return this->_M_refcount > 0;
3081 _M_set_leaked() _GLIBCXX_NOEXCEPT
3082 { this->_M_refcount = -1; }
3085 _M_set_sharable() _GLIBCXX_NOEXCEPT
3086 { this->_M_refcount = 0; }
3089 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3091 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3092 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3095 this->_M_set_sharable();
3096 this->_M_length = __n;
3097 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3104 _M_refdata()
throw()
3105 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3108 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3110 return (!_M_is_leaked() && __alloc1 == __alloc2)
3111 ? _M_refcopy() : _M_clone(__alloc1);
3116 _S_create(size_type, size_type,
const _Alloc&);
3119 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3121 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3122 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3126 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3135 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3138 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3145 _M_destroy(
const _Alloc&)
throw();
3148 _M_refcopy()
throw()
3150 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3151 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3153 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3154 return _M_refdata();
3158 _M_clone(
const _Alloc&, size_type __res = 0);
3162 struct _Alloc_hider : _Alloc
3164 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3165 : _Alloc(__a), _M_p(__dat) { }
3175 static const size_type npos =
static_cast<size_type
>(-1);
3179 mutable _Alloc_hider _M_dataplus;
3182 _M_data() const _GLIBCXX_NOEXCEPT
3183 {
return _M_dataplus._M_p; }
3186 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3187 {
return (_M_dataplus._M_p = __p); }
3190 _M_rep()
const _GLIBCXX_NOEXCEPT
3191 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3196 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3197 {
return iterator(_M_data()); }
3200 _M_iend()
const _GLIBCXX_NOEXCEPT
3201 {
return iterator(_M_data() + this->
size()); }
3206 if (!_M_rep()->_M_is_leaked())
3211 _M_check(size_type __pos,
const char* __s)
const 3213 if (__pos > this->
size())
3214 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3215 "this->size() (which is %zu)"),
3216 __s, __pos, this->
size());
3221 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3224 __throw_length_error(__N(__s));
3229 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3231 const bool __testoff = __off < this->
size() - __pos;
3232 return __testoff ? __off : this->
size() - __pos;
3237 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3246 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3249 traits_type::assign(*__d, *__s);
3251 traits_type::copy(__d, __s, __n);
3255 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3258 traits_type::assign(*__d, *__s);
3260 traits_type::move(__d, __s, __n);
3264 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3267 traits_type::assign(*__d, __c);
3269 traits_type::assign(__d, __n, __c);
3274 template<
class _Iterator>
3276 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3278 for (; __k1 != __k2; ++__k1, (void)++__p)
3279 traits_type::assign(*__p, *__k1);
3283 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3284 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3287 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3289 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3292 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3293 { _M_copy(__p, __k1, __k2 - __k1); }
3296 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3298 { _M_copy(__p, __k1, __k2 - __k1); }
3301 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3303 const difference_type __d = difference_type(__n1 - __n2);
3305 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3306 return __gnu_cxx::__numeric_traits<int>::__max;
3307 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3308 return __gnu_cxx::__numeric_traits<int>::__min;
3314 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3320 _S_empty_rep() _GLIBCXX_NOEXCEPT
3321 {
return _Rep::_S_empty_rep(); }
3323 #if __cplusplus > 201402L 3325 typedef basic_string_view<_CharT, _Traits> __sv_type;
3327 template<
typename _Tp,
typename _Res>
3328 using _If_sv = enable_if_t<
3329 __and_<is_convertible<const _Tp&, __sv_type>,
3330 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3343 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3344 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3346 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3370 basic_string(
const basic_string& __str, size_type __pos,
3371 const _Alloc& __a = _Alloc());
3379 basic_string(
const basic_string& __str, size_type __pos,
3388 basic_string(
const basic_string& __str, size_type __pos,
3389 size_type __n,
const _Alloc& __a);
3401 const _Alloc& __a = _Alloc());
3407 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3414 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3416 #if __cplusplus >= 201103L 3425 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3428 : _M_dataplus(__str._M_dataplus)
3430 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3431 __str._M_data(_S_empty_rep()._M_refdata());
3433 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3451 template<
class _InputIterator>
3452 basic_string(_InputIterator __beg, _InputIterator __end,
3453 const _Alloc& __a = _Alloc());
3455 #if __cplusplus > 201402L 3463 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3464 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3465 const _Alloc& __a = _Alloc())
3474 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
3490 {
return this->
assign(__str); }
3498 {
return this->
assign(__s); }
3514 #if __cplusplus >= 201103L 3538 this->
assign(__l.begin(), __l.size());
3543 #if __cplusplus > 201402L 3550 {
return this->
assign(__sv); }
3556 operator __sv_type()
const noexcept
3557 {
return __sv_type(
data(),
size()); }
3569 return iterator(_M_data());
3578 {
return const_iterator(_M_data()); }
3588 return iterator(_M_data() + this->
size());
3597 {
return const_iterator(_M_data() + this->
size()); }
3606 {
return reverse_iterator(this->
end()); }
3613 const_reverse_iterator
3615 {
return const_reverse_iterator(this->
end()); }
3624 {
return reverse_iterator(this->
begin()); }
3631 const_reverse_iterator
3633 {
return const_reverse_iterator(this->
begin()); }
3635 #if __cplusplus >= 201103L 3642 {
return const_iterator(this->_M_data()); }
3650 {
return const_iterator(this->_M_data() + this->
size()); }
3657 const_reverse_iterator
3659 {
return const_reverse_iterator(this->
end()); }
3666 const_reverse_iterator
3668 {
return const_reverse_iterator(this->
begin()); }
3677 {
return _M_rep()->_M_length; }
3683 {
return _M_rep()->_M_length; }
3688 {
return _Rep::_S_max_size; }
3701 resize(size_type __n, _CharT __c);
3715 { this->
resize(__n, _CharT()); }
3717 #if __cplusplus >= 201103L 3722 #if __cpp_exceptions 3740 {
return _M_rep()->_M_capacity; }
3760 reserve(size_type __res_arg = 0);
3765 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3769 if (_M_rep()->_M_is_shared())
3772 _M_data(_S_empty_rep()._M_refdata());
3775 _M_rep()->_M_set_length_and_sharable(0);
3781 { _M_mutate(0, this->
size(), 0); }
3790 {
return this->
size() == 0; }
3806 __glibcxx_assert(__pos <=
size());
3807 return _M_data()[__pos];
3825 __glibcxx_assert(__pos <=
size());
3827 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3829 return _M_data()[__pos];
3845 if (__n >= this->
size())
3846 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3847 "(which is %zu) >= this->size() " 3850 return _M_data()[__n];
3868 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3869 "(which is %zu) >= this->size() " 3873 return _M_data()[__n];
3876 #if __cplusplus >= 201103L 3884 __glibcxx_assert(!
empty());
3895 __glibcxx_assert(!
empty());
3906 __glibcxx_assert(!
empty());
3917 __glibcxx_assert(!
empty());
3930 {
return this->
append(__str); }
3939 {
return this->
append(__s); }
3953 #if __cplusplus >= 201103L 3961 {
return this->
append(__l.begin(), __l.size()); }
3964 #if __cplusplus > 201402L 3972 {
return this->
append(__sv); }
3981 append(
const basic_string& __str);
3997 append(
const basic_string& __str, size_type __pos, size_type __n);
4006 append(
const _CharT* __s, size_type __n);
4016 __glibcxx_requires_string(__s);
4017 return this->
append(__s, traits_type::length(__s));
4029 append(size_type __n, _CharT __c);
4031 #if __cplusplus >= 201103L 4039 {
return this->
append(__l.begin(), __l.size()); }
4050 template<
class _InputIterator>
4052 append(_InputIterator __first, _InputIterator __last)
4053 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4055 #if __cplusplus > 201402L 4063 {
return this->
append(__sv.data(), __sv.size()); }
4072 template <
typename _Tp>
4073 _If_sv<_Tp, basic_string&>
4074 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4076 __sv_type __sv = __svt;
4077 return append(__sv.data()
4078 + __sv._M_check(__pos,
"basic_string::append"),
4079 __sv._M_limit(__pos, __n));
4090 const size_type __len = 1 + this->
size();
4091 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4093 traits_type::assign(_M_data()[this->
size()], __c);
4094 _M_rep()->_M_set_length_and_sharable(__len);
4103 assign(
const basic_string& __str);
4105 #if __cplusplus >= 201103L 4137 assign(
const basic_string& __str, size_type __pos, size_type __n)
4138 {
return this->
assign(__str._M_data()
4139 + __str._M_check(__pos,
"basic_string::assign"),
4140 __str._M_limit(__pos, __n)); }
4153 assign(
const _CharT* __s, size_type __n);
4167 __glibcxx_requires_string(__s);
4168 return this->
assign(__s, traits_type::length(__s));
4182 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4192 template<
class _InputIterator>
4194 assign(_InputIterator __first, _InputIterator __last)
4195 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4197 #if __cplusplus >= 201103L 4205 {
return this->
assign(__l.begin(), __l.size()); }
4208 #if __cplusplus > 201402L 4216 {
return this->
assign(__sv.data(), __sv.size()); }
4225 template <
typename _Tp>
4226 _If_sv<_Tp, basic_string&>
4227 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4229 __sv_type __sv = __svt;
4230 return assign(__sv.data()
4231 + __sv._M_check(__pos,
"basic_string::assign"),
4232 __sv._M_limit(__pos, __n));
4250 insert(iterator __p, size_type __n, _CharT __c)
4251 { this->
replace(__p, __p, __n, __c); }
4265 template<
class _InputIterator>
4267 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4268 { this->
replace(__p, __p, __beg, __end); }
4270 #if __cplusplus >= 201103L 4280 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4281 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4298 insert(size_type __pos1,
const basic_string& __str)
4299 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4320 insert(size_type __pos1,
const basic_string& __str,
4321 size_type __pos2, size_type __n)
4322 {
return this->
insert(__pos1, __str._M_data()
4323 + __str._M_check(__pos2,
"basic_string::insert"),
4324 __str._M_limit(__pos2, __n)); }
4343 insert(size_type __pos,
const _CharT* __s, size_type __n);
4363 __glibcxx_requires_string(__s);
4364 return this->
insert(__pos, __s, traits_type::length(__s));
4384 insert(size_type __pos, size_type __n, _CharT __c)
4385 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4386 size_type(0), __n, __c); }
4404 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4405 const size_type __pos = __p - _M_ibegin();
4406 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4407 _M_rep()->_M_set_leaked();
4408 return iterator(_M_data() + __pos);
4411 #if __cplusplus > 201402L 4419 insert(size_type __pos, __sv_type __sv)
4420 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
4431 template <
typename _Tp>
4432 _If_sv<_Tp, basic_string&>
4433 insert(size_type __pos1,
const _Tp& __svt,
4434 size_type __pos2, size_type __n = npos)
4436 __sv_type __sv = __svt;
4437 return this->
replace(__pos1, size_type(0), __sv.data()
4438 + __sv._M_check(__pos2,
"basic_string::insert"),
4439 __sv._M_limit(__pos2, __n));
4459 erase(size_type __pos = 0, size_type __n = npos)
4461 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4462 _M_limit(__pos, __n), size_type(0));
4477 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4478 && __position < _M_iend());
4479 const size_type __pos = __position - _M_ibegin();
4480 _M_mutate(__pos, size_type(1), size_type(0));
4481 _M_rep()->_M_set_leaked();
4482 return iterator(_M_data() + __pos);
4495 erase(iterator __first, iterator __last);
4497 #if __cplusplus >= 201103L 4506 __glibcxx_assert(!
empty());
4529 replace(size_type __pos, size_type __n,
const basic_string& __str)
4530 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4551 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4552 size_type __pos2, size_type __n2)
4553 {
return this->
replace(__pos1, __n1, __str._M_data()
4554 + __str._M_check(__pos2,
"basic_string::replace"),
4555 __str._M_limit(__pos2, __n2)); }
4576 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4596 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4598 __glibcxx_requires_string(__s);
4599 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4620 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4621 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4622 _M_limit(__pos, __n1), __n2, __c); }
4638 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4639 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4657 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4659 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4660 && __i2 <= _M_iend());
4661 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4678 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4680 __glibcxx_requires_string(__s);
4681 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4699 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4701 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4702 && __i2 <= _M_iend());
4703 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4721 template<
class _InputIterator>
4724 _InputIterator __k1, _InputIterator __k2)
4726 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4727 && __i2 <= _M_iend());
4728 __glibcxx_requires_valid_range(__k1, __k2);
4729 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4730 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4736 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4738 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4739 && __i2 <= _M_iend());
4740 __glibcxx_requires_valid_range(__k1, __k2);
4741 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4746 replace(iterator __i1, iterator __i2,
4747 const _CharT* __k1,
const _CharT* __k2)
4749 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4750 && __i2 <= _M_iend());
4751 __glibcxx_requires_valid_range(__k1, __k2);
4752 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4757 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4759 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4760 && __i2 <= _M_iend());
4761 __glibcxx_requires_valid_range(__k1, __k2);
4762 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4763 __k1.base(), __k2 - __k1);
4767 replace(iterator __i1, iterator __i2,
4768 const_iterator __k1, const_iterator __k2)
4770 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4771 && __i2 <= _M_iend());
4772 __glibcxx_requires_valid_range(__k1, __k2);
4773 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4774 __k1.base(), __k2 - __k1);
4777 #if __cplusplus >= 201103L 4792 basic_string&
replace(iterator __i1, iterator __i2,
4794 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4797 #if __cplusplus > 201402L 4806 replace(size_type __pos, size_type __n, __sv_type __sv)
4807 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
4818 template <
typename _Tp>
4819 _If_sv<_Tp, basic_string&>
4820 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4821 size_type __pos2, size_type __n2 = npos)
4823 __sv_type __sv = __svt;
4824 return this->
replace(__pos1, __n1, __sv.data()
4825 + __sv._M_check(__pos2,
"basic_string::replace"),
4826 __sv._M_limit(__pos2, __n2));
4839 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
4840 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
4844 template<
class _Integer>
4846 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4847 _Integer __val, __true_type)
4848 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4850 template<
class _InputIterator>
4852 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4853 _InputIterator __k2, __false_type);
4856 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4860 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4865 template<
class _InIterator>
4867 _S_construct_aux(_InIterator __beg, _InIterator __end,
4868 const _Alloc& __a, __false_type)
4870 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4871 return _S_construct(__beg, __end, __a, _Tag());
4876 template<
class _Integer>
4878 _S_construct_aux(_Integer __beg, _Integer __end,
4879 const _Alloc& __a, __true_type)
4880 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4884 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4885 {
return _S_construct(__req, __c, __a); }
4887 template<
class _InIterator>
4889 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4891 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4892 return _S_construct_aux(__beg, __end, __a, _Integral());
4896 template<
class _InIterator>
4898 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4903 template<
class _FwdIterator>
4905 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4909 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4926 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4937 swap(basic_string& __s);
4948 {
return _M_data(); }
4960 {
return _M_data(); }
4962 #if __cplusplus > 201402L 4971 {
return _M_data(); }
4979 {
return _M_dataplus; }
4994 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5008 find(
const basic_string& __str, size_type __pos = 0) const
5010 {
return this->
find(__str.data(), __pos, __str.size()); }
5023 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5025 __glibcxx_requires_string(__s);
5026 return this->
find(__s, __pos, traits_type::length(__s));
5040 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5042 #if __cplusplus > 201402L 5050 find(__sv_type __sv, size_type __pos = 0)
const noexcept
5051 {
return this->
find(__sv.data(), __pos, __sv.size()); }
5065 rfind(
const basic_string& __str, size_type __pos = npos)
const 5067 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5082 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5096 rfind(
const _CharT* __s, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
5098 __glibcxx_requires_string(__s);
5099 return this->
rfind(__s, __pos, traits_type::length(__s));
5113 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5115 #if __cplusplus > 201402L 5123 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
5124 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
5141 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5156 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5173 __glibcxx_requires_string(__s);
5174 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5191 {
return this->
find(__c, __pos); }
5193 #if __cplusplus > 201402L 5201 find_first_of(__sv_type __sv, size_type __pos = 0)
const noexcept
5202 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
5219 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5234 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5251 __glibcxx_requires_string(__s);
5252 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5269 {
return this->
rfind(__c, __pos); }
5271 #if __cplusplus > 201402L 5279 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
5280 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
5312 size_type __n)
const _GLIBCXX_NOEXCEPT;
5328 __glibcxx_requires_string(__s);
5346 #if __cplusplus > 201402L 5388 size_type __n)
const _GLIBCXX_NOEXCEPT;
5404 __glibcxx_requires_string(__s);
5422 #if __cplusplus > 201402L 5447 substr(size_type __pos = 0, size_type __n = npos)
const 5449 _M_check(__pos,
"basic_string::substr"), __n); }
5468 const size_type __size = this->
size();
5469 const size_type __osize = __str.size();
5470 const size_type __len =
std::min(__size, __osize);
5472 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5474 __r = _S_compare(__size, __osize);
5478 #if __cplusplus > 201402L 5487 const size_type __size = this->
size();
5488 const size_type __osize = __sv.size();
5489 const size_type __len =
std::min(__size, __osize);
5491 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5493 __r = _S_compare(__size, __osize);
5505 compare(size_type __pos, size_type __n, __sv_type __sv)
const 5506 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
5517 template <
typename _Tp>
5519 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5520 size_type __pos2, size_type __n2 = npos)
const 5522 __sv_type __sv = __svt;
5523 return __sv_type(*
this)
5524 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5548 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5574 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5575 size_type __pos2, size_type __n2)
const;
5592 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5616 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5643 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5644 size_type __n2)
const;
5646 # ifdef _GLIBCXX_TM_TS_INTERNAL 5648 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5651 ::_txnal_cow_string_c_str(
const void *that);
5653 ::_txnal_cow_string_D1(
void *that);
5655 ::_txnal_cow_string_D1_commit(
void *that);
5658 #endif // !_GLIBCXX_USE_CXX11_ABI 5667 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5673 __str.append(__rhs);
5683 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5694 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5704 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5707 const _CharT* __rhs)
5710 __str.append(__rhs);
5720 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5725 typedef typename __string_type::size_type __size_type;
5726 __string_type __str(__lhs);
5727 __str.append(__size_type(1), __rhs);
5731 #if __cplusplus >= 201103L 5732 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5736 {
return std::move(__lhs.append(__rhs)); }
5738 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5742 {
return std::move(__rhs.insert(0, __lhs)); }
5744 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5749 const auto __size = __lhs.size() + __rhs.size();
5750 const bool __cond = (__size > __lhs.capacity()
5751 && __size <= __rhs.capacity());
5752 return __cond ? std::move(__rhs.insert(0, __lhs))
5753 : std::move(__lhs.append(__rhs));
5756 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5760 {
return std::move(__rhs.insert(0, __lhs)); }
5762 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5766 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5768 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5771 const _CharT* __rhs)
5772 {
return std::move(__lhs.append(__rhs)); }
5774 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5778 {
return std::move(__lhs.append(1, __rhs)); }
5788 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5793 {
return __lhs.compare(__rhs) == 0; }
5795 template<
typename _CharT>
5797 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5800 {
return (__lhs.
size() == __rhs.
size()
5810 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5812 operator==(
const _CharT* __lhs,
5814 {
return __rhs.compare(__lhs) == 0; }
5822 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5825 const _CharT* __rhs)
5826 {
return __lhs.compare(__rhs) == 0; }
5835 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5840 {
return !(__lhs == __rhs); }
5848 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5850 operator!=(
const _CharT* __lhs,
5852 {
return !(__lhs == __rhs); }
5860 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5863 const _CharT* __rhs)
5864 {
return !(__lhs == __rhs); }
5873 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5875 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5878 {
return __lhs.
compare(__rhs) < 0; }
5886 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5888 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5889 const _CharT* __rhs)
5890 {
return __lhs.
compare(__rhs) < 0; }
5898 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5900 operator<(
const _CharT* __lhs,
5902 {
return __rhs.compare(__lhs) > 0; }
5911 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5916 {
return __lhs.compare(__rhs) > 0; }
5924 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5927 const _CharT* __rhs)
5928 {
return __lhs.compare(__rhs) > 0; }
5936 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5938 operator>(
const _CharT* __lhs,
5940 {
return __rhs.compare(__lhs) < 0; }
5949 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5951 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5954 {
return __lhs.
compare(__rhs) <= 0; }
5962 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5964 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5965 const _CharT* __rhs)
5966 {
return __lhs.
compare(__rhs) <= 0; }
5974 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5976 operator<=(
const _CharT* __lhs,
5978 {
return __rhs.compare(__lhs) >= 0; }
5987 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5992 {
return __lhs.compare(__rhs) >= 0; }
6000 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6003 const _CharT* __rhs)
6004 {
return __lhs.compare(__rhs) >= 0; }
6012 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6014 operator>=(
const _CharT* __lhs,
6016 {
return __rhs.compare(__lhs) <= 0; }
6025 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6029 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6030 { __lhs.swap(__rhs); }
6045 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6063 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6065 operator<<(basic_ostream<_CharT, _Traits>& __os,
6070 return __ostream_insert(__os, __str.
data(), __str.
size());
6086 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6109 #if __cplusplus >= 201103L 6111 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6118 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6130 #ifdef _GLIBCXX_USE_WCHAR_T 6137 _GLIBCXX_END_NAMESPACE_VERSION
6140 #if __cplusplus >= 201103L 6144 namespace std _GLIBCXX_VISIBILITY(default)
6146 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6147 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6149 #if _GLIBCXX_USE_C99_STDLIB 6152 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6153 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
6157 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6158 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
6161 inline unsigned long 6162 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6163 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
6167 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6168 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
6171 inline unsigned long long 6172 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6173 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
6178 stof(
const string& __str,
size_t* __idx = 0)
6179 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
6182 stod(
const string& __str,
size_t* __idx = 0)
6183 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
6186 stold(
const string& __str,
size_t* __idx = 0)
6187 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
6188 #endif // _GLIBCXX_USE_C99_STDLIB 6190 #if _GLIBCXX_USE_C99_STDIO 6195 to_string(
int __val)
6196 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6200 to_string(
unsigned __val)
6201 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6202 4 *
sizeof(unsigned),
6206 to_string(
long __val)
6207 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6211 to_string(
unsigned long __val)
6212 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6213 4 *
sizeof(
unsigned long),
6217 to_string(
long long __val)
6218 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6219 4 *
sizeof(
long long),
6223 to_string(
unsigned long long __val)
6224 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6225 4 *
sizeof(
unsigned long long),
6229 to_string(
float __val)
6232 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6233 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6238 to_string(
double __val)
6241 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6242 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6247 to_string(
long double __val)
6250 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6251 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6254 #endif // _GLIBCXX_USE_C99_STDIO 6256 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6258 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6259 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6263 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6264 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6267 inline unsigned long 6268 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6269 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6273 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6274 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6277 inline unsigned long long 6278 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6279 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6284 stof(
const wstring& __str,
size_t* __idx = 0)
6285 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6288 stod(
const wstring& __str,
size_t* __idx = 0)
6289 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6292 stold(
const wstring& __str,
size_t* __idx = 0)
6293 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6295 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6298 to_wstring(
int __val)
6299 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6303 to_wstring(
unsigned __val)
6304 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6305 4 *
sizeof(unsigned),
6309 to_wstring(
long __val)
6310 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6314 to_wstring(
unsigned long __val)
6315 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6316 4 *
sizeof(
unsigned long),
6320 to_wstring(
long long __val)
6321 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6322 4 *
sizeof(
long long),
6326 to_wstring(
unsigned long long __val)
6327 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6328 4 *
sizeof(
unsigned long long),
6332 to_wstring(
float __val)
6335 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6336 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6341 to_wstring(
double __val)
6344 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6345 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6350 to_wstring(
long double __val)
6353 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6354 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6357 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6358 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6360 _GLIBCXX_END_NAMESPACE_CXX11
6361 _GLIBCXX_END_NAMESPACE_VERSION
6366 #if __cplusplus >= 201103L 6370 namespace std _GLIBCXX_VISIBILITY(default)
6372 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6376 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6380 :
public __hash_base<size_t, string>
6383 operator()(
const string& __s)
const noexcept
6384 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6391 #ifdef _GLIBCXX_USE_WCHAR_T 6395 :
public __hash_base<size_t, wstring>
6398 operator()(
const wstring& __s)
const noexcept
6399 {
return std::_Hash_impl::hash(__s.
data(),
6400 __s.
length() *
sizeof(wchar_t)); }
6409 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6413 :
public __hash_base<size_t, u16string>
6416 operator()(
const u16string& __s)
const noexcept
6417 {
return std::_Hash_impl::hash(__s.
data(),
6418 __s.
length() *
sizeof(char16_t)); }
6428 :
public __hash_base<size_t, u32string>
6431 operator()(
const u32string& __s)
const noexcept
6432 {
return std::_Hash_impl::hash(__s.
data(),
6433 __s.
length() *
sizeof(char32_t)); }
6441 _GLIBCXX_END_NAMESPACE_VERSION
6443 #if __cplusplus > 201103L 6445 #define __cpp_lib_string_udls 201304 6447 inline namespace literals
6449 inline namespace string_literals
6451 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6453 _GLIBCXX_DEFAULT_ABI_TAG
6455 operator""s(
const char* __str,
size_t __len)
6458 #ifdef _GLIBCXX_USE_WCHAR_T 6459 _GLIBCXX_DEFAULT_ABI_TAG
6461 operator""s(
const wchar_t* __str,
size_t __len)
6465 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6466 _GLIBCXX_DEFAULT_ABI_TAG
6468 operator""s(
const char16_t* __str,
size_t __len)
6471 _GLIBCXX_DEFAULT_ABI_TAG
6473 operator""s(
const char32_t* __str,
size_t __len)
6477 _GLIBCXX_END_NAMESPACE_VERSION
6481 #endif // __cplusplus > 201103L const_iterator end() const noexcept
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
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.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
const_reference front() const noexcept
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
char_type widen(char __c) const
Widens characters.
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().
iterator insert(iterator __p, _CharT __c)
Insert one 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.
Primary class template hash.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
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.
basic_string & operator+=(_CharT __c)
Append a character.
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 crbegin() const noexcept
const_reverse_iterator rend() 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.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
const_reference back() const noexcept
const_iterator begin() const noexcept
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
iterator erase(iterator __position)
Remove one character.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
Template class basic_ostream.
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.
basic_string & append(const _CharT *__s)
Append a C string.
Uniform interface to all pointer-like types.
const_iterator cbegin() const noexcept
void push_back(_CharT __c)
Append a single character.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
reverse_iterator rbegin()
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 & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
~basic_string() noexcept
Destroy the string instance.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & operator+=(const _CharT *__s)
Append a C string.
const_iterator cend() const noexcept
const_reverse_iterator rbegin() const noexcept
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
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.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
void pop_back()
Remove the last character.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
Managing sequences of characters and character-like objects.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
One of the comparison functors.
Forward iterators support a superset of input iterator operations.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string()
Default constructor creates an empty string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
Uniform interface to C++98 and C++11 allocators.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the 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.
int compare(const basic_string &__str) const
Compare to a string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
static const size_type npos
Value returned by various member functions when they fail.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of 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.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
const _CharT * data() const noexcept
Return const pointer to contents.
Template class basic_istream.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & append(const basic_string &__str)
Append a string to this string.
Basis for explicit traits specializations.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.