34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
42 #if __cplusplus >= 201103L
43 #include <initializer_list>
46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 #if _GLIBCXX_USE_CXX11_ABI
51 _GLIBCXX_BEGIN_NAMESPACE_CXX11
70 template<
typename _CharT,
typename _Traits,
typename _Alloc>
74 rebind<_CharT>::other _Char_alloc_type;
79 typedef _Traits traits_type;
80 typedef typename _Traits::char_type value_type;
81 typedef _Char_alloc_type allocator_type;
82 typedef typename _Alloc_traits::size_type size_type;
83 typedef typename _Alloc_traits::difference_type difference_type;
84 typedef typename _Alloc_traits::reference reference;
85 typedef typename _Alloc_traits::const_reference const_reference;
86 typedef typename _Alloc_traits::pointer pointer;
87 typedef typename _Alloc_traits::const_pointer const_pointer;
88 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
89 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
95 static const size_type
npos =
static_cast<size_type
>(-1);
99 #if __cplusplus < 201103L
100 typedef iterator __const_iterator;
102 typedef const_iterator __const_iterator;
106 struct _Alloc_hider : allocator_type
108 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
109 : allocator_type(__a), _M_p(__dat) { }
114 _Alloc_hider _M_dataplus;
115 size_type _M_string_length;
117 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
121 _CharT _M_local_buf[_S_local_capacity + 1];
122 size_type _M_allocated_capacity;
127 { _M_dataplus._M_p = __p; }
130 _M_length(size_type __length)
131 { _M_string_length = __length; }
135 {
return _M_dataplus._M_p; }
140 #if __cplusplus >= 201103L
143 return pointer(_M_local_buf);
148 _M_local_data()
const
150 #if __cplusplus >= 201103L
153 return const_pointer(_M_local_buf);
158 _M_capacity(size_type __capacity)
159 { _M_allocated_capacity = __capacity; }
162 _M_set_length(size_type __n)
165 traits_type::assign(_M_data()[__n], _CharT());
170 {
return _M_data() == _M_local_data(); }
174 _M_create(size_type&, size_type);
180 _M_destroy(_M_allocated_capacity);
184 _M_destroy(size_type __size)
throw()
185 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
189 template<
typename _InIterator>
191 _M_construct_aux(_InIterator __beg, _InIterator __end,
194 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
195 _M_construct(__beg, __end, _Tag());
200 template<
typename _Integer>
202 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
203 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
206 _M_construct_aux_2(size_type __req, _CharT __c)
207 { _M_construct(__req, __c); }
209 template<
typename _InIterator>
211 _M_construct(_InIterator __beg, _InIterator __end)
213 typedef typename std::__is_integer<_InIterator>::__type _Integral;
214 _M_construct_aux(__beg, __end, _Integral());
218 template<
typename _InIterator>
220 _M_construct(_InIterator __beg, _InIterator __end,
225 template<
typename _FwdIterator>
227 _M_construct(_FwdIterator __beg, _FwdIterator __end,
231 _M_construct(size_type __req, _CharT __c);
235 {
return _M_dataplus; }
237 const allocator_type&
238 _M_get_allocator()
const
239 {
return _M_dataplus; }
243 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
246 template<
typename _Tp,
bool _Requires =
247 !__are_same<_Tp, _CharT*>::__value
248 && !__are_same<_Tp, const _CharT*>::__value
249 && !__are_same<_Tp, iterator>::__value
250 && !__are_same<_Tp, const_iterator>::__value>
251 struct __enable_if_not_native_iterator
253 template<
typename _Tp>
254 struct __enable_if_not_native_iterator<_Tp, false> { };
258 _M_check(size_type __pos,
const char* __s)
const
260 if (__pos > this->
size())
261 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
262 "this->size() (which is %zu)"),
263 __s, __pos, this->
size());
268 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
271 __throw_length_error(__N(__s));
277 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
279 const bool __testoff = __off < this->
size() - __pos;
280 return __testoff ? __off : this->
size() - __pos;
285 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
287 return (less<const _CharT*>()(__s, _M_data())
288 || less<const _CharT*>()(_M_data() + this->
size(), __s));
294 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
297 traits_type::assign(*__d, *__s);
299 traits_type::copy(__d, __s, __n);
303 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
306 traits_type::assign(*__d, *__s);
312 _S_assign(_CharT* __d, size_type __n, _CharT __c)
315 traits_type::assign(*__d, __c);
317 traits_type::assign(__d, __n, __c);
322 template<
class _Iterator>
324 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
327 for (; __k1 != __k2; ++__k1, ++__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 #if __cplusplus >= 201103L
382 noexcept(is_nothrow_default_constructible<_Alloc>::value)
384 : _M_dataplus(_M_local_data())
385 { _M_set_length(0); }
392 : _M_dataplus(_M_local_data(), __a)
393 { _M_set_length(0); }
400 : _M_dataplus(_M_local_data(), __str._M_get_allocator())
401 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
412 size_type __n = npos)
413 : _M_dataplus(_M_local_data())
415 const _CharT* __start = __str._M_data()
416 + __str._M_check(__pos,
"basic_string::basic_string");
417 _M_construct(__start, __start + __str._M_limit(__pos, __n));
428 size_type __n,
const _Alloc& __a)
429 : _M_dataplus(_M_local_data(), __a)
431 const _CharT* __start
432 = __str._M_data() + __str._M_check(__pos,
"string::string");
433 _M_construct(__start, __start + __str._M_limit(__pos, __n));
446 const _Alloc& __a = _Alloc())
447 : _M_dataplus(_M_local_data(), __a)
448 { _M_construct(__s, __s + __n); }
455 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
456 : _M_dataplus(_M_local_data(), __a)
457 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
465 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
466 : _M_dataplus(_M_local_data(), __a)
467 { _M_construct(__n, __c); }
469 #if __cplusplus >= 201103L
478 : _M_dataplus(_M_local_data(),
std::
move(__str._M_get_allocator()))
480 if (__str._M_is_local())
482 traits_type::copy(_M_local_buf, __str._M_local_buf,
483 _S_local_capacity + 1);
487 _M_data(__str._M_data());
488 _M_capacity(__str._M_allocated_capacity);
494 _M_length(__str.length());
495 __str._M_data(__str._M_local_data());
496 __str._M_set_length(0);
504 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
505 : _M_dataplus(_M_local_data(), __a)
506 { _M_construct(__l.begin(), __l.end()); }
509 : _M_dataplus(_M_local_data(), __a)
510 { _M_construct(__str.begin(), __str.end()); }
513 : _M_dataplus(_M_local_data(), __a)
515 if (__str.get_allocator() == __a)
518 _M_construct(__str.begin(), __str.end());
529 #if __cplusplus >= 201103L
530 template<
typename _InputIterator,
531 typename = std::_RequireInputIter<_InputIterator>>
533 template<
typename _InputIterator>
535 basic_string(_InputIterator __beg, _InputIterator __end,
536 const _Alloc& __a = _Alloc())
537 : _M_dataplus(_M_local_data(), __a)
538 { _M_construct(__beg, __end); }
552 {
return this->
assign(__str); }
560 {
return this->
assign(__s); }
576 #if __cplusplus >= 201103L
601 this->
assign(__l.begin(), __l.size());
612 begin() _GLIBCXX_NOEXCEPT
613 {
return iterator(_M_data()); }
620 begin() const _GLIBCXX_NOEXCEPT
621 {
return const_iterator(_M_data()); }
628 end() _GLIBCXX_NOEXCEPT
629 {
return iterator(_M_data() + this->
size()); }
636 end() const _GLIBCXX_NOEXCEPT
637 {
return const_iterator(_M_data() + this->
size()); }
645 rbegin() _GLIBCXX_NOEXCEPT
646 {
return reverse_iterator(this->
end()); }
653 const_reverse_iterator
654 rbegin() const _GLIBCXX_NOEXCEPT
655 {
return const_reverse_iterator(this->
end()); }
663 rend() _GLIBCXX_NOEXCEPT
664 {
return reverse_iterator(this->
begin()); }
671 const_reverse_iterator
672 rend() const _GLIBCXX_NOEXCEPT
673 {
return const_reverse_iterator(this->
begin()); }
675 #if __cplusplus >= 201103L
682 {
return const_iterator(this->_M_data()); }
689 cend() const noexcept
690 {
return const_iterator(this->_M_data() + this->
size()); }
697 const_reverse_iterator
699 {
return const_reverse_iterator(this->
end()); }
706 const_reverse_iterator
707 crend() const noexcept
708 {
return const_reverse_iterator(this->
begin()); }
716 size() const _GLIBCXX_NOEXCEPT
717 {
return _M_string_length; }
722 length() const _GLIBCXX_NOEXCEPT
723 {
return _M_string_length; }
728 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
741 resize(size_type __n, _CharT __c);
755 { this->
resize(__n, _CharT()); }
757 #if __cplusplus >= 201103L
779 return _M_is_local() ? size_type(_S_local_capacity)
780 : _M_allocated_capacity;
801 reserve(size_type __res_arg = 0);
807 clear() _GLIBCXX_NOEXCEPT
808 { _M_set_length(0); }
815 empty() const _GLIBCXX_NOEXCEPT
816 {
return this->
size() == 0; }
830 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
832 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
833 return _M_data()[__pos];
851 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
853 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
854 return _M_data()[__pos];
868 at(size_type __n)
const
870 if (__n >= this->
size())
871 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
872 "(which is %zu) >= this->size() "
875 return _M_data()[__n];
892 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
893 "(which is %zu) >= this->size() "
896 return _M_data()[__n];
899 #if __cplusplus >= 201103L
913 front() const noexcept
929 back() const noexcept
941 {
return this->
append(__str); }
950 {
return this->
append(__s); }
964 #if __cplusplus >= 201103L
972 {
return this->
append(__l.begin(), __l.size()); }
982 {
return _M_append(__str._M_data(), __str.size()); }
999 {
return _M_append(__str._M_data()
1000 + __str._M_check(__pos,
"basic_string::append"),
1001 __str._M_limit(__pos, __n)); }
1010 append(
const _CharT* __s, size_type __n)
1012 __glibcxx_requires_string_len(__s, __n);
1013 _M_check_length(size_type(0), __n,
"basic_string::append");
1014 return _M_append(__s, __n);
1023 append(
const _CharT* __s)
1025 __glibcxx_requires_string(__s);
1026 const size_type __n = traits_type::length(__s);
1027 _M_check_length(size_type(0), __n,
"basic_string::append");
1028 return _M_append(__s, __n);
1040 append(size_type __n, _CharT __c)
1041 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1043 #if __cplusplus >= 201103L
1050 append(initializer_list<_CharT> __l)
1051 {
return this->
append(__l.begin(), __l.size()); }
1062 #if __cplusplus >= 201103L
1063 template<
class _InputIterator,
1064 typename = std::_RequireInputIter<_InputIterator>>
1066 template<
class _InputIterator>
1069 append(_InputIterator __first, _InputIterator __last)
1079 const size_type __size = this->
size();
1081 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1082 traits_type::assign(this->_M_data()[__size], __c);
1083 this->_M_set_length(__size + 1);
1094 this->_M_assign(__str);
1098 #if __cplusplus >= 201103L
1131 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1132 + __str._M_check(__pos,
"basic_string::assign"),
1133 __str._M_limit(__pos, __n)); }
1146 assign(
const _CharT* __s, size_type __n)
1148 __glibcxx_requires_string_len(__s, __n);
1149 return _M_replace(size_type(0), this->
size(), __s, __n);
1162 assign(
const _CharT* __s)
1164 __glibcxx_requires_string(__s);
1165 return _M_replace(size_type(0), this->
size(), __s,
1166 traits_type::length(__s));
1179 assign(size_type __n, _CharT __c)
1180 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1190 #if __cplusplus >= 201103L
1191 template<
class _InputIterator,
1192 typename = std::_RequireInputIter<_InputIterator>>
1194 template<
class _InputIterator>
1197 assign(_InputIterator __first, _InputIterator __last)
1200 #if __cplusplus >= 201103L
1207 assign(initializer_list<_CharT> __l)
1208 {
return this->
assign(__l.begin(), __l.size()); }
1211 #if __cplusplus >= 201103L
1228 insert(const_iterator __p, size_type __n, _CharT __c)
1230 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1231 const size_type __pos = __p -
begin();
1232 this->
replace(__p, __p, __n, __c);
1233 return iterator(this->_M_data() + __pos);
1250 insert(iterator __p, size_type __n, _CharT __c)
1251 { this->
replace(__p, __p, __n, __c); }
1254 #if __cplusplus >= 201103L
1269 template<
class _InputIterator,
1270 typename = std::_RequireInputIter<_InputIterator>>
1272 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1274 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1275 const size_type __pos = __p -
begin();
1276 this->
replace(__p, __p, __beg, __end);
1277 return iterator(this->_M_data() + __pos);
1292 template<
class _InputIterator>
1294 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1295 { this->
replace(__p, __p, __beg, __end); }
1298 #if __cplusplus >= 201103L
1306 insert(iterator __p, initializer_list<_CharT> __l)
1308 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1309 this->
insert(__p -
begin(), __l.begin(), __l.size());
1327 {
return this->
replace(__pos1, size_type(0),
1328 __str._M_data(), __str.size()); }
1350 size_type __pos2, size_type __n)
1351 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1352 + __str._M_check(__pos2,
"basic_string::insert"),
1353 __str._M_limit(__pos2, __n)); }
1372 insert(size_type __pos,
const _CharT* __s, size_type __n)
1373 {
return this->
replace(__pos, size_type(0), __s, __n); }
1391 insert(size_type __pos,
const _CharT* __s)
1393 __glibcxx_requires_string(__s);
1394 return this->
replace(__pos, size_type(0), __s,
1395 traits_type::length(__s));
1415 insert(size_type __pos, size_type __n, _CharT __c)
1416 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1417 size_type(0), __n, __c); }
1433 insert(__const_iterator __p, _CharT __c)
1435 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1436 const size_type __pos = __p -
begin();
1437 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1438 return iterator(_M_data() + __pos);
1457 erase(size_type __pos = 0, size_type __n = npos)
1459 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1460 _M_limit(__pos, __n));
1473 erase(__const_iterator __position)
1475 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1476 && __position <
end());
1477 const size_type __pos = __position -
begin();
1478 this->_M_erase(__pos, size_type(1));
1479 return iterator(_M_data() + __pos);
1492 erase(__const_iterator __first, __const_iterator __last)
1494 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1495 && __last <=
end());
1496 const size_type __pos = __first -
begin();
1497 this->_M_erase(__pos, __last - __first);
1498 return iterator(this->_M_data() + __pos);
1501 #if __cplusplus >= 201103L
1509 { _M_erase(
size()-1, 1); }
1531 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1553 size_type __pos2, size_type __n2)
1554 {
return this->
replace(__pos1, __n1, __str._M_data()
1555 + __str._M_check(__pos2,
"basic_string::replace"),
1556 __str._M_limit(__pos2, __n2)); }
1577 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1580 __glibcxx_requires_string_len(__s, __n2);
1581 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1582 _M_limit(__pos, __n1), __s, __n2);
1602 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1604 __glibcxx_requires_string(__s);
1605 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1626 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1627 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1628 _M_limit(__pos, __n1), __n2, __c); }
1644 replace(__const_iterator __i1, __const_iterator __i2,
1646 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1664 replace(__const_iterator __i1, __const_iterator __i2,
1665 const _CharT* __s, size_type __n)
1667 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1669 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1686 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1688 __glibcxx_requires_string(__s);
1689 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1707 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1710 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1712 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1730 #if __cplusplus >= 201103L
1731 template<
class _InputIterator,
1732 typename = std::_RequireInputIter<_InputIterator>>
1734 replace(const_iterator __i1, const_iterator __i2,
1735 _InputIterator __k1, _InputIterator __k2)
1737 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1739 __glibcxx_requires_valid_range(__k1, __k2);
1740 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1741 std::__false_type());
1744 template<
class _InputIterator>
1745 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
1746 typename __enable_if_not_native_iterator<_InputIterator>::__type
1750 replace(iterator __i1, iterator __i2,
1751 _InputIterator __k1, _InputIterator __k2)
1753 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1755 __glibcxx_requires_valid_range(__k1, __k2);
1756 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1757 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1764 replace(__const_iterator __i1, __const_iterator __i2,
1765 _CharT* __k1, _CharT* __k2)
1767 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1769 __glibcxx_requires_valid_range(__k1, __k2);
1775 replace(__const_iterator __i1, __const_iterator __i2,
1776 const _CharT* __k1,
const _CharT* __k2)
1778 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1780 __glibcxx_requires_valid_range(__k1, __k2);
1786 replace(__const_iterator __i1, __const_iterator __i2,
1787 iterator __k1, iterator __k2)
1789 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1791 __glibcxx_requires_valid_range(__k1, __k2);
1793 __k1.base(), __k2 - __k1);
1797 replace(__const_iterator __i1, __const_iterator __i2,
1798 const_iterator __k1, const_iterator __k2)
1800 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1802 __glibcxx_requires_valid_range(__k1, __k2);
1804 __k1.base(), __k2 - __k1);
1807 #if __cplusplus >= 201103L
1823 initializer_list<_CharT> __l)
1824 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1828 template<
class _Integer>
1830 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1831 _Integer __n, _Integer __val, __true_type)
1832 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1834 template<
class _InputIterator>
1836 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1837 _InputIterator __k1, _InputIterator __k2,
1841 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1845 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1846 const size_type __len2);
1849 _M_append(
const _CharT* __s, size_type __n);
1866 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1886 c_str() const _GLIBCXX_NOEXCEPT
1887 {
return _M_data(); }
1896 data() const _GLIBCXX_NOEXCEPT
1897 {
return _M_data(); }
1904 {
return _M_get_allocator(); }
1919 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
1934 {
return this->
find(__str.data(), __pos, __str.size()); }
1947 find(
const _CharT* __s, size_type __pos = 0)
const
1949 __glibcxx_requires_string(__s);
1950 return this->
find(__s, __pos, traits_type::length(__s));
1964 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
1979 {
return this->
rfind(__str.data(), __pos, __str.size()); }
1994 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2007 rfind(
const _CharT* __s, size_type __pos = npos)
const
2009 __glibcxx_requires_string(__s);
2010 return this->
rfind(__s, __pos, traits_type::length(__s));
2024 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2040 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2055 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2070 __glibcxx_requires_string(__s);
2071 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2087 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2088 {
return this->
find(__c, __pos); }
2104 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2119 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2132 find_last_of(
const _CharT* __s, size_type __pos = npos)
const
2134 __glibcxx_requires_string(__s);
2135 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2151 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2152 {
return this->
rfind(__c, __pos); }
2183 size_type __n)
const;
2198 __glibcxx_requires_string(__s);
2246 size_type __n)
const;
2261 __glibcxx_requires_string(__s);
2292 substr(size_type __pos = 0, size_type __n = npos)
const
2294 _M_check(__pos,
"basic_string::substr"), __n); }
2313 const size_type __size = this->
size();
2314 const size_type __osize = __str.size();
2315 const size_type __len =
std::min(__size, __osize);
2317 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2319 __r = _S_compare(__size, __osize);
2370 size_type __pos2, size_type __n2)
const;
2387 compare(
const _CharT* __s)
const;
2411 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2438 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2439 size_type __n2)
const;
2441 _GLIBCXX_END_NAMESPACE_CXX11
2442 #else // !_GLIBCXX_USE_CXX11_ABI
2507 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2510 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2514 typedef _Traits traits_type;
2515 typedef typename _Traits::char_type value_type;
2516 typedef _Alloc allocator_type;
2517 typedef typename _CharT_alloc_type::size_type size_type;
2518 typedef typename _CharT_alloc_type::difference_type difference_type;
2519 typedef typename _CharT_alloc_type::reference reference;
2520 typedef typename _CharT_alloc_type::const_reference const_reference;
2521 typedef typename _CharT_alloc_type::pointer pointer;
2522 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2523 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2524 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2546 size_type _M_length;
2547 size_type _M_capacity;
2548 _Atomic_word _M_refcount;
2551 struct _Rep : _Rep_base
2554 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2569 static const size_type _S_max_size;
2570 static const _CharT _S_terminal;
2574 static size_type _S_empty_rep_storage[];
2577 _S_empty_rep() _GLIBCXX_NOEXCEPT
2582 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2583 return *
reinterpret_cast<_Rep*
>(__p);
2587 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2588 {
return this->_M_refcount < 0; }
2591 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2592 {
return this->_M_refcount > 0; }
2595 _M_set_leaked() _GLIBCXX_NOEXCEPT
2596 { this->_M_refcount = -1; }
2599 _M_set_sharable() _GLIBCXX_NOEXCEPT
2600 { this->_M_refcount = 0; }
2603 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2605 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2606 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2609 this->_M_set_sharable();
2610 this->_M_length = __n;
2611 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2618 _M_refdata()
throw()
2619 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2622 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2624 return (!_M_is_leaked() && __alloc1 == __alloc2)
2625 ? _M_refcopy() : _M_clone(__alloc1);
2630 _S_create(size_type, size_type,
const _Alloc&);
2633 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2635 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2636 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2640 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2641 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2644 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2651 _M_destroy(
const _Alloc&)
throw();
2654 _M_refcopy()
throw()
2656 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2657 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2659 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2660 return _M_refdata();
2664 _M_clone(
const _Alloc&, size_type __res = 0);
2668 struct _Alloc_hider : _Alloc
2670 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2671 : _Alloc(__a), _M_p(__dat) { }
2681 static const size_type npos =
static_cast<size_type
>(-1);
2685 mutable _Alloc_hider _M_dataplus;
2688 _M_data() const _GLIBCXX_NOEXCEPT
2689 {
return _M_dataplus._M_p; }
2692 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2693 {
return (_M_dataplus._M_p = __p); }
2696 _M_rep() const _GLIBCXX_NOEXCEPT
2697 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2702 _M_ibegin() const _GLIBCXX_NOEXCEPT
2703 {
return iterator(_M_data()); }
2706 _M_iend() const _GLIBCXX_NOEXCEPT
2707 {
return iterator(_M_data() + this->
size()); }
2712 if (!_M_rep()->_M_is_leaked())
2717 _M_check(size_type __pos,
const char* __s)
const
2719 if (__pos > this->
size())
2720 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
2721 "this->size() (which is %zu)"),
2722 __s, __pos, this->
size());
2727 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
2730 __throw_length_error(__N(__s));
2735 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2737 const bool __testoff = __off < this->
size() - __pos;
2738 return __testoff ? __off : this->
size() - __pos;
2743 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2745 return (less<const _CharT*>()(__s, _M_data())
2746 || less<const _CharT*>()(_M_data() + this->
size(), __s));
2752 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2755 traits_type::assign(*__d, *__s);
2757 traits_type::copy(__d, __s, __n);
2761 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2764 traits_type::assign(*__d, *__s);
2770 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2773 traits_type::assign(*__d, __c);
2775 traits_type::assign(__d, __n, __c);
2780 template<
class _Iterator>
2782 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2785 for (; __k1 != __k2; ++__k1, ++__p)
2786 traits_type::assign(*__p, *__k1);
2790 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2791 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2794 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2796 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2799 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2800 { _M_copy(__p, __k1, __k2 - __k1); }
2803 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2805 { _M_copy(__p, __k1, __k2 - __k1); }
2808 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2810 const difference_type __d = difference_type(__n1 - __n2);
2812 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2813 return __gnu_cxx::__numeric_traits<int>::__max;
2814 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2815 return __gnu_cxx::__numeric_traits<int>::__min;
2821 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2827 _S_empty_rep() _GLIBCXX_NOEXCEPT
2828 {
return _Rep::_S_empty_rep(); }
2839 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2840 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2842 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2864 size_type __n = npos);
2873 size_type __n,
const _Alloc& __a);
2885 const _Alloc& __a = _Alloc());
2891 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2898 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2900 #if __cplusplus >= 201103L
2909 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2912 : _M_dataplus(__str._M_dataplus)
2914 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2915 __str._M_data(_S_empty_rep()._M_refdata());
2917 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
2926 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc());
2935 template<
class _InputIterator>
2936 basic_string(_InputIterator __beg, _InputIterator __end,
2937 const _Alloc& __a = _Alloc());
2951 {
return this->
assign(__str); }
2959 {
return this->
assign(__s); }
2975 #if __cplusplus >= 201103L
2999 this->
assign(__l.begin(), __l.size());
3013 return iterator(_M_data());
3022 {
return const_iterator(_M_data()); }
3032 return iterator(_M_data() + this->
size());
3041 {
return const_iterator(_M_data() + this->
size()); }
3050 {
return reverse_iterator(this->
end()); }
3057 const_reverse_iterator
3059 {
return const_reverse_iterator(this->
end()); }
3068 {
return reverse_iterator(this->
begin()); }
3075 const_reverse_iterator
3077 {
return const_reverse_iterator(this->
begin()); }
3079 #if __cplusplus >= 201103L
3086 {
return const_iterator(this->_M_data()); }
3094 {
return const_iterator(this->_M_data() + this->
size()); }
3101 const_reverse_iterator
3103 {
return const_reverse_iterator(this->
end()); }
3110 const_reverse_iterator
3112 {
return const_reverse_iterator(this->
begin()); }
3121 {
return _M_rep()->_M_length; }
3127 {
return _M_rep()->_M_length; }
3132 {
return _Rep::_S_max_size; }
3145 resize(size_type __n, _CharT __c);
3159 { this->
resize(__n, _CharT()); }
3161 #if __cplusplus >= 201103L
3182 {
return _M_rep()->_M_capacity; }
3202 reserve(size_type __res_arg = 0);
3210 { _M_mutate(0, this->
size(), 0); }
3218 {
return this->
size() == 0; }
3234 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3235 return _M_data()[__pos];
3253 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3255 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3257 return _M_data()[__pos];
3273 if (__n >= this->
size())
3274 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3275 "(which is %zu) >= this->size() "
3278 return _M_data()[__n];
3296 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3297 "(which is %zu) >= this->size() "
3301 return _M_data()[__n];
3304 #if __cplusplus >= 201103L
3346 {
return this->
append(__str); }
3355 {
return this->
append(__s); }
3369 #if __cplusplus >= 201103L
3377 {
return this->
append(__l.begin(), __l.size()); }
3411 append(
const _CharT* __s, size_type __n);
3421 __glibcxx_requires_string(__s);
3422 return this->
append(__s, traits_type::length(__s));
3434 append(size_type __n, _CharT __c);
3436 #if __cplusplus >= 201103L
3444 {
return this->
append(__l.begin(), __l.size()); }
3455 template<
class _InputIterator>
3457 append(_InputIterator __first, _InputIterator __last)
3458 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3467 const size_type __len = 1 + this->
size();
3468 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3470 traits_type::assign(_M_data()[this->
size()], __c);
3471 _M_rep()->_M_set_length_and_sharable(__len);
3482 #if __cplusplus >= 201103L
3515 {
return this->
assign(__str._M_data()
3516 + __str._M_check(__pos,
"basic_string::assign"),
3517 __str._M_limit(__pos, __n)); }
3530 assign(
const _CharT* __s, size_type __n);
3544 __glibcxx_requires_string(__s);
3545 return this->
assign(__s, traits_type::length(__s));
3559 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3569 template<
class _InputIterator>
3571 assign(_InputIterator __first, _InputIterator __last)
3572 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3574 #if __cplusplus >= 201103L
3582 {
return this->
assign(__l.begin(), __l.size()); }
3599 insert(iterator __p, size_type __n, _CharT __c)
3600 { this->
replace(__p, __p, __n, __c); }
3614 template<
class _InputIterator>
3616 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3617 { this->
replace(__p, __p, __beg, __end); }
3619 #if __cplusplus >= 201103L
3627 insert(iterator __p, initializer_list<_CharT> __l)
3629 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3630 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3648 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3670 size_type __pos2, size_type __n)
3671 {
return this->
insert(__pos1, __str._M_data()
3672 + __str._M_check(__pos2,
"basic_string::insert"),
3673 __str._M_limit(__pos2, __n)); }
3692 insert(size_type __pos,
const _CharT* __s, size_type __n);
3712 __glibcxx_requires_string(__s);
3713 return this->
insert(__pos, __s, traits_type::length(__s));
3733 insert(size_type __pos, size_type __n, _CharT __c)
3734 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3735 size_type(0), __n, __c); }
3753 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3754 const size_type __pos = __p - _M_ibegin();
3755 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3756 _M_rep()->_M_set_leaked();
3757 return iterator(_M_data() + __pos);
3776 erase(size_type __pos = 0, size_type __n = npos)
3778 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3779 _M_limit(__pos, __n), size_type(0));
3794 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3795 && __position < _M_iend());
3796 const size_type __pos = __position - _M_ibegin();
3797 _M_mutate(__pos, size_type(1), size_type(0));
3798 _M_rep()->_M_set_leaked();
3799 return iterator(_M_data() + __pos);
3812 erase(iterator __first, iterator __last);
3814 #if __cplusplus >= 201103L
3844 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3866 size_type __pos2, size_type __n2)
3867 {
return this->
replace(__pos1, __n1, __str._M_data()
3868 + __str._M_check(__pos2,
"basic_string::replace"),
3869 __str._M_limit(__pos2, __n2)); }
3890 replace(size_type __pos, size_type __n1,
const _CharT* __s,
3910 replace(size_type __pos, size_type __n1,
const _CharT* __s)
3912 __glibcxx_requires_string(__s);
3913 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
3934 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
3935 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
3936 _M_limit(__pos, __n1), __n2, __c); }
3953 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
3971 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
3973 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
3974 && __i2 <= _M_iend());
3975 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
3992 replace(iterator __i1, iterator __i2,
const _CharT* __s)
3994 __glibcxx_requires_string(__s);
3995 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4013 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4015 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4016 && __i2 <= _M_iend());
4017 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4035 template<
class _InputIterator>
4038 _InputIterator __k1, _InputIterator __k2)
4040 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4041 && __i2 <= _M_iend());
4042 __glibcxx_requires_valid_range(__k1, __k2);
4043 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4044 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4050 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4052 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4053 && __i2 <= _M_iend());
4054 __glibcxx_requires_valid_range(__k1, __k2);
4055 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4060 replace(iterator __i1, iterator __i2,
4061 const _CharT* __k1,
const _CharT* __k2)
4063 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4064 && __i2 <= _M_iend());
4065 __glibcxx_requires_valid_range(__k1, __k2);
4066 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4071 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4073 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4074 && __i2 <= _M_iend());
4075 __glibcxx_requires_valid_range(__k1, __k2);
4076 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4077 __k1.base(), __k2 - __k1);
4081 replace(iterator __i1, iterator __i2,
4082 const_iterator __k1, const_iterator __k2)
4084 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4085 && __i2 <= _M_iend());
4086 __glibcxx_requires_valid_range(__k1, __k2);
4087 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4088 __k1.base(), __k2 - __k1);
4091 #if __cplusplus >= 201103L
4107 initializer_list<_CharT> __l)
4108 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4112 template<
class _Integer>
4114 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4115 _Integer __val, __true_type)
4116 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4118 template<
class _InputIterator>
4120 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4121 _InputIterator __k2, __false_type);
4124 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4128 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4133 template<
class _InIterator>
4135 _S_construct_aux(_InIterator __beg, _InIterator __end,
4136 const _Alloc& __a, __false_type)
4138 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4139 return _S_construct(__beg, __end, __a, _Tag());
4144 template<
class _Integer>
4146 _S_construct_aux(_Integer __beg, _Integer __end,
4147 const _Alloc& __a, __true_type)
4148 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4152 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4153 {
return _S_construct(__req, __c, __a); }
4155 template<
class _InIterator>
4157 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4159 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4160 return _S_construct_aux(__beg, __end, __a, _Integral());
4164 template<
class _InIterator>
4166 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4167 input_iterator_tag);
4171 template<
class _FwdIterator>
4173 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4174 forward_iterator_tag);
4177 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4194 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4216 {
return _M_data(); }
4226 {
return _M_data(); }
4233 {
return _M_dataplus; }
4248 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4263 {
return this->
find(__str.data(), __pos, __str.size()); }
4276 find(
const _CharT* __s, size_type __pos = 0)
const
4278 __glibcxx_requires_string(__s);
4279 return this->
find(__s, __pos, traits_type::length(__s));
4293 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
4308 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4323 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4336 rfind(
const _CharT* __s, size_type __pos = npos)
const
4338 __glibcxx_requires_string(__s);
4339 return this->
rfind(__s, __pos, traits_type::length(__s));
4353 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
4369 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4384 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4399 __glibcxx_requires_string(__s);
4400 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4417 {
return this->
find(__c, __pos); }
4433 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4448 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4463 __glibcxx_requires_string(__s);
4464 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4481 {
return this->
rfind(__c, __pos); }
4512 size_type __n)
const;
4527 __glibcxx_requires_string(__s);
4575 size_type __n)
const;
4590 __glibcxx_requires_string(__s);
4621 substr(size_type __pos = 0, size_type __n = npos)
const
4623 _M_check(__pos,
"basic_string::substr"), __n); }
4642 const size_type __size = this->
size();
4643 const size_type __osize = __str.size();
4644 const size_type __len =
std::min(__size, __osize);
4646 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4648 __r = _S_compare(__size, __osize);
4699 size_type __pos2, size_type __n2)
const;
4716 compare(
const _CharT* __s)
const;
4740 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4767 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4768 size_type __n2)
const;
4770 #endif // !_GLIBCXX_USE_CXX11_ABI
4779 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4780 basic_string<_CharT, _Traits, _Alloc>
4785 __str.append(__rhs);
4795 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4796 basic_string<_CharT,_Traits,_Alloc>
4798 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4806 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4807 basic_string<_CharT,_Traits,_Alloc>
4808 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4816 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4817 inline basic_string<_CharT, _Traits, _Alloc>
4819 const _CharT* __rhs)
4822 __str.append(__rhs);
4832 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4833 inline basic_string<_CharT, _Traits, _Alloc>
4837 typedef typename __string_type::size_type __size_type;
4838 __string_type __str(__lhs);
4839 __str.append(__size_type(1), __rhs);
4843 #if __cplusplus >= 201103L
4844 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4845 inline basic_string<_CharT, _Traits, _Alloc>
4846 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4847 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4848 {
return std::move(__lhs.append(__rhs)); }
4850 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4851 inline basic_string<_CharT, _Traits, _Alloc>
4852 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4853 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4854 {
return std::move(__rhs.insert(0, __lhs)); }
4856 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4857 inline basic_string<_CharT, _Traits, _Alloc>
4858 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4859 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4861 const auto __size = __lhs.size() + __rhs.size();
4862 const bool __cond = (__size > __lhs.capacity()
4863 && __size <= __rhs.capacity());
4864 return __cond ?
std::move(__rhs.insert(0, __lhs))
4868 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4869 inline basic_string<_CharT, _Traits, _Alloc>
4871 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4872 {
return std::move(__rhs.insert(0, __lhs)); }
4874 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4875 inline basic_string<_CharT, _Traits, _Alloc>
4877 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4878 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4880 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4881 inline basic_string<_CharT, _Traits, _Alloc>
4882 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4883 const _CharT* __rhs)
4884 {
return std::move(__lhs.append(__rhs)); }
4886 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4887 inline basic_string<_CharT, _Traits, _Alloc>
4888 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4890 {
return std::move(__lhs.append(1, __rhs)); }
4900 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4904 {
return __lhs.compare(__rhs) == 0; }
4906 template<
typename _CharT>
4908 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
4909 operator==(
const basic_string<_CharT>& __lhs,
4910 const basic_string<_CharT>& __rhs)
4911 {
return (__lhs.size() == __rhs.size()
4921 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4923 operator==(
const _CharT* __lhs,
4925 {
return __rhs.compare(__lhs) == 0; }
4933 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4936 const _CharT* __rhs)
4937 {
return __lhs.compare(__rhs) == 0; }
4946 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4950 {
return !(__lhs == __rhs); }
4958 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4960 operator!=(
const _CharT* __lhs,
4962 {
return !(__lhs == __rhs); }
4970 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4973 const _CharT* __rhs)
4974 {
return !(__lhs == __rhs); }
4983 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4985 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4987 {
return __lhs.compare(__rhs) < 0; }
4995 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4997 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4998 const _CharT* __rhs)
4999 {
return __lhs.compare(__rhs) < 0; }
5007 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5011 {
return __rhs.compare(__lhs) > 0; }
5020 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5024 {
return __lhs.compare(__rhs) > 0; }
5032 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5035 const _CharT* __rhs)
5036 {
return __lhs.compare(__rhs) > 0; }
5044 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5048 {
return __rhs.compare(__lhs) < 0; }
5057 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5059 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5061 {
return __lhs.compare(__rhs) <= 0; }
5069 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5071 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5072 const _CharT* __rhs)
5073 {
return __lhs.compare(__rhs) <= 0; }
5081 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5085 {
return __rhs.compare(__lhs) >= 0; }
5094 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5098 {
return __lhs.compare(__rhs) >= 0; }
5106 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5109 const _CharT* __rhs)
5110 {
return __lhs.compare(__rhs) >= 0; }
5118 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5122 {
return __rhs.compare(__lhs) <= 0; }
5131 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5135 { __lhs.swap(__rhs); }
5150 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5151 basic_istream<_CharT, _Traits>&
5152 operator>>(basic_istream<_CharT, _Traits>& __is,
5153 basic_string<_CharT, _Traits, _Alloc>& __str);
5156 basic_istream<char>&
5157 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
5168 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5169 inline basic_ostream<_CharT, _Traits>&
5170 operator<<(basic_ostream<_CharT, _Traits>& __os,
5175 return __ostream_insert(__os, __str.data(), __str.size());
5191 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5192 basic_istream<_CharT, _Traits>&
5193 getline(basic_istream<_CharT, _Traits>& __is,
5194 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
5208 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5209 inline basic_istream<_CharT, _Traits>&
5212 {
return std::getline(__is, __str, __is.widen(
'\n')); }
5214 #if __cplusplus >= 201103L
5216 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5217 inline basic_istream<_CharT, _Traits>&
5223 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5224 inline basic_istream<_CharT, _Traits>&
5231 basic_istream<char>&
5232 getline(basic_istream<char>& __in, basic_string<char>& __str,
5235 #ifdef _GLIBCXX_USE_WCHAR_T
5237 basic_istream<wchar_t>&
5238 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
5242 _GLIBCXX_END_NAMESPACE_VERSION
5245 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
5249 namespace std _GLIBCXX_VISIBILITY(default)
5251 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5252 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5256 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5257 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
5261 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5262 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
5265 inline unsigned long
5266 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5267 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
5271 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5272 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
5275 inline unsigned long long
5276 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5277 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
5282 stof(
const string& __str,
size_t* __idx = 0)
5283 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
5286 stod(
const string& __str,
size_t* __idx = 0)
5287 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
5290 stold(
const string& __str,
size_t* __idx = 0)
5291 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
5297 to_string(
int __val)
5298 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5302 to_string(
unsigned __val)
5303 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5304 4 *
sizeof(unsigned),
5308 to_string(
long __val)
5309 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5313 to_string(
unsigned long __val)
5314 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5315 4 *
sizeof(
unsigned long),
5319 to_string(
long long __val)
5320 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5321 4 *
sizeof(
long long),
5325 to_string(
unsigned long long __val)
5326 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5327 4 *
sizeof(
unsigned long long),
5331 to_string(
float __val)
5334 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5335 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5340 to_string(
double __val)
5343 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5344 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5349 to_string(
long double __val)
5352 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5353 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5357 #ifdef _GLIBCXX_USE_WCHAR_T
5359 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5360 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
5364 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5365 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
5368 inline unsigned long
5369 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5370 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
5374 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5375 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
5378 inline unsigned long long
5379 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5380 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
5385 stof(
const wstring& __str,
size_t* __idx = 0)
5386 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
5389 stod(
const wstring& __str,
size_t* __idx = 0)
5390 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
5393 stold(
const wstring& __str,
size_t* __idx = 0)
5394 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
5396 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5399 to_wstring(
int __val)
5400 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5404 to_wstring(
unsigned __val)
5405 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5406 4 *
sizeof(unsigned),
5410 to_wstring(
long __val)
5411 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5415 to_wstring(
unsigned long __val)
5416 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5417 4 *
sizeof(
unsigned long),
5421 to_wstring(
long long __val)
5422 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5423 4 *
sizeof(
long long),
5427 to_wstring(
unsigned long long __val)
5428 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5429 4 *
sizeof(
unsigned long long),
5433 to_wstring(
float __val)
5436 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5437 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5442 to_wstring(
double __val)
5445 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5446 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5451 to_wstring(
long double __val)
5454 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5455 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5458 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5461 _GLIBCXX_END_NAMESPACE_CXX11
5462 _GLIBCXX_END_NAMESPACE_VERSION
5467 #if __cplusplus >= 201103L
5471 namespace std _GLIBCXX_VISIBILITY(default)
5473 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5477 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5481 :
public __hash_base<size_t, string>
5484 operator()(
const string& __s)
const noexcept
5485 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5489 struct __is_fast_hash<
hash<
string>> : std::false_type
5492 #ifdef _GLIBCXX_USE_WCHAR_T
5496 :
public __hash_base<size_t, wstring>
5499 operator()(
const wstring& __s)
const noexcept
5500 {
return std::_Hash_impl::hash(__s.
data(),
5501 __s.
length() *
sizeof(wchar_t)); }
5505 struct __is_fast_hash<
hash<
wstring>> : std::false_type
5510 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5514 :
public __hash_base<size_t, u16string>
5517 operator()(
const u16string& __s)
const noexcept
5518 {
return std::_Hash_impl::hash(__s.
data(),
5519 __s.
length() *
sizeof(char16_t)); }
5529 :
public __hash_base<size_t, u32string>
5532 operator()(
const u32string& __s)
const noexcept
5533 {
return std::_Hash_impl::hash(__s.
data(),
5534 __s.
length() *
sizeof(char32_t)); }
5542 #if __cplusplus > 201103L
5544 #define __cpp_lib_string_udls 201304
5546 inline namespace literals
5548 inline namespace string_literals
5551 _GLIBCXX_DEFAULT_ABI_TAG
5552 inline basic_string<char>
5553 operator""s(
const char* __str,
size_t __len)
5554 {
return basic_string<char>{__str, __len}; }
5556 #ifdef _GLIBCXX_USE_WCHAR_T
5557 _GLIBCXX_DEFAULT_ABI_TAG
5558 inline basic_string<wchar_t>
5559 operator""s(
const wchar_t* __str,
size_t __len)
5560 {
return basic_string<wchar_t>{__str, __len}; }
5563 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5564 _GLIBCXX_DEFAULT_ABI_TAG
5565 inline basic_string<char16_t>
5566 operator""s(
const char16_t* __str,
size_t __len)
5567 {
return basic_string<char16_t>{__str, __len}; }
5569 _GLIBCXX_DEFAULT_ABI_TAG
5570 inline basic_string<char32_t>
5571 operator""s(
const char32_t* __str,
size_t __len)
5572 {
return basic_string<char32_t>{__str, __len}; }
5578 #endif // __cplusplus > 201103L
5580 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_iterator cbegin() const noexcept
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
Basis for explicit traits specializations.
Managing sequences of characters and character-like objects.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
bool empty() const noexcept
basic_string & append(const basic_string &__str)
Append a string to this string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
int compare(const basic_string &__str) const
Compare to a string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
bool operator<(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string precedes string.
Uniform interface to C++98 and C++0x allocators.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
~basic_string() noexcept
Destroy the string instance.
Forward iterators support a superset of input iterator operations.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C 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.
const_reference front() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
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.
iterator erase(iterator __position)
Remove one character.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
reverse_iterator rbegin()
void resize(size_type __n)
Resizes the string to the specified number of characters.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
void resize(size_type __n, _CharT __c)
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 & operator+=(const basic_string &__str)
Append a string to this string.
bool operator<=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't follow string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a 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.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
Primary class template hash.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
const_iterator begin() const noexcept
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
void push_back(_CharT __c)
Append a single character.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const_reference back() const noexcept
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
static const size_type npos
Value returned by various member functions when they fail.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string< _CharT, _Traits, _Alloc > operator+(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Concatenate two strings.
basic_istream< _CharT, _Traits > & operator>>(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str)
Read stream into a string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
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 & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string()
Default constructor creates an empty string.
Uniform interface to all pointer-like types.
const_reverse_iterator crbegin() const noexcept
const_iterator cend() const noexcept
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
void pop_back()
Remove the last character.
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 & operator=(_CharT __c)
Set value to string of length 1.
const_reverse_iterator rbegin() const noexcept
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reverse_iterator rend() const noexcept
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
const_iterator end() const noexcept
basic_string< wchar_t > wstring
A string of wchar_t.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
ISO C++ entities toplevel namespace is std.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
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.