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);
396 #if __cplusplus >= 201103L 402 { this->_M_assign(__str); }
414 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
415 : _M_dataplus(_M_local_data())
416 { _M_set_length(0); }
423 : _M_dataplus(_M_local_data(), __a)
424 { _M_set_length(0); }
431 : _M_dataplus(_M_local_data(),
432 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
433 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
444 const _Alloc& __a = _Alloc())
445 : _M_dataplus(_M_local_data(), __a)
447 const _CharT* __start = __str._M_data()
448 + __str._M_check(__pos,
"basic_string::basic_string");
449 _M_construct(__start, __start + __str._M_limit(__pos, npos));
458 basic_string(
const basic_string& __str, size_type __pos,
460 : _M_dataplus(_M_local_data())
462 const _CharT* __start = __str._M_data()
463 + __str._M_check(__pos,
"basic_string::basic_string");
464 _M_construct(__start, __start + __str._M_limit(__pos, __n));
474 basic_string(
const basic_string& __str, size_type __pos,
475 size_type __n,
const _Alloc& __a)
476 : _M_dataplus(_M_local_data(), __a)
478 const _CharT* __start
479 = __str._M_data() + __str._M_check(__pos,
"string::string");
480 _M_construct(__start, __start + __str._M_limit(__pos, __n));
493 const _Alloc& __a = _Alloc())
494 : _M_dataplus(_M_local_data(), __a)
495 { _M_construct(__s, __s + __n); }
502 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
503 : _M_dataplus(_M_local_data(), __a)
504 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
512 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
513 : _M_dataplus(_M_local_data(), __a)
514 { _M_construct(__n, __c); }
516 #if __cplusplus >= 201103L 525 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
527 if (__str._M_is_local())
529 traits_type::copy(_M_local_buf, __str._M_local_buf,
530 _S_local_capacity + 1);
534 _M_data(__str._M_data());
535 _M_capacity(__str._M_allocated_capacity);
541 _M_length(__str.length());
542 __str._M_data(__str._M_local_data());
543 __str._M_set_length(0);
551 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
552 : _M_dataplus(_M_local_data(), __a)
553 { _M_construct(__l.begin(), __l.end()); }
555 basic_string(
const basic_string& __str,
const _Alloc& __a)
556 : _M_dataplus(_M_local_data(), __a)
557 { _M_construct(__str.begin(), __str.end()); }
560 noexcept(_Alloc_traits::_S_always_equal())
561 : _M_dataplus(_M_local_data(), __a)
563 if (__str._M_is_local())
565 traits_type::copy(_M_local_buf, __str._M_local_buf,
566 _S_local_capacity + 1);
567 _M_length(__str.length());
568 __str._M_set_length(0);
570 else if (_Alloc_traits::_S_always_equal()
571 || __str.get_allocator() == __a)
573 _M_data(__str._M_data());
574 _M_length(__str.length());
575 _M_capacity(__str._M_allocated_capacity);
576 __str._M_data(__str._M_local_buf);
577 __str._M_set_length(0);
580 _M_construct(__str.begin(), __str.end());
591 #if __cplusplus >= 201103L 592 template<
typename _InputIterator,
593 typename = std::_RequireInputIter<_InputIterator>>
595 template<
typename _InputIterator>
597 basic_string(_InputIterator __beg, _InputIterator __end,
598 const _Alloc& __a = _Alloc())
599 : _M_dataplus(_M_local_data(), __a)
600 { _M_construct(__beg, __end); }
602 #if __cplusplus > 201402L 610 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
611 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
612 const _Alloc& __a = _Alloc())
613 : basic_string(__sv_type(__t).
substr(__pos, __n), __a) { }
621 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
622 : basic_string(__sv.
data(), __sv.
size(), __a) { }
638 #if __cplusplus >= 201103L 639 _M_copy_assign(__str,
640 typename _Alloc_traits::propagate_on_container_copy_assignment());
642 this->_M_assign(__str);
653 {
return this->
assign(__s); }
669 #if __cplusplus >= 201103L 682 noexcept(_Alloc_traits::_S_nothrow_move())
684 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
685 && !_Alloc_traits::_S_always_equal()
686 && _M_get_allocator() != __str._M_get_allocator())
689 _M_destroy(_M_allocated_capacity);
690 _M_data(_M_local_data());
694 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
696 if (!__str._M_is_local()
697 && (_Alloc_traits::_S_propagate_on_move_assign()
698 || _Alloc_traits::_S_always_equal()))
700 pointer __data =
nullptr;
701 size_type __capacity;
704 if (_Alloc_traits::_S_always_equal())
707 __capacity = _M_allocated_capacity;
710 _M_destroy(_M_allocated_capacity);
713 _M_data(__str._M_data());
714 _M_length(__str.length());
715 _M_capacity(__str._M_allocated_capacity);
718 __str._M_data(__data);
719 __str._M_capacity(__capacity);
722 __str._M_data(__str._M_local_buf);
737 this->
assign(__l.begin(), __l.size());
742 #if __cplusplus > 201402L 749 {
return this->
assign(__sv); }
755 operator __sv_type() const noexcept
756 {
return __sv_type(
data(),
size()); }
765 begin() _GLIBCXX_NOEXCEPT
766 {
return iterator(_M_data()); }
773 begin() const _GLIBCXX_NOEXCEPT
774 {
return const_iterator(_M_data()); }
781 end() _GLIBCXX_NOEXCEPT
782 {
return iterator(_M_data() + this->
size()); }
789 end() const _GLIBCXX_NOEXCEPT
790 {
return const_iterator(_M_data() + this->
size()); }
798 rbegin() _GLIBCXX_NOEXCEPT
799 {
return reverse_iterator(this->
end()); }
806 const_reverse_iterator
807 rbegin() const _GLIBCXX_NOEXCEPT
808 {
return const_reverse_iterator(this->
end()); }
816 rend() _GLIBCXX_NOEXCEPT
817 {
return reverse_iterator(this->
begin()); }
824 const_reverse_iterator
825 rend() const _GLIBCXX_NOEXCEPT
826 {
return const_reverse_iterator(this->
begin()); }
828 #if __cplusplus >= 201103L 835 {
return const_iterator(this->_M_data()); }
842 cend() const noexcept
843 {
return const_iterator(this->_M_data() + this->
size()); }
850 const_reverse_iterator
852 {
return const_reverse_iterator(this->
end()); }
859 const_reverse_iterator
860 crend() const noexcept
861 {
return const_reverse_iterator(this->
begin()); }
869 size() const _GLIBCXX_NOEXCEPT
870 {
return _M_string_length; }
875 length() const _GLIBCXX_NOEXCEPT
876 {
return _M_string_length; }
881 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
894 resize(size_type __n, _CharT __c);
908 { this->
resize(__n, _CharT()); }
910 #if __cplusplus >= 201103L 934 return _M_is_local() ? size_type(_S_local_capacity)
935 : _M_allocated_capacity;
956 reserve(size_type __res_arg = 0);
962 clear() _GLIBCXX_NOEXCEPT
963 { _M_set_length(0); }
970 empty() const _GLIBCXX_NOEXCEPT
971 {
return this->
size() == 0; }
985 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
987 __glibcxx_assert(__pos <=
size());
988 return _M_data()[__pos];
1006 __glibcxx_assert(__pos <=
size());
1008 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1009 return _M_data()[__pos];
1023 at(size_type __n)
const 1025 if (__n >= this->
size())
1026 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1027 "(which is %zu) >= this->size() " 1030 return _M_data()[__n];
1047 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1048 "(which is %zu) >= this->size() " 1051 return _M_data()[__n];
1054 #if __cplusplus >= 201103L 1062 __glibcxx_assert(!
empty());
1071 front() const noexcept
1073 __glibcxx_assert(!
empty());
1084 __glibcxx_assert(!
empty());
1093 back() const noexcept
1095 __glibcxx_assert(!
empty());
1108 {
return this->
append(__str); }
1117 {
return this->
append(__s); }
1131 #if __cplusplus >= 201103L 1139 {
return this->
append(__l.begin(), __l.size()); }
1142 #if __cplusplus > 201402L 1150 {
return this->
append(__sv); }
1159 append(
const basic_string& __str)
1160 {
return _M_append(__str._M_data(), __str.size()); }
1176 append(
const basic_string& __str, size_type __pos, size_type __n)
1177 {
return _M_append(__str._M_data()
1178 + __str._M_check(__pos,
"basic_string::append"),
1179 __str._M_limit(__pos, __n)); }
1188 append(
const _CharT* __s, size_type __n)
1190 __glibcxx_requires_string_len(__s, __n);
1191 _M_check_length(size_type(0), __n,
"basic_string::append");
1192 return _M_append(__s, __n);
1201 append(
const _CharT* __s)
1203 __glibcxx_requires_string(__s);
1204 const size_type __n = traits_type::length(__s);
1205 _M_check_length(size_type(0), __n,
"basic_string::append");
1206 return _M_append(__s, __n);
1218 append(size_type __n, _CharT __c)
1219 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1221 #if __cplusplus >= 201103L 1228 append(initializer_list<_CharT> __l)
1229 {
return this->
append(__l.begin(), __l.size()); }
1240 #if __cplusplus >= 201103L 1241 template<
class _InputIterator,
1242 typename = std::_RequireInputIter<_InputIterator>>
1244 template<
class _InputIterator>
1247 append(_InputIterator __first, _InputIterator __last)
1250 #if __cplusplus > 201402L 1258 {
return this->
append(__sv.data(), __sv.size()); }
1267 template <
typename _Tp>
1268 _If_sv<_Tp, basic_string&>
1269 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1271 __sv_type __sv = __svt;
1272 return _M_append(__sv.data()
1273 + __sv._M_check(__pos,
"basic_string::append"),
1274 __sv._M_limit(__pos, __n));
1285 const size_type __size = this->
size();
1287 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1288 traits_type::assign(this->_M_data()[__size], __c);
1289 this->_M_set_length(__size + 1);
1298 assign(
const basic_string& __str)
1300 this->_M_assign(__str);
1304 #if __cplusplus >= 201103L 1314 assign(basic_string&& __str)
1315 noexcept(_Alloc_traits::_S_nothrow_move())
1319 return *
this = std::move(__str);
1337 assign(
const basic_string& __str, size_type __pos, size_type __n)
1338 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1339 + __str._M_check(__pos,
"basic_string::assign"),
1340 __str._M_limit(__pos, __n)); }
1353 assign(
const _CharT* __s, size_type __n)
1355 __glibcxx_requires_string_len(__s, __n);
1356 return _M_replace(size_type(0), this->
size(), __s, __n);
1369 assign(
const _CharT* __s)
1371 __glibcxx_requires_string(__s);
1372 return _M_replace(size_type(0), this->
size(), __s,
1373 traits_type::length(__s));
1386 assign(size_type __n, _CharT __c)
1387 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1397 #if __cplusplus >= 201103L 1398 template<
class _InputIterator,
1399 typename = std::_RequireInputIter<_InputIterator>>
1401 template<
class _InputIterator>
1404 assign(_InputIterator __first, _InputIterator __last)
1407 #if __cplusplus >= 201103L 1414 assign(initializer_list<_CharT> __l)
1415 {
return this->
assign(__l.begin(), __l.size()); }
1418 #if __cplusplus > 201402L 1426 {
return this->
assign(__sv.data(), __sv.size()); }
1435 template <
typename _Tp>
1436 _If_sv<_Tp, basic_string&>
1437 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1439 __sv_type __sv = __svt;
1440 return _M_replace(size_type(0), this->
size(), __sv.data()
1441 + __sv._M_check(__pos,
"basic_string::assign"),
1442 __sv._M_limit(__pos, __n));
1446 #if __cplusplus >= 201103L 1463 insert(const_iterator __p, size_type __n, _CharT __c)
1465 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1466 const size_type __pos = __p -
begin();
1467 this->
replace(__p, __p, __n, __c);
1468 return iterator(this->_M_data() + __pos);
1485 insert(iterator __p, size_type __n, _CharT __c)
1486 { this->
replace(__p, __p, __n, __c); }
1489 #if __cplusplus >= 201103L 1504 template<
class _InputIterator,
1505 typename = std::_RequireInputIter<_InputIterator>>
1507 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1509 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1510 const size_type __pos = __p -
begin();
1511 this->
replace(__p, __p, __beg, __end);
1512 return iterator(this->_M_data() + __pos);
1527 template<
class _InputIterator>
1529 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1530 { this->
replace(__p, __p, __beg, __end); }
1533 #if __cplusplus >= 201103L 1541 insert(iterator __p, initializer_list<_CharT> __l)
1543 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1544 this->
insert(__p -
begin(), __l.begin(), __l.size());
1561 insert(size_type __pos1,
const basic_string& __str)
1562 {
return this->
replace(__pos1, size_type(0),
1563 __str._M_data(), __str.size()); }
1584 insert(size_type __pos1,
const basic_string& __str,
1585 size_type __pos2, size_type __n)
1586 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1587 + __str._M_check(__pos2,
"basic_string::insert"),
1588 __str._M_limit(__pos2, __n)); }
1607 insert(size_type __pos,
const _CharT* __s, size_type __n)
1608 {
return this->
replace(__pos, size_type(0), __s, __n); }
1626 insert(size_type __pos,
const _CharT* __s)
1628 __glibcxx_requires_string(__s);
1629 return this->
replace(__pos, size_type(0), __s,
1630 traits_type::length(__s));
1650 insert(size_type __pos, size_type __n, _CharT __c)
1651 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1652 size_type(0), __n, __c); }
1668 insert(__const_iterator __p, _CharT __c)
1670 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1671 const size_type __pos = __p -
begin();
1672 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1673 return iterator(_M_data() + __pos);
1676 #if __cplusplus > 201402L 1684 insert(size_type __pos, __sv_type __sv)
1685 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
1696 template <
typename _Tp>
1697 _If_sv<_Tp, basic_string&>
1698 insert(size_type __pos1,
const _Tp& __svt,
1699 size_type __pos2, size_type __n = npos)
1701 __sv_type __sv = __svt;
1702 return this->
replace(__pos1, size_type(0), __sv.data()
1703 + __sv._M_check(__pos2,
"basic_string::insert"),
1704 __sv._M_limit(__pos2, __n));
1724 erase(size_type __pos = 0, size_type __n = npos)
1726 _M_check(__pos,
"basic_string::erase");
1728 this->_M_set_length(__pos);
1730 this->_M_erase(__pos, _M_limit(__pos, __n));
1743 erase(__const_iterator __position)
1745 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1746 && __position <
end());
1747 const size_type __pos = __position -
begin();
1748 this->_M_erase(__pos, size_type(1));
1749 return iterator(_M_data() + __pos);
1762 erase(__const_iterator __first, __const_iterator __last)
1764 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1765 && __last <=
end());
1766 const size_type __pos = __first -
begin();
1767 if (__last ==
end())
1768 this->_M_set_length(__pos);
1770 this->_M_erase(__pos, __last - __first);
1771 return iterator(this->_M_data() + __pos);
1774 #if __cplusplus >= 201103L 1783 __glibcxx_assert(!
empty());
1784 _M_erase(
size() - 1, 1);
1806 replace(size_type __pos, size_type __n,
const basic_string& __str)
1807 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1828 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1829 size_type __pos2, size_type __n2)
1830 {
return this->
replace(__pos1, __n1, __str._M_data()
1831 + __str._M_check(__pos2,
"basic_string::replace"),
1832 __str._M_limit(__pos2, __n2)); }
1853 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1856 __glibcxx_requires_string_len(__s, __n2);
1857 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1858 _M_limit(__pos, __n1), __s, __n2);
1878 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1880 __glibcxx_requires_string(__s);
1881 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1902 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1903 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1904 _M_limit(__pos, __n1), __n2, __c); }
1920 replace(__const_iterator __i1, __const_iterator __i2,
1921 const basic_string& __str)
1922 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1940 replace(__const_iterator __i1, __const_iterator __i2,
1941 const _CharT* __s, size_type __n)
1943 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1945 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1962 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1964 __glibcxx_requires_string(__s);
1965 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1983 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1986 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1988 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2006 #if __cplusplus >= 201103L 2007 template<
class _InputIterator,
2008 typename = std::_RequireInputIter<_InputIterator>>
2010 replace(const_iterator __i1, const_iterator __i2,
2011 _InputIterator __k1, _InputIterator __k2)
2013 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2015 __glibcxx_requires_valid_range(__k1, __k2);
2016 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2017 std::__false_type());
2020 template<
class _InputIterator>
2021 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2022 typename __enable_if_not_native_iterator<_InputIterator>::__type
2026 replace(iterator __i1, iterator __i2,
2027 _InputIterator __k1, _InputIterator __k2)
2029 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2031 __glibcxx_requires_valid_range(__k1, __k2);
2032 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2033 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2040 replace(__const_iterator __i1, __const_iterator __i2,
2041 _CharT* __k1, _CharT* __k2)
2043 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2045 __glibcxx_requires_valid_range(__k1, __k2);
2051 replace(__const_iterator __i1, __const_iterator __i2,
2052 const _CharT* __k1,
const _CharT* __k2)
2054 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2056 __glibcxx_requires_valid_range(__k1, __k2);
2062 replace(__const_iterator __i1, __const_iterator __i2,
2063 iterator __k1, iterator __k2)
2065 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2067 __glibcxx_requires_valid_range(__k1, __k2);
2069 __k1.base(), __k2 - __k1);
2073 replace(__const_iterator __i1, __const_iterator __i2,
2074 const_iterator __k1, const_iterator __k2)
2076 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2078 __glibcxx_requires_valid_range(__k1, __k2);
2080 __k1.base(), __k2 - __k1);
2083 #if __cplusplus >= 201103L 2098 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2099 initializer_list<_CharT> __l)
2100 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2103 #if __cplusplus > 201402L 2112 replace(size_type __pos, size_type __n, __sv_type __sv)
2113 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
2124 template <
typename _Tp>
2125 _If_sv<_Tp, basic_string&>
2126 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2127 size_type __pos2, size_type __n2 = npos)
2129 __sv_type __sv = __svt;
2130 return this->
replace(__pos1, __n1, __sv.data()
2131 + __sv._M_check(__pos2,
"basic_string::replace"),
2132 __sv._M_limit(__pos2, __n2));
2145 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
2146 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
2150 template<
class _Integer>
2152 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2153 _Integer __n, _Integer __val, __true_type)
2154 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2156 template<
class _InputIterator>
2158 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2159 _InputIterator __k1, _InputIterator __k2,
2163 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2167 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2168 const size_type __len2);
2171 _M_append(
const _CharT* __s, size_type __n);
2188 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2198 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2208 c_str() const _GLIBCXX_NOEXCEPT
2209 {
return _M_data(); }
2220 data() const _GLIBCXX_NOEXCEPT
2221 {
return _M_data(); }
2223 #if __cplusplus > 201402L 2232 {
return _M_data(); }
2240 {
return _M_get_allocator(); }
2255 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2269 find(
const basic_string& __str, size_type __pos = 0) const
2271 {
return this->
find(__str.data(), __pos, __str.size()); }
2273 #if __cplusplus > 201402L 2281 find(__sv_type __sv, size_type __pos = 0) const noexcept
2282 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2296 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2298 __glibcxx_requires_string(__s);
2299 return this->
find(__s, __pos, traits_type::length(__s));
2313 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2326 rfind(const basic_string& __str, size_type __pos = npos) const
2328 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2330 #if __cplusplus > 201402L 2338 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
2339 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2355 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2369 rfind(
const _CharT* __s, size_type __pos = npos)
const 2371 __glibcxx_requires_string(__s);
2372 return this->
rfind(__s, __pos, traits_type::length(__s));
2386 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
2400 find_first_of(
const basic_string& __str, size_type __pos = 0) const
2402 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2404 #if __cplusplus > 201402L 2412 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2413 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2429 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2446 __glibcxx_requires_string(__s);
2447 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2463 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2464 {
return this->
find(__c, __pos); }
2478 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 2480 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2482 #if __cplusplus > 201402L 2490 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
2491 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2507 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2521 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2524 __glibcxx_requires_string(__s);
2525 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2541 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
2542 {
return this->
rfind(__c, __pos); }
2559 #if __cplusplus > 201402L 2585 size_type __n)
const _GLIBCXX_NOEXCEPT;
2601 __glibcxx_requires_string(__s);
2635 #if __cplusplus > 201402L 2661 size_type __n)
const _GLIBCXX_NOEXCEPT;
2677 __glibcxx_requires_string(__s);
2708 substr(size_type __pos = 0, size_type __n = npos)
const 2710 _M_check(__pos,
"basic_string::substr"), __n); }
2727 compare(
const basic_string& __str)
const 2729 const size_type __size = this->
size();
2730 const size_type __osize = __str.size();
2731 const size_type __len =
std::min(__size, __osize);
2733 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2735 __r = _S_compare(__size, __osize);
2739 #if __cplusplus > 201402L 2748 const size_type __size = this->
size();
2749 const size_type __osize = __sv.size();
2750 const size_type __len =
std::min(__size, __osize);
2752 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2754 __r = _S_compare(__size, __osize);
2766 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2767 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2778 template <
typename _Tp>
2780 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2781 size_type __pos2, size_type __n2 = npos)
const 2783 __sv_type __sv = __svt;
2784 return __sv_type(*
this)
2785 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2809 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2835 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2836 size_type __pos2, size_type __n2)
const;
2853 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2877 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2904 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2905 size_type __n2)
const;
2907 _GLIBCXX_END_NAMESPACE_CXX11
2908 #else // !_GLIBCXX_USE_CXX11_ABI 2973 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2976 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2980 typedef _Traits traits_type;
2981 typedef typename _Traits::char_type value_type;
2982 typedef _Alloc allocator_type;
2983 typedef typename _CharT_alloc_type::size_type size_type;
2984 typedef typename _CharT_alloc_type::difference_type difference_type;
2985 typedef typename _CharT_alloc_type::reference reference;
2986 typedef typename _CharT_alloc_type::const_reference const_reference;
2987 typedef typename _CharT_alloc_type::pointer pointer;
2988 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2989 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2990 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3012 size_type _M_length;
3013 size_type _M_capacity;
3014 _Atomic_word _M_refcount;
3017 struct _Rep : _Rep_base
3020 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3035 static const size_type _S_max_size;
3036 static const _CharT _S_terminal;
3040 static size_type _S_empty_rep_storage[];
3043 _S_empty_rep() _GLIBCXX_NOEXCEPT
3048 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3049 return *
reinterpret_cast<_Rep*
>(__p);
3053 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3055 #if defined(__GTHREADS) 3060 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3062 return this->_M_refcount < 0;
3067 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3069 #if defined(__GTHREADS) 3075 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3077 return this->_M_refcount > 0;
3082 _M_set_leaked() _GLIBCXX_NOEXCEPT
3083 { this->_M_refcount = -1; }
3086 _M_set_sharable() _GLIBCXX_NOEXCEPT
3087 { this->_M_refcount = 0; }
3090 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3092 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3093 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3096 this->_M_set_sharable();
3097 this->_M_length = __n;
3098 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3105 _M_refdata()
throw()
3106 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3109 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3111 return (!_M_is_leaked() && __alloc1 == __alloc2)
3112 ? _M_refcopy() : _M_clone(__alloc1);
3117 _S_create(size_type, size_type,
const _Alloc&);
3120 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3122 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3123 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3127 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3136 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3139 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3146 _M_destroy(
const _Alloc&)
throw();
3149 _M_refcopy()
throw()
3151 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3152 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3154 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3155 return _M_refdata();
3159 _M_clone(
const _Alloc&, size_type __res = 0);
3163 struct _Alloc_hider : _Alloc
3165 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3166 : _Alloc(__a), _M_p(__dat) { }
3176 static const size_type npos =
static_cast<size_type
>(-1);
3180 mutable _Alloc_hider _M_dataplus;
3183 _M_data() const _GLIBCXX_NOEXCEPT
3184 {
return _M_dataplus._M_p; }
3187 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3188 {
return (_M_dataplus._M_p = __p); }
3191 _M_rep()
const _GLIBCXX_NOEXCEPT
3192 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3197 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3198 {
return iterator(_M_data()); }
3201 _M_iend()
const _GLIBCXX_NOEXCEPT
3202 {
return iterator(_M_data() + this->
size()); }
3207 if (!_M_rep()->_M_is_leaked())
3212 _M_check(size_type __pos,
const char* __s)
const 3214 if (__pos > this->
size())
3215 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3216 "this->size() (which is %zu)"),
3217 __s, __pos, this->
size());
3222 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3225 __throw_length_error(__N(__s));
3230 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3232 const bool __testoff = __off < this->
size() - __pos;
3233 return __testoff ? __off : this->
size() - __pos;
3238 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3247 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3250 traits_type::assign(*__d, *__s);
3252 traits_type::copy(__d, __s, __n);
3256 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3259 traits_type::assign(*__d, *__s);
3261 traits_type::move(__d, __s, __n);
3265 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3268 traits_type::assign(*__d, __c);
3270 traits_type::assign(__d, __n, __c);
3275 template<
class _Iterator>
3277 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3279 for (; __k1 != __k2; ++__k1, (void)++__p)
3280 traits_type::assign(*__p, *__k1);
3284 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3285 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3288 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3290 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3293 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3294 { _M_copy(__p, __k1, __k2 - __k1); }
3297 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3299 { _M_copy(__p, __k1, __k2 - __k1); }
3302 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3304 const difference_type __d = difference_type(__n1 - __n2);
3306 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3307 return __gnu_cxx::__numeric_traits<int>::__max;
3308 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3309 return __gnu_cxx::__numeric_traits<int>::__min;
3315 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3321 _S_empty_rep() _GLIBCXX_NOEXCEPT
3322 {
return _Rep::_S_empty_rep(); }
3324 #if __cplusplus > 201402L 3326 typedef basic_string_view<_CharT, _Traits> __sv_type;
3328 template<
typename _Tp,
typename _Res>
3329 using _If_sv = enable_if_t<
3330 __and_<is_convertible<const _Tp&, __sv_type>,
3331 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3344 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3345 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3347 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3371 basic_string(
const basic_string& __str, size_type __pos,
3372 const _Alloc& __a = _Alloc());
3380 basic_string(
const basic_string& __str, size_type __pos,
3389 basic_string(
const basic_string& __str, size_type __pos,
3390 size_type __n,
const _Alloc& __a);
3402 const _Alloc& __a = _Alloc());
3408 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3415 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3417 #if __cplusplus >= 201103L 3426 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3429 : _M_dataplus(__str._M_dataplus)
3431 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3432 __str._M_data(_S_empty_rep()._M_refdata());
3434 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3452 template<
class _InputIterator>
3453 basic_string(_InputIterator __beg, _InputIterator __end,
3454 const _Alloc& __a = _Alloc());
3456 #if __cplusplus > 201402L 3464 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3465 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3466 const _Alloc& __a = _Alloc())
3475 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
3491 {
return this->
assign(__str); }
3499 {
return this->
assign(__s); }
3515 #if __cplusplus >= 201103L 3539 this->
assign(__l.begin(), __l.size());
3544 #if __cplusplus > 201402L 3551 {
return this->
assign(__sv); }
3557 operator __sv_type()
const noexcept
3558 {
return __sv_type(
data(),
size()); }
3570 return iterator(_M_data());
3579 {
return const_iterator(_M_data()); }
3589 return iterator(_M_data() + this->
size());
3598 {
return const_iterator(_M_data() + this->
size()); }
3607 {
return reverse_iterator(this->
end()); }
3614 const_reverse_iterator
3616 {
return const_reverse_iterator(this->
end()); }
3625 {
return reverse_iterator(this->
begin()); }
3632 const_reverse_iterator
3634 {
return const_reverse_iterator(this->
begin()); }
3636 #if __cplusplus >= 201103L 3643 {
return const_iterator(this->_M_data()); }
3651 {
return const_iterator(this->_M_data() + this->
size()); }
3658 const_reverse_iterator
3660 {
return const_reverse_iterator(this->
end()); }
3667 const_reverse_iterator
3669 {
return const_reverse_iterator(this->
begin()); }
3678 {
return _M_rep()->_M_length; }
3684 {
return _M_rep()->_M_length; }
3689 {
return _Rep::_S_max_size; }
3702 resize(size_type __n, _CharT __c);
3716 { this->
resize(__n, _CharT()); }
3718 #if __cplusplus >= 201103L 3723 #if __cpp_exceptions 3741 {
return _M_rep()->_M_capacity; }
3761 reserve(size_type __res_arg = 0);
3766 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3770 if (_M_rep()->_M_is_shared())
3773 _M_data(_S_empty_rep()._M_refdata());
3776 _M_rep()->_M_set_length_and_sharable(0);
3782 { _M_mutate(0, this->
size(), 0); }
3791 {
return this->
size() == 0; }
3807 __glibcxx_assert(__pos <=
size());
3808 return _M_data()[__pos];
3826 __glibcxx_assert(__pos <=
size());
3828 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3830 return _M_data()[__pos];
3846 if (__n >= this->
size())
3847 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3848 "(which is %zu) >= this->size() " 3851 return _M_data()[__n];
3869 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3870 "(which is %zu) >= this->size() " 3874 return _M_data()[__n];
3877 #if __cplusplus >= 201103L 3885 __glibcxx_assert(!
empty());
3896 __glibcxx_assert(!
empty());
3907 __glibcxx_assert(!
empty());
3918 __glibcxx_assert(!
empty());
3931 {
return this->
append(__str); }
3940 {
return this->
append(__s); }
3954 #if __cplusplus >= 201103L 3962 {
return this->
append(__l.begin(), __l.size()); }
3965 #if __cplusplus > 201402L 3973 {
return this->
append(__sv); }
3982 append(
const basic_string& __str);
3998 append(
const basic_string& __str, size_type __pos, size_type __n);
4007 append(
const _CharT* __s, size_type __n);
4017 __glibcxx_requires_string(__s);
4018 return this->
append(__s, traits_type::length(__s));
4030 append(size_type __n, _CharT __c);
4032 #if __cplusplus >= 201103L 4040 {
return this->
append(__l.begin(), __l.size()); }
4051 template<
class _InputIterator>
4053 append(_InputIterator __first, _InputIterator __last)
4054 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4056 #if __cplusplus > 201402L 4064 {
return this->
append(__sv.data(), __sv.size()); }
4073 template <
typename _Tp>
4074 _If_sv<_Tp, basic_string&>
4075 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4077 __sv_type __sv = __svt;
4078 return append(__sv.data()
4079 + __sv._M_check(__pos,
"basic_string::append"),
4080 __sv._M_limit(__pos, __n));
4091 const size_type __len = 1 + this->
size();
4092 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4094 traits_type::assign(_M_data()[this->
size()], __c);
4095 _M_rep()->_M_set_length_and_sharable(__len);
4104 assign(
const basic_string& __str);
4106 #if __cplusplus >= 201103L 4138 assign(
const basic_string& __str, size_type __pos, size_type __n)
4139 {
return this->
assign(__str._M_data()
4140 + __str._M_check(__pos,
"basic_string::assign"),
4141 __str._M_limit(__pos, __n)); }
4154 assign(
const _CharT* __s, size_type __n);
4168 __glibcxx_requires_string(__s);
4169 return this->
assign(__s, traits_type::length(__s));
4183 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4193 template<
class _InputIterator>
4195 assign(_InputIterator __first, _InputIterator __last)
4196 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4198 #if __cplusplus >= 201103L 4206 {
return this->
assign(__l.begin(), __l.size()); }
4209 #if __cplusplus > 201402L 4217 {
return this->
assign(__sv.data(), __sv.size()); }
4226 template <
typename _Tp>
4227 _If_sv<_Tp, basic_string&>
4228 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4230 __sv_type __sv = __svt;
4231 return assign(__sv.data()
4232 + __sv._M_check(__pos,
"basic_string::assign"),
4233 __sv._M_limit(__pos, __n));
4251 insert(iterator __p, size_type __n, _CharT __c)
4252 { this->
replace(__p, __p, __n, __c); }
4266 template<
class _InputIterator>
4268 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4269 { this->
replace(__p, __p, __beg, __end); }
4271 #if __cplusplus >= 201103L 4281 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4282 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4299 insert(size_type __pos1,
const basic_string& __str)
4300 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4321 insert(size_type __pos1,
const basic_string& __str,
4322 size_type __pos2, size_type __n)
4323 {
return this->
insert(__pos1, __str._M_data()
4324 + __str._M_check(__pos2,
"basic_string::insert"),
4325 __str._M_limit(__pos2, __n)); }
4344 insert(size_type __pos,
const _CharT* __s, size_type __n);
4364 __glibcxx_requires_string(__s);
4365 return this->
insert(__pos, __s, traits_type::length(__s));
4385 insert(size_type __pos, size_type __n, _CharT __c)
4386 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4387 size_type(0), __n, __c); }
4405 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4406 const size_type __pos = __p - _M_ibegin();
4407 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4408 _M_rep()->_M_set_leaked();
4409 return iterator(_M_data() + __pos);
4412 #if __cplusplus > 201402L 4420 insert(size_type __pos, __sv_type __sv)
4421 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
4432 template <
typename _Tp>
4433 _If_sv<_Tp, basic_string&>
4434 insert(size_type __pos1,
const _Tp& __svt,
4435 size_type __pos2, size_type __n = npos)
4437 __sv_type __sv = __svt;
4438 return this->
replace(__pos1, size_type(0), __sv.data()
4439 + __sv._M_check(__pos2,
"basic_string::insert"),
4440 __sv._M_limit(__pos2, __n));
4460 erase(size_type __pos = 0, size_type __n = npos)
4462 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4463 _M_limit(__pos, __n), size_type(0));
4478 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4479 && __position < _M_iend());
4480 const size_type __pos = __position - _M_ibegin();
4481 _M_mutate(__pos, size_type(1), size_type(0));
4482 _M_rep()->_M_set_leaked();
4483 return iterator(_M_data() + __pos);
4496 erase(iterator __first, iterator __last);
4498 #if __cplusplus >= 201103L 4507 __glibcxx_assert(!
empty());
4530 replace(size_type __pos, size_type __n,
const basic_string& __str)
4531 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4552 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4553 size_type __pos2, size_type __n2)
4554 {
return this->
replace(__pos1, __n1, __str._M_data()
4555 + __str._M_check(__pos2,
"basic_string::replace"),
4556 __str._M_limit(__pos2, __n2)); }
4577 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4597 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4599 __glibcxx_requires_string(__s);
4600 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4621 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4622 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4623 _M_limit(__pos, __n1), __n2, __c); }
4639 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4640 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4658 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4660 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4661 && __i2 <= _M_iend());
4662 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4679 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4681 __glibcxx_requires_string(__s);
4682 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4700 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4702 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4703 && __i2 <= _M_iend());
4704 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4722 template<
class _InputIterator>
4725 _InputIterator __k1, _InputIterator __k2)
4727 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4728 && __i2 <= _M_iend());
4729 __glibcxx_requires_valid_range(__k1, __k2);
4730 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4731 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4737 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4739 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4740 && __i2 <= _M_iend());
4741 __glibcxx_requires_valid_range(__k1, __k2);
4742 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4747 replace(iterator __i1, iterator __i2,
4748 const _CharT* __k1,
const _CharT* __k2)
4750 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4751 && __i2 <= _M_iend());
4752 __glibcxx_requires_valid_range(__k1, __k2);
4753 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4758 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4760 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4761 && __i2 <= _M_iend());
4762 __glibcxx_requires_valid_range(__k1, __k2);
4763 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4764 __k1.base(), __k2 - __k1);
4768 replace(iterator __i1, iterator __i2,
4769 const_iterator __k1, const_iterator __k2)
4771 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4772 && __i2 <= _M_iend());
4773 __glibcxx_requires_valid_range(__k1, __k2);
4774 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4775 __k1.base(), __k2 - __k1);
4778 #if __cplusplus >= 201103L 4793 basic_string&
replace(iterator __i1, iterator __i2,
4795 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4798 #if __cplusplus > 201402L 4807 replace(size_type __pos, size_type __n, __sv_type __sv)
4808 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
4819 template <
typename _Tp>
4820 _If_sv<_Tp, basic_string&>
4821 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4822 size_type __pos2, size_type __n2 = npos)
4824 __sv_type __sv = __svt;
4825 return this->
replace(__pos1, __n1, __sv.data()
4826 + __sv._M_check(__pos2,
"basic_string::replace"),
4827 __sv._M_limit(__pos2, __n2));
4840 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
4841 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
4845 template<
class _Integer>
4847 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4848 _Integer __val, __true_type)
4849 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4851 template<
class _InputIterator>
4853 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4854 _InputIterator __k2, __false_type);
4857 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4861 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4866 template<
class _InIterator>
4868 _S_construct_aux(_InIterator __beg, _InIterator __end,
4869 const _Alloc& __a, __false_type)
4871 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4872 return _S_construct(__beg, __end, __a, _Tag());
4877 template<
class _Integer>
4879 _S_construct_aux(_Integer __beg, _Integer __end,
4880 const _Alloc& __a, __true_type)
4881 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4885 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4886 {
return _S_construct(__req, __c, __a); }
4888 template<
class _InIterator>
4890 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4892 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4893 return _S_construct_aux(__beg, __end, __a, _Integral());
4897 template<
class _InIterator>
4899 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4904 template<
class _FwdIterator>
4906 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4910 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4927 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4938 swap(basic_string& __s);
4949 {
return _M_data(); }
4961 {
return _M_data(); }
4963 #if __cplusplus > 201402L 4972 {
return _M_data(); }
4980 {
return _M_dataplus; }
4995 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5009 find(
const basic_string& __str, size_type __pos = 0) const
5011 {
return this->
find(__str.data(), __pos, __str.size()); }
5024 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5026 __glibcxx_requires_string(__s);
5027 return this->
find(__s, __pos, traits_type::length(__s));
5041 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
5043 #if __cplusplus > 201402L 5051 find(__sv_type __sv, size_type __pos = 0)
const noexcept
5052 {
return this->
find(__sv.data(), __pos, __sv.size()); }
5066 rfind(
const basic_string& __str, size_type __pos = npos)
const 5068 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5083 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5097 rfind(
const _CharT* __s, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
5099 __glibcxx_requires_string(__s);
5100 return this->
rfind(__s, __pos, traits_type::length(__s));
5114 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
5116 #if __cplusplus > 201402L 5124 rfind(__sv_type __sv, size_type __pos = npos)
const noexcept
5125 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
5142 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5157 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5174 __glibcxx_requires_string(__s);
5175 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5192 {
return this->
find(__c, __pos); }
5194 #if __cplusplus > 201402L 5202 find_first_of(__sv_type __sv, size_type __pos = 0)
const noexcept
5203 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
5220 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5235 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5252 __glibcxx_requires_string(__s);
5253 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5270 {
return this->
rfind(__c, __pos); }
5272 #if __cplusplus > 201402L 5280 find_last_of(__sv_type __sv, size_type __pos = npos)
const noexcept
5281 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
5313 size_type __n)
const _GLIBCXX_NOEXCEPT;
5329 __glibcxx_requires_string(__s);
5347 #if __cplusplus > 201402L 5389 size_type __n)
const _GLIBCXX_NOEXCEPT;
5405 __glibcxx_requires_string(__s);
5423 #if __cplusplus > 201402L 5448 substr(size_type __pos = 0, size_type __n = npos)
const 5450 _M_check(__pos,
"basic_string::substr"), __n); }
5469 const size_type __size = this->
size();
5470 const size_type __osize = __str.size();
5471 const size_type __len =
std::min(__size, __osize);
5473 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5475 __r = _S_compare(__size, __osize);
5479 #if __cplusplus > 201402L 5488 const size_type __size = this->
size();
5489 const size_type __osize = __sv.size();
5490 const size_type __len =
std::min(__size, __osize);
5492 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5494 __r = _S_compare(__size, __osize);
5506 compare(size_type __pos, size_type __n, __sv_type __sv)
const 5507 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
5518 template <
typename _Tp>
5520 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5521 size_type __pos2, size_type __n2 = npos)
const 5523 __sv_type __sv = __svt;
5524 return __sv_type(*
this)
5525 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5549 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5575 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5576 size_type __pos2, size_type __n2)
const;
5593 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5617 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5644 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5645 size_type __n2)
const;
5647 # ifdef _GLIBCXX_TM_TS_INTERNAL 5649 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5652 ::_txnal_cow_string_c_str(
const void *that);
5654 ::_txnal_cow_string_D1(
void *that);
5656 ::_txnal_cow_string_D1_commit(
void *that);
5659 #endif // !_GLIBCXX_USE_CXX11_ABI 5668 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5674 __str.append(__rhs);
5684 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5695 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5705 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5708 const _CharT* __rhs)
5711 __str.append(__rhs);
5721 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5726 typedef typename __string_type::size_type __size_type;
5727 __string_type __str(__lhs);
5728 __str.append(__size_type(1), __rhs);
5732 #if __cplusplus >= 201103L 5733 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5737 {
return std::move(__lhs.append(__rhs)); }
5739 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5743 {
return std::move(__rhs.insert(0, __lhs)); }
5745 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5750 const auto __size = __lhs.size() + __rhs.size();
5751 const bool __cond = (__size > __lhs.capacity()
5752 && __size <= __rhs.capacity());
5753 return __cond ? std::move(__rhs.insert(0, __lhs))
5754 : std::move(__lhs.append(__rhs));
5757 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5761 {
return std::move(__rhs.insert(0, __lhs)); }
5763 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5767 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5769 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5772 const _CharT* __rhs)
5773 {
return std::move(__lhs.append(__rhs)); }
5775 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5779 {
return std::move(__lhs.append(1, __rhs)); }
5789 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5794 {
return __lhs.compare(__rhs) == 0; }
5796 template<
typename _CharT>
5798 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5801 {
return (__lhs.
size() == __rhs.
size()
5811 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5813 operator==(
const _CharT* __lhs,
5815 {
return __rhs.compare(__lhs) == 0; }
5823 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5826 const _CharT* __rhs)
5827 {
return __lhs.compare(__rhs) == 0; }
5836 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5841 {
return !(__lhs == __rhs); }
5849 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5851 operator!=(
const _CharT* __lhs,
5853 {
return !(__lhs == __rhs); }
5861 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5864 const _CharT* __rhs)
5865 {
return !(__lhs == __rhs); }
5874 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5876 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5879 {
return __lhs.
compare(__rhs) < 0; }
5887 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5889 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5890 const _CharT* __rhs)
5891 {
return __lhs.
compare(__rhs) < 0; }
5899 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5901 operator<(
const _CharT* __lhs,
5903 {
return __rhs.compare(__lhs) > 0; }
5912 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5917 {
return __lhs.compare(__rhs) > 0; }
5925 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5928 const _CharT* __rhs)
5929 {
return __lhs.compare(__rhs) > 0; }
5937 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5939 operator>(
const _CharT* __lhs,
5941 {
return __rhs.compare(__lhs) < 0; }
5950 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5952 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5955 {
return __lhs.
compare(__rhs) <= 0; }
5963 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5965 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5966 const _CharT* __rhs)
5967 {
return __lhs.
compare(__rhs) <= 0; }
5975 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5977 operator<=(
const _CharT* __lhs,
5979 {
return __rhs.compare(__lhs) >= 0; }
5988 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5993 {
return __lhs.compare(__rhs) >= 0; }
6001 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6004 const _CharT* __rhs)
6005 {
return __lhs.compare(__rhs) >= 0; }
6013 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6015 operator>=(
const _CharT* __lhs,
6017 {
return __rhs.compare(__lhs) <= 0; }
6026 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6030 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6031 { __lhs.swap(__rhs); }
6046 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6064 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6066 operator<<(basic_ostream<_CharT, _Traits>& __os,
6071 return __ostream_insert(__os, __str.
data(), __str.
size());
6087 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6104 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6110 #if __cplusplus >= 201103L 6112 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6119 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6131 #ifdef _GLIBCXX_USE_WCHAR_T 6138 _GLIBCXX_END_NAMESPACE_VERSION
6141 #if __cplusplus >= 201103L 6145 namespace std _GLIBCXX_VISIBILITY(default)
6147 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6148 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6150 #if _GLIBCXX_USE_C99_STDLIB 6153 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6154 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
6158 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6159 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
6162 inline unsigned long 6163 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6164 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
6168 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6169 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
6172 inline unsigned long long 6173 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6174 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
6179 stof(
const string& __str,
size_t* __idx = 0)
6180 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
6183 stod(
const string& __str,
size_t* __idx = 0)
6184 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
6187 stold(
const string& __str,
size_t* __idx = 0)
6188 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
6189 #endif // _GLIBCXX_USE_C99_STDLIB 6191 #if _GLIBCXX_USE_C99_STDIO 6196 to_string(
int __val)
6197 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6201 to_string(
unsigned __val)
6202 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6203 4 *
sizeof(unsigned),
6207 to_string(
long __val)
6208 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6212 to_string(
unsigned long __val)
6213 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6214 4 *
sizeof(
unsigned long),
6218 to_string(
long long __val)
6219 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6220 4 *
sizeof(
long long),
6224 to_string(
unsigned long long __val)
6225 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6226 4 *
sizeof(
unsigned long long),
6230 to_string(
float __val)
6233 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6234 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6239 to_string(
double __val)
6242 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6243 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6248 to_string(
long double __val)
6251 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6252 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6255 #endif // _GLIBCXX_USE_C99_STDIO 6257 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6259 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6260 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
6264 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6265 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
6268 inline unsigned long 6269 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6270 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
6274 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6275 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
6278 inline unsigned long long 6279 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6280 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
6285 stof(
const wstring& __str,
size_t* __idx = 0)
6286 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
6289 stod(
const wstring& __str,
size_t* __idx = 0)
6290 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
6293 stold(
const wstring& __str,
size_t* __idx = 0)
6294 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
6296 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6299 to_wstring(
int __val)
6300 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6304 to_wstring(
unsigned __val)
6305 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6306 4 *
sizeof(unsigned),
6310 to_wstring(
long __val)
6311 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6315 to_wstring(
unsigned long __val)
6316 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6317 4 *
sizeof(
unsigned long),
6321 to_wstring(
long long __val)
6322 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6323 4 *
sizeof(
long long),
6327 to_wstring(
unsigned long long __val)
6328 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6329 4 *
sizeof(
unsigned long long),
6333 to_wstring(
float __val)
6336 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6337 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6342 to_wstring(
double __val)
6345 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6346 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6351 to_wstring(
long double __val)
6354 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6355 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6358 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6359 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6361 _GLIBCXX_END_NAMESPACE_CXX11
6362 _GLIBCXX_END_NAMESPACE_VERSION
6367 #if __cplusplus >= 201103L 6371 namespace std _GLIBCXX_VISIBILITY(default)
6373 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6377 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6381 :
public __hash_base<size_t, string>
6384 operator()(
const string& __s)
const noexcept
6385 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6392 #ifdef _GLIBCXX_USE_WCHAR_T 6396 :
public __hash_base<size_t, wstring>
6399 operator()(
const wstring& __s)
const noexcept
6400 {
return std::_Hash_impl::hash(__s.
data(),
6401 __s.
length() *
sizeof(wchar_t)); }
6410 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6414 :
public __hash_base<size_t, u16string>
6417 operator()(
const u16string& __s)
const noexcept
6418 {
return std::_Hash_impl::hash(__s.
data(),
6419 __s.
length() *
sizeof(char16_t)); }
6429 :
public __hash_base<size_t, u32string>
6432 operator()(
const u32string& __s)
const noexcept
6433 {
return std::_Hash_impl::hash(__s.
data(),
6434 __s.
length() *
sizeof(char32_t)); }
6442 _GLIBCXX_END_NAMESPACE_VERSION
6444 #if __cplusplus > 201103L 6446 #define __cpp_lib_string_udls 201304 6448 inline namespace literals
6450 inline namespace string_literals
6452 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6454 _GLIBCXX_DEFAULT_ABI_TAG
6456 operator""s(
const char* __str,
size_t __len)
6459 #ifdef _GLIBCXX_USE_WCHAR_T 6460 _GLIBCXX_DEFAULT_ABI_TAG
6462 operator""s(
const wchar_t* __str,
size_t __len)
6466 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6467 _GLIBCXX_DEFAULT_ABI_TAG
6469 operator""s(
const char16_t* __str,
size_t __len)
6472 _GLIBCXX_DEFAULT_ABI_TAG
6474 operator""s(
const char32_t* __str,
size_t __len)
6478 _GLIBCXX_END_NAMESPACE_VERSION
6482 #endif // __cplusplus > 201103L basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
Uniform interface to all pointer-like types.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
const_reference front() const noexcept
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
char_type widen(char __c) const
Widens characters.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
Basis for explicit traits specializations.
void pop_back()
Remove the last character.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
reference at(size_type __n)
Provides access to the data contained in the string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
~basic_string() noexcept
Destroy the string instance.
Primary class template hash.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
const_reverse_iterator crbegin() const noexcept
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
ISO C++ entities toplevel namespace is std.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
iterator erase(iterator __position)
Remove one character.
const_iterator begin() const noexcept
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
Template class basic_ostream.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_iterator end() const noexcept
Managing sequences of characters and character-like objects.
basic_string & append(const _CharT *__s)
Append a C string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
const_iterator cbegin() const noexcept
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
void push_back(_CharT __c)
Append a single character.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
size_type capacity() const noexcept
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & operator+=(const _CharT *__s)
Append a C string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
const_reverse_iterator rend() const noexcept
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
const_iterator cend() const noexcept
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string()
Default constructor creates an empty string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
bool empty() const noexcept
void swap(basic_string &__s)
Swap contents with another string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
const_reverse_iterator crend() const noexcept
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
reverse_iterator rbegin()
static const size_type npos
Value returned by various member functions when they fail.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
const_reference back() const noexcept
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
Uniform interface to C++98 and C++11 allocators.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
Template class basic_istream.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
One of the comparison functors.
Forward iterators support a superset of input iterator operations.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.