34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 #if _GLIBCXX_USE_CXX11_ABI
52 _GLIBCXX_BEGIN_NAMESPACE_CXX11
71 template<
typename _CharT,
typename _Traits,
typename _Alloc>
75 rebind<_CharT>::other _Char_alloc_type;
80 typedef _Traits traits_type;
81 typedef typename _Traits::char_type value_type;
82 typedef _Char_alloc_type allocator_type;
83 typedef typename _Alloc_traits::size_type size_type;
84 typedef typename _Alloc_traits::difference_type difference_type;
85 typedef typename _Alloc_traits::reference reference;
86 typedef typename _Alloc_traits::const_reference const_reference;
87 typedef typename _Alloc_traits::pointer pointer;
88 typedef typename _Alloc_traits::const_pointer const_pointer;
89 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
90 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
96 static const size_type
npos =
static_cast<size_type
>(-1);
100 #if __cplusplus < 201103L
101 typedef iterator __const_iterator;
103 typedef const_iterator __const_iterator;
107 struct _Alloc_hider : allocator_type
109 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
110 : allocator_type(__a), _M_p(__dat) { }
115 _Alloc_hider _M_dataplus;
116 size_type _M_string_length;
118 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
122 _CharT _M_local_buf[_S_local_capacity + 1];
123 size_type _M_allocated_capacity;
128 { _M_dataplus._M_p = __p; }
131 _M_length(size_type __length)
132 { _M_string_length = __length; }
136 {
return _M_dataplus._M_p; }
141 #if __cplusplus >= 201103L
144 return pointer(_M_local_buf);
149 _M_local_data()
const
151 #if __cplusplus >= 201103L
154 return const_pointer(_M_local_buf);
159 _M_capacity(size_type __capacity)
160 { _M_allocated_capacity = __capacity; }
163 _M_set_length(size_type __n)
166 traits_type::assign(_M_data()[__n], _CharT());
171 {
return _M_data() == _M_local_data(); }
175 _M_create(size_type&, size_type);
181 _M_destroy(_M_allocated_capacity);
185 _M_destroy(size_type __size)
throw()
186 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
190 template<
typename _InIterator>
192 _M_construct_aux(_InIterator __beg, _InIterator __end,
195 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
196 _M_construct(__beg, __end, _Tag());
201 template<
typename _Integer>
203 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
204 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
207 _M_construct_aux_2(size_type __req, _CharT __c)
208 { _M_construct(__req, __c); }
210 template<
typename _InIterator>
212 _M_construct(_InIterator __beg, _InIterator __end)
214 typedef typename std::__is_integer<_InIterator>::__type _Integral;
215 _M_construct_aux(__beg, __end, _Integral());
219 template<
typename _InIterator>
221 _M_construct(_InIterator __beg, _InIterator __end,
226 template<
typename _FwdIterator>
228 _M_construct(_FwdIterator __beg, _FwdIterator __end,
232 _M_construct(size_type __req, _CharT __c);
236 {
return _M_dataplus; }
238 const allocator_type&
239 _M_get_allocator()
const
240 {
return _M_dataplus; }
244 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
247 template<
typename _Tp,
bool _Requires =
248 !__are_same<_Tp, _CharT*>::__value
249 && !__are_same<_Tp, const _CharT*>::__value
250 && !__are_same<_Tp, iterator>::__value
251 && !__are_same<_Tp, const_iterator>::__value>
252 struct __enable_if_not_native_iterator
254 template<
typename _Tp>
255 struct __enable_if_not_native_iterator<_Tp, false> { };
259 _M_check(size_type __pos,
const char* __s)
const
261 if (__pos > this->
size())
262 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
263 "this->size() (which is %zu)"),
264 __s, __pos, this->
size());
269 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
272 __throw_length_error(__N(__s));
278 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
280 const bool __testoff = __off < this->
size() - __pos;
281 return __testoff ? __off : this->
size() - __pos;
286 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
288 return (less<const _CharT*>()(__s, _M_data())
289 || less<const _CharT*>()(_M_data() + this->
size(), __s));
295 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
298 traits_type::assign(*__d, *__s);
300 traits_type::copy(__d, __s, __n);
304 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
307 traits_type::assign(*__d, *__s);
309 traits_type::move(__d, __s, __n);
313 _S_assign(_CharT* __d, size_type __n, _CharT __c)
316 traits_type::assign(*__d, __c);
318 traits_type::assign(__d, __n, __c);
323 template<
class _Iterator>
325 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
327 for (; __k1 != __k2; ++__k1, (void)++__p)
328 traits_type::assign(*__p, *__k1);
332 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
333 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
336 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
338 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
341 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
342 { _S_copy(__p, __k1, __k2 - __k1); }
345 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
347 { _S_copy(__p, __k1, __k2 - __k1); }
350 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
352 const difference_type __d = difference_type(__n1 - __n2);
354 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
355 return __gnu_cxx::__numeric_traits<int>::__max;
356 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
357 return __gnu_cxx::__numeric_traits<int>::__min;
366 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
370 _M_erase(size_type __pos, size_type __n);
381 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
382 : _M_dataplus(_M_local_data())
383 { _M_set_length(0); }
390 : _M_dataplus(_M_local_data(), __a)
391 { _M_set_length(0); }
398 : _M_dataplus(_M_local_data(),
399 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
400 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
411 size_type __n =
npos)
412 : _M_dataplus(_M_local_data())
414 const _CharT* __start = __str._M_data()
415 + __str._M_check(__pos,
"basic_string::basic_string");
416 _M_construct(__start, __start + __str._M_limit(__pos, __n));
427 size_type __n,
const _Alloc& __a)
428 : _M_dataplus(_M_local_data(), __a)
430 const _CharT* __start
431 = __str._M_data() + __str._M_check(__pos,
"string::string");
432 _M_construct(__start, __start + __str._M_limit(__pos, __n));
445 const _Alloc& __a = _Alloc())
446 : _M_dataplus(_M_local_data(), __a)
447 { _M_construct(__s, __s + __n); }
454 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
455 : _M_dataplus(_M_local_data(), __a)
456 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
464 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
465 : _M_dataplus(_M_local_data(), __a)
466 { _M_construct(__n, __c); }
468 #if __cplusplus >= 201103L
477 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
479 if (__str._M_is_local())
481 traits_type::copy(_M_local_buf, __str._M_local_buf,
482 _S_local_capacity + 1);
486 _M_data(__str._M_data());
487 _M_capacity(__str._M_allocated_capacity);
493 _M_length(__str.length());
494 __str._M_data(__str._M_local_data());
495 __str._M_set_length(0);
503 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
504 : _M_dataplus(_M_local_data(), __a)
505 { _M_construct(__l.begin(), __l.end()); }
508 : _M_dataplus(_M_local_data(), __a)
509 { _M_construct(__str.begin(), __str.end()); }
512 noexcept(_Alloc_traits::_S_always_equal())
513 : _M_dataplus(_M_local_data(), __a)
515 if (__str._M_is_local())
517 traits_type::copy(_M_local_buf, __str._M_local_buf,
518 _S_local_capacity + 1);
519 _M_length(__str.length());
520 __str._M_set_length(0);
522 else if (_Alloc_traits::_S_always_equal()
523 || __str.get_allocator() == __a)
525 _M_data(__str._M_data());
526 _M_length(__str.length());
527 _M_capacity(__str._M_allocated_capacity);
528 __str._M_data(__str._M_local_buf);
529 __str._M_set_length(0);
532 _M_construct(__str.begin(), __str.end());
543 #if __cplusplus >= 201103L
544 template<
typename _InputIterator,
545 typename = std::_RequireInputIter<_InputIterator>>
547 template<
typename _InputIterator>
549 basic_string(_InputIterator __beg, _InputIterator __end,
550 const _Alloc& __a = _Alloc())
551 : _M_dataplus(_M_local_data(), __a)
552 { _M_construct(__beg, __end); }
567 #if __cplusplus >= 201103L
568 if (_Alloc_traits::_S_propagate_on_copy_assign())
570 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
571 && _M_get_allocator() != __str._M_get_allocator())
575 if (__str.size() <= _S_local_capacity)
577 _M_destroy(_M_allocated_capacity);
578 _M_data(_M_local_data());
583 const auto __len = __str.size();
584 auto __alloc = __str._M_get_allocator();
586 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
587 _M_destroy(_M_allocated_capacity);
590 _M_set_length(__len);
593 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
596 return this->
assign(__str);
605 {
return this->
assign(__s); }
621 #if __cplusplus >= 201103L
634 noexcept(_Alloc_traits::_S_nothrow_move())
636 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
637 && !_Alloc_traits::_S_always_equal()
638 && _M_get_allocator() != __str._M_get_allocator())
641 _M_destroy(_M_allocated_capacity);
642 _M_data(_M_local_data());
646 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
648 if (!__str._M_is_local()
649 && (_Alloc_traits::_S_propagate_on_move_assign()
650 || _Alloc_traits::_S_always_equal()))
652 pointer __data =
nullptr;
653 size_type __capacity;
656 if (_Alloc_traits::_S_always_equal())
659 __capacity = _M_allocated_capacity;
662 _M_destroy(_M_allocated_capacity);
665 _M_data(__str._M_data());
666 _M_length(__str.length());
667 _M_capacity(__str._M_allocated_capacity);
670 __str._M_data(__data);
671 __str._M_capacity(__capacity);
674 __str._M_data(__str._M_local_buf);
689 this->
assign(__l.begin(), __l.size());
700 begin() _GLIBCXX_NOEXCEPT
701 {
return iterator(_M_data()); }
708 begin() const _GLIBCXX_NOEXCEPT
709 {
return const_iterator(_M_data()); }
716 end() _GLIBCXX_NOEXCEPT
717 {
return iterator(_M_data() + this->
size()); }
724 end() const _GLIBCXX_NOEXCEPT
725 {
return const_iterator(_M_data() + this->
size()); }
733 rbegin() _GLIBCXX_NOEXCEPT
734 {
return reverse_iterator(this->
end()); }
741 const_reverse_iterator
742 rbegin() const _GLIBCXX_NOEXCEPT
743 {
return const_reverse_iterator(this->
end()); }
751 rend() _GLIBCXX_NOEXCEPT
752 {
return reverse_iterator(this->
begin()); }
759 const_reverse_iterator
760 rend() const _GLIBCXX_NOEXCEPT
761 {
return const_reverse_iterator(this->
begin()); }
763 #if __cplusplus >= 201103L
770 {
return const_iterator(this->_M_data()); }
777 cend() const noexcept
778 {
return const_iterator(this->_M_data() + this->
size()); }
785 const_reverse_iterator
787 {
return const_reverse_iterator(this->
end()); }
794 const_reverse_iterator
795 crend() const noexcept
796 {
return const_reverse_iterator(this->
begin()); }
804 size() const _GLIBCXX_NOEXCEPT
805 {
return _M_string_length; }
810 length() const _GLIBCXX_NOEXCEPT
811 {
return _M_string_length; }
816 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
829 resize(size_type __n, _CharT __c);
843 { this->
resize(__n, _CharT()); }
845 #if __cplusplus >= 201103L
869 return _M_is_local() ? size_type(_S_local_capacity)
870 : _M_allocated_capacity;
891 reserve(size_type __res_arg = 0);
897 clear() _GLIBCXX_NOEXCEPT
898 { _M_set_length(0); }
905 empty() const _GLIBCXX_NOEXCEPT
906 {
return this->
size() == 0; }
920 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
922 __glibcxx_assert(__pos <=
size());
923 return _M_data()[__pos];
941 __glibcxx_assert(__pos <=
size());
943 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
944 return _M_data()[__pos];
958 at(size_type __n)
const
960 if (__n >= this->
size())
961 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
962 "(which is %zu) >= this->size() "
965 return _M_data()[__n];
982 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
983 "(which is %zu) >= this->size() "
986 return _M_data()[__n];
989 #if __cplusplus >= 201103L
997 __glibcxx_assert(!
empty());
1006 front() const noexcept
1008 __glibcxx_assert(!
empty());
1019 __glibcxx_assert(!
empty());
1028 back() const noexcept
1030 __glibcxx_assert(!
empty());
1043 {
return this->
append(__str); }
1052 {
return this->
append(__s); }
1066 #if __cplusplus >= 201103L
1074 {
return this->
append(__l.begin(), __l.size()); }
1084 {
return _M_append(__str._M_data(), __str.size()); }
1101 {
return _M_append(__str._M_data()
1102 + __str._M_check(__pos,
"basic_string::append"),
1103 __str._M_limit(__pos, __n)); }
1112 append(
const _CharT* __s, size_type __n)
1114 __glibcxx_requires_string_len(__s, __n);
1115 _M_check_length(size_type(0), __n,
"basic_string::append");
1116 return _M_append(__s, __n);
1125 append(
const _CharT* __s)
1127 __glibcxx_requires_string(__s);
1128 const size_type __n = traits_type::length(__s);
1129 _M_check_length(size_type(0), __n,
"basic_string::append");
1130 return _M_append(__s, __n);
1142 append(size_type __n, _CharT __c)
1143 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1145 #if __cplusplus >= 201103L
1152 append(initializer_list<_CharT> __l)
1153 {
return this->
append(__l.begin(), __l.size()); }
1164 #if __cplusplus >= 201103L
1165 template<
class _InputIterator,
1166 typename = std::_RequireInputIter<_InputIterator>>
1168 template<
class _InputIterator>
1171 append(_InputIterator __first, _InputIterator __last)
1181 const size_type __size = this->
size();
1183 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1184 traits_type::assign(this->_M_data()[__size], __c);
1185 this->_M_set_length(__size + 1);
1196 this->_M_assign(__str);
1200 #if __cplusplus >= 201103L
1211 noexcept(_Alloc_traits::_S_nothrow_move())
1215 return *
this = std::move(__str);
1234 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1235 + __str._M_check(__pos,
"basic_string::assign"),
1236 __str._M_limit(__pos, __n)); }
1249 assign(
const _CharT* __s, size_type __n)
1251 __glibcxx_requires_string_len(__s, __n);
1252 return _M_replace(size_type(0), this->
size(), __s, __n);
1265 assign(
const _CharT* __s)
1267 __glibcxx_requires_string(__s);
1268 return _M_replace(size_type(0), this->
size(), __s,
1269 traits_type::length(__s));
1282 assign(size_type __n, _CharT __c)
1283 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1293 #if __cplusplus >= 201103L
1294 template<
class _InputIterator,
1295 typename = std::_RequireInputIter<_InputIterator>>
1297 template<
class _InputIterator>
1300 assign(_InputIterator __first, _InputIterator __last)
1303 #if __cplusplus >= 201103L
1310 assign(initializer_list<_CharT> __l)
1311 {
return this->
assign(__l.begin(), __l.size()); }
1314 #if __cplusplus >= 201103L
1331 insert(const_iterator __p, size_type __n, _CharT __c)
1333 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1334 const size_type __pos = __p -
begin();
1335 this->
replace(__p, __p, __n, __c);
1336 return iterator(this->_M_data() + __pos);
1353 insert(iterator __p, size_type __n, _CharT __c)
1354 { this->
replace(__p, __p, __n, __c); }
1357 #if __cplusplus >= 201103L
1372 template<
class _InputIterator,
1373 typename = std::_RequireInputIter<_InputIterator>>
1375 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1377 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1378 const size_type __pos = __p -
begin();
1379 this->
replace(__p, __p, __beg, __end);
1380 return iterator(this->_M_data() + __pos);
1395 template<
class _InputIterator>
1397 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1398 { this->
replace(__p, __p, __beg, __end); }
1401 #if __cplusplus >= 201103L
1409 insert(iterator __p, initializer_list<_CharT> __l)
1411 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1412 this->
insert(__p -
begin(), __l.begin(), __l.size());
1430 {
return this->
replace(__pos1, size_type(0),
1431 __str._M_data(), __str.size()); }
1453 size_type __pos2, size_type __n)
1454 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1455 + __str._M_check(__pos2,
"basic_string::insert"),
1456 __str._M_limit(__pos2, __n)); }
1475 insert(size_type __pos,
const _CharT* __s, size_type __n)
1476 {
return this->
replace(__pos, size_type(0), __s, __n); }
1494 insert(size_type __pos,
const _CharT* __s)
1496 __glibcxx_requires_string(__s);
1497 return this->
replace(__pos, size_type(0), __s,
1498 traits_type::length(__s));
1518 insert(size_type __pos, size_type __n, _CharT __c)
1519 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1520 size_type(0), __n, __c); }
1536 insert(__const_iterator __p, _CharT __c)
1538 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1539 const size_type __pos = __p -
begin();
1540 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1541 return iterator(_M_data() + __pos);
1560 erase(size_type __pos = 0, size_type __n =
npos)
1562 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1563 _M_limit(__pos, __n));
1576 erase(__const_iterator __position)
1578 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1579 && __position <
end());
1580 const size_type __pos = __position -
begin();
1581 this->_M_erase(__pos, size_type(1));
1582 return iterator(_M_data() + __pos);
1595 erase(__const_iterator __first, __const_iterator __last)
1597 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1598 && __last <=
end());
1599 const size_type __pos = __first -
begin();
1600 this->_M_erase(__pos, __last - __first);
1601 return iterator(this->_M_data() + __pos);
1604 #if __cplusplus >= 201103L
1613 __glibcxx_assert(!
empty());
1614 _M_erase(
size() - 1, 1);
1637 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1659 size_type __pos2, size_type __n2)
1660 {
return this->
replace(__pos1, __n1, __str._M_data()
1661 + __str._M_check(__pos2,
"basic_string::replace"),
1662 __str._M_limit(__pos2, __n2)); }
1683 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1686 __glibcxx_requires_string_len(__s, __n2);
1687 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1688 _M_limit(__pos, __n1), __s, __n2);
1708 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1710 __glibcxx_requires_string(__s);
1711 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1732 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1733 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1734 _M_limit(__pos, __n1), __n2, __c); }
1750 replace(__const_iterator __i1, __const_iterator __i2,
1752 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1770 replace(__const_iterator __i1, __const_iterator __i2,
1771 const _CharT* __s, size_type __n)
1773 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1775 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1792 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1794 __glibcxx_requires_string(__s);
1795 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1813 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1816 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1818 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1836 #if __cplusplus >= 201103L
1837 template<
class _InputIterator,
1838 typename = std::_RequireInputIter<_InputIterator>>
1840 replace(const_iterator __i1, const_iterator __i2,
1841 _InputIterator __k1, _InputIterator __k2)
1843 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1845 __glibcxx_requires_valid_range(__k1, __k2);
1846 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1847 std::__false_type());
1850 template<
class _InputIterator>
1851 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
1852 typename __enable_if_not_native_iterator<_InputIterator>::__type
1856 replace(iterator __i1, iterator __i2,
1857 _InputIterator __k1, _InputIterator __k2)
1859 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1861 __glibcxx_requires_valid_range(__k1, __k2);
1862 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1863 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1870 replace(__const_iterator __i1, __const_iterator __i2,
1871 _CharT* __k1, _CharT* __k2)
1873 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1875 __glibcxx_requires_valid_range(__k1, __k2);
1881 replace(__const_iterator __i1, __const_iterator __i2,
1882 const _CharT* __k1,
const _CharT* __k2)
1884 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1886 __glibcxx_requires_valid_range(__k1, __k2);
1892 replace(__const_iterator __i1, __const_iterator __i2,
1893 iterator __k1, iterator __k2)
1895 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1897 __glibcxx_requires_valid_range(__k1, __k2);
1899 __k1.base(), __k2 - __k1);
1903 replace(__const_iterator __i1, __const_iterator __i2,
1904 const_iterator __k1, const_iterator __k2)
1906 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1908 __glibcxx_requires_valid_range(__k1, __k2);
1910 __k1.base(), __k2 - __k1);
1913 #if __cplusplus >= 201103L
1929 initializer_list<_CharT> __l)
1930 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1934 template<
class _Integer>
1936 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1937 _Integer __n, _Integer __val, __true_type)
1938 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1940 template<
class _InputIterator>
1942 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1943 _InputIterator __k1, _InputIterator __k2,
1947 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1951 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1952 const size_type __len2);
1955 _M_append(
const _CharT* __s, size_type __n);
1972 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1992 c_str() const _GLIBCXX_NOEXCEPT
1993 {
return _M_data(); }
2002 data() const _GLIBCXX_NOEXCEPT
2003 {
return _M_data(); }
2010 {
return _M_get_allocator(); }
2025 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2040 {
return this->
find(__str.data(), __pos, __str.size()); }
2053 find(
const _CharT* __s, size_type __pos = 0)
const
2055 __glibcxx_requires_string(__s);
2056 return this->
find(__s, __pos, traits_type::length(__s));
2070 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2085 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2100 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2113 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2115 __glibcxx_requires_string(__s);
2116 return this->
rfind(__s, __pos, traits_type::length(__s));
2130 rfind(_CharT __c, size_type __pos =
npos) const _GLIBCXX_NOEXCEPT;
2146 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2161 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2176 __glibcxx_requires_string(__s);
2177 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2193 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2194 {
return this->
find(__c, __pos); }
2210 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2225 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2240 __glibcxx_requires_string(__s);
2241 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2258 {
return this->
rfind(__c, __pos); }
2289 size_type __n)
const;
2304 __glibcxx_requires_string(__s);
2352 size_type __n)
const;
2367 __glibcxx_requires_string(__s);
2398 substr(size_type __pos = 0, size_type __n =
npos)
const
2400 _M_check(__pos,
"basic_string::substr"), __n); }
2419 const size_type __size = this->
size();
2420 const size_type __osize = __str.size();
2421 const size_type __len =
std::min(__size, __osize);
2423 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2425 __r = _S_compare(__size, __osize);
2476 size_type __pos2, size_type __n2)
const;
2493 compare(
const _CharT* __s)
const;
2517 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2544 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2545 size_type __n2)
const;
2547 _GLIBCXX_END_NAMESPACE_CXX11
2548 #else // !_GLIBCXX_USE_CXX11_ABI
2613 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2616 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2620 typedef _Traits traits_type;
2621 typedef typename _Traits::char_type value_type;
2622 typedef _Alloc allocator_type;
2623 typedef typename _CharT_alloc_type::size_type size_type;
2624 typedef typename _CharT_alloc_type::difference_type difference_type;
2625 typedef typename _CharT_alloc_type::reference reference;
2626 typedef typename _CharT_alloc_type::const_reference const_reference;
2627 typedef typename _CharT_alloc_type::pointer pointer;
2628 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2629 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2630 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2652 size_type _M_length;
2653 size_type _M_capacity;
2654 _Atomic_word _M_refcount;
2657 struct _Rep : _Rep_base
2660 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2675 static const size_type _S_max_size;
2676 static const _CharT _S_terminal;
2680 static size_type _S_empty_rep_storage[];
2683 _S_empty_rep() _GLIBCXX_NOEXCEPT
2688 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2689 return *
reinterpret_cast<_Rep*
>(__p);
2693 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2695 #if defined(__GTHREADS)
2700 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
2702 return this->_M_refcount < 0;
2707 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2709 #if defined(__GTHREADS)
2715 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
2717 return this->_M_refcount > 0;
2722 _M_set_leaked() _GLIBCXX_NOEXCEPT
2723 { this->_M_refcount = -1; }
2726 _M_set_sharable() _GLIBCXX_NOEXCEPT
2727 { this->_M_refcount = 0; }
2730 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2732 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2733 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2736 this->_M_set_sharable();
2737 this->_M_length = __n;
2738 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2745 _M_refdata()
throw()
2746 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2749 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2751 return (!_M_is_leaked() && __alloc1 == __alloc2)
2752 ? _M_refcopy() : _M_clone(__alloc1);
2757 _S_create(size_type, size_type,
const _Alloc&);
2760 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2762 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2763 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2767 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2776 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2779 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2786 _M_destroy(
const _Alloc&)
throw();
2789 _M_refcopy()
throw()
2791 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2792 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2794 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2795 return _M_refdata();
2799 _M_clone(
const _Alloc&, size_type __res = 0);
2803 struct _Alloc_hider : _Alloc
2805 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2806 : _Alloc(__a), _M_p(__dat) { }
2816 static const size_type npos =
static_cast<size_type
>(-1);
2820 mutable _Alloc_hider _M_dataplus;
2823 _M_data() const _GLIBCXX_NOEXCEPT
2824 {
return _M_dataplus._M_p; }
2827 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2828 {
return (_M_dataplus._M_p = __p); }
2831 _M_rep() const _GLIBCXX_NOEXCEPT
2832 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2837 _M_ibegin() const _GLIBCXX_NOEXCEPT
2838 {
return iterator(_M_data()); }
2841 _M_iend() const _GLIBCXX_NOEXCEPT
2842 {
return iterator(_M_data() + this->
size()); }
2847 if (!_M_rep()->_M_is_leaked())
2852 _M_check(size_type __pos,
const char* __s)
const
2854 if (__pos > this->
size())
2855 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
2856 "this->size() (which is %zu)"),
2857 __s, __pos, this->
size());
2862 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
2865 __throw_length_error(__N(__s));
2870 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2872 const bool __testoff = __off < this->
size() - __pos;
2873 return __testoff ? __off : this->
size() - __pos;
2878 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2880 return (less<const _CharT*>()(__s, _M_data())
2881 || less<const _CharT*>()(_M_data() + this->
size(), __s));
2887 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2890 traits_type::assign(*__d, *__s);
2892 traits_type::copy(__d, __s, __n);
2896 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2899 traits_type::assign(*__d, *__s);
2901 traits_type::move(__d, __s, __n);
2905 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2908 traits_type::assign(*__d, __c);
2910 traits_type::assign(__d, __n, __c);
2915 template<
class _Iterator>
2917 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2919 for (; __k1 != __k2; ++__k1, (void)++__p)
2920 traits_type::assign(*__p, *__k1);
2924 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2925 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2928 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2930 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2933 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2934 { _M_copy(__p, __k1, __k2 - __k1); }
2937 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2939 { _M_copy(__p, __k1, __k2 - __k1); }
2942 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2944 const difference_type __d = difference_type(__n1 - __n2);
2946 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2947 return __gnu_cxx::__numeric_traits<int>::__max;
2948 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2949 return __gnu_cxx::__numeric_traits<int>::__min;
2955 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2961 _S_empty_rep() _GLIBCXX_NOEXCEPT
2962 {
return _Rep::_S_empty_rep(); }
2973 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2974 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2976 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2998 size_type __n = npos);
3007 size_type __n,
const _Alloc& __a);
3019 const _Alloc& __a = _Alloc());
3025 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3032 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3034 #if __cplusplus >= 201103L
3043 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3046 : _M_dataplus(__str._M_dataplus)
3048 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3049 __str._M_data(_S_empty_rep()._M_refdata());
3051 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3069 template<
class _InputIterator>
3070 basic_string(_InputIterator __beg, _InputIterator __end,
3071 const _Alloc& __a = _Alloc());
3085 {
return this->
assign(__str); }
3093 {
return this->
assign(__s); }
3109 #if __cplusplus >= 201103L
3133 this->
assign(__l.begin(), __l.size());
3147 return iterator(_M_data());
3156 {
return const_iterator(_M_data()); }
3166 return iterator(_M_data() + this->
size());
3175 {
return const_iterator(_M_data() + this->
size()); }
3191 const_reverse_iterator
3209 const_reverse_iterator
3213 #if __cplusplus >= 201103L
3220 {
return const_iterator(this->_M_data()); }
3228 {
return const_iterator(this->_M_data() + this->
size()); }
3235 const_reverse_iterator
3244 const_reverse_iterator
3255 {
return _M_rep()->_M_length; }
3261 {
return _M_rep()->_M_length; }
3266 {
return _Rep::_S_max_size; }
3279 resize(size_type __n, _CharT __c);
3293 { this->
resize(__n, _CharT()); }
3295 #if __cplusplus >= 201103L
3300 #if __cpp_exceptions
3318 {
return _M_rep()->_M_capacity; }
3338 reserve(size_type __res_arg = 0);
3346 { _M_mutate(0, this->
size(), 0); }
3354 {
return this->
size() == 0; }
3370 __glibcxx_assert(__pos <=
size());
3371 return _M_data()[__pos];
3389 __glibcxx_assert(__pos <=
size());
3391 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3393 return _M_data()[__pos];
3409 if (__n >= this->
size())
3410 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3411 "(which is %zu) >= this->size() "
3414 return _M_data()[__n];
3432 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3433 "(which is %zu) >= this->size() "
3437 return _M_data()[__n];
3440 #if __cplusplus >= 201103L
3448 __glibcxx_assert(!
empty());
3459 __glibcxx_assert(!
empty());
3470 __glibcxx_assert(!
empty());
3481 __glibcxx_assert(!
empty());
3494 {
return this->
append(__str); }
3503 {
return this->
append(__s); }
3517 #if __cplusplus >= 201103L
3525 {
return this->
append(__l.begin(), __l.size()); }
3559 append(
const _CharT* __s, size_type __n);
3569 __glibcxx_requires_string(__s);
3570 return this->
append(__s, traits_type::length(__s));
3582 append(size_type __n, _CharT __c);
3584 #if __cplusplus >= 201103L
3592 {
return this->
append(__l.begin(), __l.size()); }
3603 template<
class _InputIterator>
3605 append(_InputIterator __first, _InputIterator __last)
3606 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3615 const size_type __len = 1 + this->
size();
3616 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3618 traits_type::assign(_M_data()[this->
size()], __c);
3619 _M_rep()->_M_set_length_and_sharable(__len);
3630 #if __cplusplus >= 201103L
3663 {
return this->
assign(__str._M_data()
3664 + __str._M_check(__pos,
"basic_string::assign"),
3665 __str._M_limit(__pos, __n)); }
3678 assign(
const _CharT* __s, size_type __n);
3692 __glibcxx_requires_string(__s);
3693 return this->
assign(__s, traits_type::length(__s));
3707 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3717 template<
class _InputIterator>
3719 assign(_InputIterator __first, _InputIterator __last)
3720 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3722 #if __cplusplus >= 201103L
3730 {
return this->
assign(__l.begin(), __l.size()); }
3747 insert(iterator __p, size_type __n, _CharT __c)
3748 { this->
replace(__p, __p, __n, __c); }
3762 template<
class _InputIterator>
3764 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3765 { this->
replace(__p, __p, __beg, __end); }
3767 #if __cplusplus >= 201103L
3777 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3778 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3796 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3818 size_type __pos2, size_type __n)
3819 {
return this->
insert(__pos1, __str._M_data()
3820 + __str._M_check(__pos2,
"basic_string::insert"),
3821 __str._M_limit(__pos2, __n)); }
3840 insert(size_type __pos,
const _CharT* __s, size_type __n);
3860 __glibcxx_requires_string(__s);
3861 return this->
insert(__pos, __s, traits_type::length(__s));
3881 insert(size_type __pos, size_type __n, _CharT __c)
3882 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3883 size_type(0), __n, __c); }
3901 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3902 const size_type __pos = __p - _M_ibegin();
3903 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3904 _M_rep()->_M_set_leaked();
3905 return iterator(_M_data() + __pos);
3924 erase(size_type __pos = 0, size_type __n = npos)
3926 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3927 _M_limit(__pos, __n), size_type(0));
3942 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3943 && __position < _M_iend());
3944 const size_type __pos = __position - _M_ibegin();
3945 _M_mutate(__pos, size_type(1), size_type(0));
3946 _M_rep()->_M_set_leaked();
3947 return iterator(_M_data() + __pos);
3962 #if __cplusplus >= 201103L
3971 __glibcxx_assert(!
empty());
3995 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4017 size_type __pos2, size_type __n2)
4018 {
return this->
replace(__pos1, __n1, __str._M_data()
4019 + __str._M_check(__pos2,
"basic_string::replace"),
4020 __str._M_limit(__pos2, __n2)); }
4041 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4061 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4063 __glibcxx_requires_string(__s);
4064 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4085 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4086 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4087 _M_limit(__pos, __n1), __n2, __c); }
4104 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4122 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4124 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4125 && __i2 <= _M_iend());
4126 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4143 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4145 __glibcxx_requires_string(__s);
4146 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4164 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4166 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4167 && __i2 <= _M_iend());
4168 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4186 template<
class _InputIterator>
4189 _InputIterator __k1, _InputIterator __k2)
4191 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4192 && __i2 <= _M_iend());
4193 __glibcxx_requires_valid_range(__k1, __k2);
4194 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4195 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4203 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4204 && __i2 <= _M_iend());
4205 __glibcxx_requires_valid_range(__k1, __k2);
4206 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4211 replace(iterator __i1, iterator __i2,
4212 const _CharT* __k1,
const _CharT* __k2)
4214 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4215 && __i2 <= _M_iend());
4216 __glibcxx_requires_valid_range(__k1, __k2);
4217 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4222 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4224 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4225 && __i2 <= _M_iend());
4226 __glibcxx_requires_valid_range(__k1, __k2);
4227 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4228 __k1.base(), __k2 - __k1);
4232 replace(iterator __i1, iterator __i2,
4233 const_iterator __k1, const_iterator __k2)
4235 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4236 && __i2 <= _M_iend());
4237 __glibcxx_requires_valid_range(__k1, __k2);
4238 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4239 __k1.base(), __k2 - __k1);
4242 #if __cplusplus >= 201103L
4259 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4263 template<
class _Integer>
4266 _Integer __val, __true_type)
4267 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4269 template<
class _InputIterator>
4271 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4272 _InputIterator __k2, __false_type);
4275 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4279 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4284 template<
class _InIterator>
4286 _S_construct_aux(_InIterator __beg, _InIterator __end,
4287 const _Alloc& __a, __false_type)
4289 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4290 return _S_construct(__beg, __end, __a, _Tag());
4295 template<
class _Integer>
4297 _S_construct_aux(_Integer __beg, _Integer __end,
4298 const _Alloc& __a, __true_type)
4299 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4303 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4304 {
return _S_construct(__req, __c, __a); }
4306 template<
class _InIterator>
4308 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4310 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4311 return _S_construct_aux(__beg, __end, __a, _Integral());
4315 template<
class _InIterator>
4317 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4318 input_iterator_tag);
4322 template<
class _FwdIterator>
4324 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4325 forward_iterator_tag);
4328 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4345 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4367 {
return _M_data(); }
4377 {
return _M_data(); }
4384 {
return _M_dataplus; }
4399 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4414 {
return this->
find(__str.data(), __pos, __str.size()); }
4427 find(
const _CharT* __s, size_type __pos = 0)
const
4429 __glibcxx_requires_string(__s);
4430 return this->
find(__s, __pos, traits_type::length(__s));
4444 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
4459 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4474 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4487 rfind(
const _CharT* __s, size_type __pos = npos)
const
4489 __glibcxx_requires_string(__s);
4490 return this->
rfind(__s, __pos, traits_type::length(__s));
4504 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
4520 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4535 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4550 __glibcxx_requires_string(__s);
4551 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4568 {
return this->
find(__c, __pos); }
4584 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4599 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4614 __glibcxx_requires_string(__s);
4615 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4632 {
return this->
rfind(__c, __pos); }
4663 size_type __n)
const;
4678 __glibcxx_requires_string(__s);
4726 size_type __n)
const;
4741 __glibcxx_requires_string(__s);
4772 substr(size_type __pos = 0, size_type __n = npos)
const
4774 _M_check(__pos,
"basic_string::substr"), __n); }
4793 const size_type __size = this->
size();
4794 const size_type __osize = __str.size();
4795 const size_type __len =
std::min(__size, __osize);
4797 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4799 __r = _S_compare(__size, __osize);
4850 size_type __pos2, size_type __n2)
const;
4867 compare(
const _CharT* __s)
const;
4891 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4918 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4919 size_type __n2)
const;
4921 # ifdef _GLIBCXX_TM_TS_INTERNAL
4923 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
4926 ::_txnal_cow_string_c_str(
const void *that);
4928 ::_txnal_cow_string_D1(
void *that);
4930 ::_txnal_cow_string_D1_commit(
void *that);
4933 #endif // !_GLIBCXX_USE_CXX11_ABI
4942 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4943 basic_string<_CharT, _Traits, _Alloc>
4948 __str.append(__rhs);
4958 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4959 basic_string<_CharT,_Traits,_Alloc>
4961 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4969 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4970 basic_string<_CharT,_Traits,_Alloc>
4971 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4979 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4980 inline basic_string<_CharT, _Traits, _Alloc>
4982 const _CharT* __rhs)
4985 __str.append(__rhs);
4995 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4996 inline basic_string<_CharT, _Traits, _Alloc>
5000 typedef typename __string_type::size_type __size_type;
5001 __string_type __str(__lhs);
5002 __str.append(__size_type(1), __rhs);
5006 #if __cplusplus >= 201103L
5007 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5008 inline basic_string<_CharT, _Traits, _Alloc>
5009 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5010 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
5011 {
return std::move(__lhs.append(__rhs)); }
5013 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5014 inline basic_string<_CharT, _Traits, _Alloc>
5015 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5016 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5017 {
return std::move(__rhs.insert(0, __lhs)); }
5019 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5020 inline basic_string<_CharT, _Traits, _Alloc>
5021 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5022 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5024 const auto __size = __lhs.size() + __rhs.size();
5025 const bool __cond = (__size > __lhs.capacity()
5026 && __size <= __rhs.capacity());
5027 return __cond ? std::move(__rhs.insert(0, __lhs))
5028 : std::move(__lhs.append(__rhs));
5031 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5032 inline basic_string<_CharT, _Traits, _Alloc>
5034 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5035 {
return std::move(__rhs.insert(0, __lhs)); }
5037 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5038 inline basic_string<_CharT, _Traits, _Alloc>
5040 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5041 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5043 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5044 inline basic_string<_CharT, _Traits, _Alloc>
5045 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5046 const _CharT* __rhs)
5047 {
return std::move(__lhs.append(__rhs)); }
5049 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5050 inline basic_string<_CharT, _Traits, _Alloc>
5051 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5053 {
return std::move(__lhs.append(1, __rhs)); }
5063 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5068 {
return __lhs.compare(__rhs) == 0; }
5070 template<
typename _CharT>
5072 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5073 operator==(
const basic_string<_CharT>& __lhs,
5074 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
5075 {
return (__lhs.size() == __rhs.size()
5085 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5087 operator==(
const _CharT* __lhs,
5089 {
return __rhs.compare(__lhs) == 0; }
5097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5100 const _CharT* __rhs)
5101 {
return __lhs.compare(__rhs) == 0; }
5110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5115 {
return !(__lhs == __rhs); }
5123 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5125 operator!=(
const _CharT* __lhs,
5127 {
return !(__lhs == __rhs); }
5135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5138 const _CharT* __rhs)
5139 {
return !(__lhs == __rhs); }
5148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5150 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5153 {
return __lhs.
compare(__rhs) < 0; }
5161 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5163 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5164 const _CharT* __rhs)
5165 {
return __lhs.compare(__rhs) < 0; }
5173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5175 operator<(
const _CharT* __lhs,
5177 {
return __rhs.compare(__lhs) > 0; }
5186 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5191 {
return __lhs.compare(__rhs) > 0; }
5199 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5202 const _CharT* __rhs)
5203 {
return __lhs.compare(__rhs) > 0; }
5211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5213 operator>(
const _CharT* __lhs,
5215 {
return __rhs.compare(__lhs) < 0; }
5224 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5226 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5229 {
return __lhs.
compare(__rhs) <= 0; }
5237 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5239 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5240 const _CharT* __rhs)
5241 {
return __lhs.compare(__rhs) <= 0; }
5249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5251 operator<=(
const _CharT* __lhs,
5253 {
return __rhs.compare(__lhs) >= 0; }
5262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5267 {
return __lhs.compare(__rhs) >= 0; }
5275 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5278 const _CharT* __rhs)
5279 {
return __lhs.compare(__rhs) >= 0; }
5287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5289 operator>=(
const _CharT* __lhs,
5291 {
return __rhs.compare(__lhs) <= 0; }
5300 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5304 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5305 { __lhs.swap(__rhs); }
5320 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5321 basic_istream<_CharT, _Traits>&
5322 operator>>(basic_istream<_CharT, _Traits>& __is,
5323 basic_string<_CharT, _Traits, _Alloc>& __str);
5326 basic_istream<char>&
5327 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
5338 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5339 inline basic_ostream<_CharT, _Traits>&
5340 operator<<(basic_ostream<_CharT, _Traits>& __os,
5345 return __ostream_insert(__os, __str.data(), __str.size());
5361 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5362 basic_istream<_CharT, _Traits>&
5363 getline(basic_istream<_CharT, _Traits>& __is,
5364 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
5378 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5379 inline basic_istream<_CharT, _Traits>&
5384 #if __cplusplus >= 201103L
5386 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5387 inline basic_istream<_CharT, _Traits>&
5393 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5394 inline basic_istream<_CharT, _Traits>&
5401 basic_istream<char>&
5402 getline(basic_istream<char>& __in, basic_string<char>& __str,
5405 #ifdef _GLIBCXX_USE_WCHAR_T
5407 basic_istream<wchar_t>&
5408 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
5412 _GLIBCXX_END_NAMESPACE_VERSION
5415 #if __cplusplus >= 201103L
5419 namespace std _GLIBCXX_VISIBILITY(default)
5421 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5422 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5424 #if _GLIBCXX_USE_C99_STDLIB
5427 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5428 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
5432 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5433 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
5436 inline unsigned long
5437 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5438 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
5442 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5443 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
5446 inline unsigned long long
5447 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5448 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
5453 stof(
const string& __str,
size_t* __idx = 0)
5454 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
5457 stod(
const string& __str,
size_t* __idx = 0)
5458 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
5461 stold(
const string& __str,
size_t* __idx = 0)
5462 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
5463 #endif // _GLIBCXX_USE_C99_STDLIB
5465 #if _GLIBCXX_USE_C99_STDIO
5470 to_string(
int __val)
5471 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5475 to_string(
unsigned __val)
5476 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5477 4 *
sizeof(unsigned),
5481 to_string(
long __val)
5482 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5486 to_string(
unsigned long __val)
5487 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5488 4 *
sizeof(
unsigned long),
5492 to_string(
long long __val)
5493 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5494 4 *
sizeof(
long long),
5498 to_string(
unsigned long long __val)
5499 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5500 4 *
sizeof(
unsigned long long),
5504 to_string(
float __val)
5507 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5508 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5513 to_string(
double __val)
5516 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5517 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5522 to_string(
long double __val)
5525 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5526 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5529 #endif // _GLIBCXX_USE_C99_STDIO
5531 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
5533 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5534 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
5538 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5539 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
5542 inline unsigned long
5543 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5544 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
5548 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5549 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
5552 inline unsigned long long
5553 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5554 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
5559 stof(
const wstring& __str,
size_t* __idx = 0)
5560 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
5563 stod(
const wstring& __str,
size_t* __idx = 0)
5564 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
5567 stold(
const wstring& __str,
size_t* __idx = 0)
5568 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
5570 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5573 to_wstring(
int __val)
5574 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5578 to_wstring(
unsigned __val)
5579 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5580 4 *
sizeof(unsigned),
5584 to_wstring(
long __val)
5585 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5589 to_wstring(
unsigned long __val)
5590 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5591 4 *
sizeof(
unsigned long),
5595 to_wstring(
long long __val)
5596 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5597 4 *
sizeof(
long long),
5601 to_wstring(
unsigned long long __val)
5602 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5603 4 *
sizeof(
unsigned long long),
5607 to_wstring(
float __val)
5610 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5611 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5616 to_wstring(
double __val)
5619 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5620 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5625 to_wstring(
long double __val)
5628 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5629 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5632 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5633 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
5635 _GLIBCXX_END_NAMESPACE_CXX11
5636 _GLIBCXX_END_NAMESPACE_VERSION
5641 #if __cplusplus >= 201103L
5645 namespace std _GLIBCXX_VISIBILITY(default)
5647 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5651 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5655 :
public __hash_base<size_t, string>
5658 operator()(
const string& __s)
const noexcept
5659 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5666 #ifdef _GLIBCXX_USE_WCHAR_T
5670 :
public __hash_base<size_t, wstring>
5673 operator()(
const wstring& __s)
const noexcept
5674 {
return std::_Hash_impl::hash(__s.
data(),
5675 __s.
length() *
sizeof(wchar_t)); }
5684 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5688 :
public __hash_base<size_t, u16string>
5691 operator()(
const u16string& __s)
const noexcept
5692 {
return std::_Hash_impl::hash(__s.
data(),
5693 __s.
length() *
sizeof(char16_t)); }
5703 :
public __hash_base<size_t, u32string>
5706 operator()(
const u32string& __s)
const noexcept
5707 {
return std::_Hash_impl::hash(__s.
data(),
5708 __s.
length() *
sizeof(char32_t)); }
5716 _GLIBCXX_END_NAMESPACE_VERSION
5718 #if __cplusplus > 201103L
5720 #define __cpp_lib_string_udls 201304
5722 inline namespace literals
5724 inline namespace string_literals
5726 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5728 _GLIBCXX_DEFAULT_ABI_TAG
5729 inline basic_string<char>
5730 operator""s(
const char* __str,
size_t __len)
5731 {
return basic_string<char>{__str, __len}; }
5733 #ifdef _GLIBCXX_USE_WCHAR_T
5734 _GLIBCXX_DEFAULT_ABI_TAG
5735 inline basic_string<wchar_t>
5736 operator""s(
const wchar_t* __str,
size_t __len)
5737 {
return basic_string<wchar_t>{__str, __len}; }
5740 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5741 _GLIBCXX_DEFAULT_ABI_TAG
5742 inline basic_string<char16_t>
5743 operator""s(
const char16_t* __str,
size_t __len)
5744 {
return basic_string<char16_t>{__str, __len}; }
5746 _GLIBCXX_DEFAULT_ABI_TAG
5747 inline basic_string<char32_t>
5748 operator""s(
const char32_t* __str,
size_t __len)
5749 {
return basic_string<char32_t>{__str, __len}; }
5752 _GLIBCXX_END_NAMESPACE_VERSION
5756 #endif // __cplusplus > 201103L
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
Basis for explicit traits specializations.
basic_string & append(const _CharT *__s)
Append a C string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
Uniform interface to all pointer-like types.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_reference front() 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.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
Primary class template hash.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
~basic_string() noexcept
Destroy the string instance.
const_iterator cend() const noexcept
basic_string< wchar_t > wstring
A string of wchar_t.
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.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a 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 & 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
Find last position of a character of C string.
int compare(const basic_string &__str) const
Compare to a string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_reference back() const noexcept
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
const_reverse_iterator crbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
Managing sequences of characters and character-like objects.
basic_string & append(const basic_string &__str)
Append a string to this string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_iterator end() const noexcept
size_type max_size() const noexcept
Returns the size() of the largest possible string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
Forward iterators support a superset of input iterator operations.
char_type widen(char __c) const
Widens characters.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
iterator erase(iterator __position)
Remove one character.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C 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.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
const_reverse_iterator rend() const noexcept
const_iterator begin() const noexcept
Template class basic_istream.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
void push_back(_CharT __c)
Append a single character.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
void swap(basic_string &__s)
Swap contents with another string.
static const size_type npos
Value returned by various member functions when they fail.
bool empty() const noexcept
reverse_iterator rbegin()
reference at(size_type __n)
Provides access to the data contained in the string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
Uniform interface to C++98 and C++11 allocators.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
const_iterator cbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.