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 : _M_dataplus(_M_local_data())
382 { _M_set_length(0); }
389 : _M_dataplus(_M_local_data(), __a)
390 { _M_set_length(0); }
397 : _M_dataplus(_M_local_data(), __str._M_get_allocator())
398 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
409 size_type __n = npos)
410 : _M_dataplus(_M_local_data())
412 const _CharT* __start = __str._M_data()
413 + __str._M_check(__pos,
"basic_string::basic_string");
414 _M_construct(__start, __start + __str._M_limit(__pos, __n));
425 size_type __n,
const _Alloc& __a)
426 : _M_dataplus(_M_local_data(), __a)
428 const _CharT* __start
429 = __str._M_data() + __str._M_check(__pos,
"string::string");
430 _M_construct(__start, __start + __str._M_limit(__pos, __n));
443 const _Alloc& __a = _Alloc())
444 : _M_dataplus(_M_local_data(), __a)
445 { _M_construct(__s, __s + __n); }
452 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
453 : _M_dataplus(_M_local_data(), __a)
454 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
462 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
463 : _M_dataplus(_M_local_data(), __a)
464 { _M_construct(__n, __c); }
466 #if __cplusplus >= 201103L
475 : _M_dataplus(_M_local_data(),
std::
move(__str._M_get_allocator()))
477 if (__str._M_is_local())
479 traits_type::copy(_M_local_buf, __str._M_local_buf,
480 _S_local_capacity + 1);
484 _M_data(__str._M_data());
485 _M_capacity(__str._M_allocated_capacity);
491 _M_length(__str.length());
492 __str._M_data(__str._M_local_data());
493 __str._M_set_length(0);
501 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
502 : _M_dataplus(_M_local_data(), __a)
503 { _M_construct(__l.begin(), __l.end()); }
506 : _M_dataplus(_M_local_data(), __a)
507 { _M_construct(__str.begin(), __str.end()); }
510 : _M_dataplus(_M_local_data(), __a)
512 if (__str.get_allocator() == __a)
515 _M_construct(__str.begin(), __str.end());
526 #if __cplusplus >= 201103L
527 template<
typename _InputIterator,
528 typename = std::_RequireInputIter<_InputIterator>>
530 template<
typename _InputIterator>
532 basic_string(_InputIterator __beg, _InputIterator __end,
533 const _Alloc& __a = _Alloc())
534 : _M_dataplus(_M_local_data(), __a)
535 { _M_construct(__beg, __end); }
549 {
return this->
assign(__str); }
557 {
return this->
assign(__s); }
573 #if __cplusplus >= 201103L
598 this->
assign(__l.begin(), __l.size());
609 begin() _GLIBCXX_NOEXCEPT
610 {
return iterator(_M_data()); }
617 begin() const _GLIBCXX_NOEXCEPT
618 {
return const_iterator(_M_data()); }
625 end() _GLIBCXX_NOEXCEPT
626 {
return iterator(_M_data() + this->
size()); }
633 end() const _GLIBCXX_NOEXCEPT
634 {
return const_iterator(_M_data() + this->
size()); }
642 rbegin() _GLIBCXX_NOEXCEPT
643 {
return reverse_iterator(this->
end()); }
650 const_reverse_iterator
651 rbegin() const _GLIBCXX_NOEXCEPT
652 {
return const_reverse_iterator(this->
end()); }
660 rend() _GLIBCXX_NOEXCEPT
661 {
return reverse_iterator(this->
begin()); }
668 const_reverse_iterator
669 rend() const _GLIBCXX_NOEXCEPT
670 {
return const_reverse_iterator(this->
begin()); }
672 #if __cplusplus >= 201103L
679 {
return const_iterator(this->_M_data()); }
686 cend() const noexcept
687 {
return const_iterator(this->_M_data() + this->
size()); }
694 const_reverse_iterator
696 {
return const_reverse_iterator(this->
end()); }
703 const_reverse_iterator
704 crend() const noexcept
705 {
return const_reverse_iterator(this->
begin()); }
713 size() const _GLIBCXX_NOEXCEPT
714 {
return _M_string_length; }
719 length() const _GLIBCXX_NOEXCEPT
720 {
return _M_string_length; }
725 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
738 resize(size_type __n, _CharT __c);
752 { this->
resize(__n, _CharT()); }
754 #if __cplusplus >= 201103L
776 return _M_is_local() ? size_type(_S_local_capacity)
777 : _M_allocated_capacity;
798 reserve(size_type __res_arg = 0);
804 clear() _GLIBCXX_NOEXCEPT
805 { _M_set_length(0); }
812 empty() const _GLIBCXX_NOEXCEPT
813 {
return this->
size() == 0; }
827 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
829 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
830 return _M_data()[__pos];
848 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
850 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
851 return _M_data()[__pos];
865 at(size_type __n)
const
867 if (__n >= this->
size())
868 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
869 "(which is %zu) >= this->size() "
872 return _M_data()[__n];
889 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
890 "(which is %zu) >= this->size() "
893 return _M_data()[__n];
896 #if __cplusplus >= 201103L
910 front() const noexcept
926 back() const noexcept
938 {
return this->
append(__str); }
947 {
return this->
append(__s); }
961 #if __cplusplus >= 201103L
969 {
return this->
append(__l.begin(), __l.size()); }
979 {
return _M_append(__str._M_data(), __str.size()); }
996 {
return _M_append(__str._M_data()
997 + __str._M_check(__pos,
"basic_string::append"),
998 __str._M_limit(__pos, __n)); }
1007 append(
const _CharT* __s, size_type __n)
1009 __glibcxx_requires_string_len(__s, __n);
1010 _M_check_length(size_type(0), __n,
"basic_string::append");
1011 return _M_append(__s, __n);
1020 append(
const _CharT* __s)
1022 __glibcxx_requires_string(__s);
1023 const size_type __n = traits_type::length(__s);
1024 _M_check_length(size_type(0), __n,
"basic_string::append");
1025 return _M_append(__s, __n);
1037 append(size_type __n, _CharT __c)
1038 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1040 #if __cplusplus >= 201103L
1047 append(initializer_list<_CharT> __l)
1048 {
return this->
append(__l.begin(), __l.size()); }
1059 #if __cplusplus >= 201103L
1060 template<
class _InputIterator,
1061 typename = std::_RequireInputIter<_InputIterator>>
1063 template<
class _InputIterator>
1066 append(_InputIterator __first, _InputIterator __last)
1076 const size_type __size = this->
size();
1078 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1079 traits_type::assign(this->_M_data()[__size], __c);
1080 this->_M_set_length(__size + 1);
1091 this->_M_assign(__str);
1095 #if __cplusplus >= 201103L
1128 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1129 + __str._M_check(__pos,
"basic_string::assign"),
1130 __str._M_limit(__pos, __n)); }
1143 assign(
const _CharT* __s, size_type __n)
1145 __glibcxx_requires_string_len(__s, __n);
1146 return _M_replace(size_type(0), this->
size(), __s, __n);
1159 assign(
const _CharT* __s)
1161 __glibcxx_requires_string(__s);
1162 return _M_replace(size_type(0), this->
size(), __s,
1163 traits_type::length(__s));
1176 assign(size_type __n, _CharT __c)
1177 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1187 #if __cplusplus >= 201103L
1188 template<
class _InputIterator,
1189 typename = std::_RequireInputIter<_InputIterator>>
1191 template<
class _InputIterator>
1194 assign(_InputIterator __first, _InputIterator __last)
1197 #if __cplusplus >= 201103L
1204 assign(initializer_list<_CharT> __l)
1205 {
return this->
assign(__l.begin(), __l.size()); }
1208 #if __cplusplus >= 201103L
1225 insert(const_iterator __p, size_type __n, _CharT __c)
1227 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1228 const size_type __pos = __p -
begin();
1229 this->
replace(__p, __p, __n, __c);
1230 return iterator(this->_M_data() + __pos);
1247 insert(iterator __p, size_type __n, _CharT __c)
1248 { this->
replace(__p, __p, __n, __c); }
1251 #if __cplusplus >= 201103L
1266 template<
class _InputIterator,
1267 typename = std::_RequireInputIter<_InputIterator>>
1269 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1271 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1272 const size_type __pos = __p -
begin();
1273 this->
replace(__p, __p, __beg, __end);
1274 return iterator(this->_M_data() + __pos);
1289 template<
class _InputIterator>
1291 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1292 { this->
replace(__p, __p, __beg, __end); }
1295 #if __cplusplus >= 201103L
1303 insert(iterator __p, initializer_list<_CharT> __l)
1305 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1306 this->
insert(__p -
begin(), __l.begin(), __l.size());
1324 {
return this->
replace(__pos1, size_type(0),
1325 __str._M_data(), __str.size()); }
1347 size_type __pos2, size_type __n)
1348 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1349 + __str._M_check(__pos2,
"basic_string::insert"),
1350 __str._M_limit(__pos2, __n)); }
1369 insert(size_type __pos,
const _CharT* __s, size_type __n)
1370 {
return this->
replace(__pos, size_type(0), __s, __n); }
1388 insert(size_type __pos,
const _CharT* __s)
1390 __glibcxx_requires_string(__s);
1391 return this->
replace(__pos, size_type(0), __s,
1392 traits_type::length(__s));
1412 insert(size_type __pos, size_type __n, _CharT __c)
1413 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1414 size_type(0), __n, __c); }
1430 insert(__const_iterator __p, _CharT __c)
1432 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1433 const size_type __pos = __p -
begin();
1434 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1435 return iterator(_M_data() + __pos);
1454 erase(size_type __pos = 0, size_type __n = npos)
1456 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1457 _M_limit(__pos, __n));
1470 erase(__const_iterator __position)
1472 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1473 && __position <
end());
1474 const size_type __pos = __position -
begin();
1475 this->_M_erase(__pos, size_type(1));
1476 return iterator(_M_data() + __pos);
1489 erase(__const_iterator __first, __const_iterator __last)
1491 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1492 && __last <=
end());
1493 const size_type __pos = __first -
begin();
1494 this->_M_erase(__pos, __last - __first);
1495 return iterator(this->_M_data() + __pos);
1498 #if __cplusplus >= 201103L
1506 { _M_erase(
size()-1, 1); }
1528 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1550 size_type __pos2, size_type __n2)
1551 {
return this->
replace(__pos1, __n1, __str._M_data()
1552 + __str._M_check(__pos2,
"basic_string::replace"),
1553 __str._M_limit(__pos2, __n2)); }
1574 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1577 __glibcxx_requires_string_len(__s, __n2);
1578 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1579 _M_limit(__pos, __n1), __s, __n2);
1599 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1601 __glibcxx_requires_string(__s);
1602 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1623 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1624 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1625 _M_limit(__pos, __n1), __n2, __c); }
1641 replace(__const_iterator __i1, __const_iterator __i2,
1643 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1661 replace(__const_iterator __i1, __const_iterator __i2,
1662 const _CharT* __s, size_type __n)
1664 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1666 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1683 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1685 __glibcxx_requires_string(__s);
1686 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1704 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1707 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1709 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1727 #if __cplusplus >= 201103L
1728 template<
class _InputIterator,
1729 typename = std::_RequireInputIter<_InputIterator>>
1731 replace(const_iterator __i1, const_iterator __i2,
1732 _InputIterator __k1, _InputIterator __k2)
1734 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1736 __glibcxx_requires_valid_range(__k1, __k2);
1737 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1738 std::__false_type());
1741 template<
class _InputIterator>
1742 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
1743 typename __enable_if_not_native_iterator<_InputIterator>::__type
1747 replace(iterator __i1, iterator __i2,
1748 _InputIterator __k1, _InputIterator __k2)
1750 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1752 __glibcxx_requires_valid_range(__k1, __k2);
1753 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1754 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1761 replace(__const_iterator __i1, __const_iterator __i2,
1762 _CharT* __k1, _CharT* __k2)
1764 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1766 __glibcxx_requires_valid_range(__k1, __k2);
1772 replace(__const_iterator __i1, __const_iterator __i2,
1773 const _CharT* __k1,
const _CharT* __k2)
1775 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1777 __glibcxx_requires_valid_range(__k1, __k2);
1783 replace(__const_iterator __i1, __const_iterator __i2,
1784 iterator __k1, iterator __k2)
1786 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1788 __glibcxx_requires_valid_range(__k1, __k2);
1790 __k1.base(), __k2 - __k1);
1794 replace(__const_iterator __i1, __const_iterator __i2,
1795 const_iterator __k1, const_iterator __k2)
1797 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1799 __glibcxx_requires_valid_range(__k1, __k2);
1801 __k1.base(), __k2 - __k1);
1804 #if __cplusplus >= 201103L
1820 initializer_list<_CharT> __l)
1821 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1825 template<
class _Integer>
1827 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1828 _Integer __n, _Integer __val, __true_type)
1829 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1831 template<
class _InputIterator>
1833 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1834 _InputIterator __k1, _InputIterator __k2,
1838 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1842 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1843 const size_type __len2);
1846 _M_append(
const _CharT* __s, size_type __n);
1863 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1883 c_str() const _GLIBCXX_NOEXCEPT
1884 {
return _M_data(); }
1893 data() const _GLIBCXX_NOEXCEPT
1894 {
return _M_data(); }
1901 {
return _M_get_allocator(); }
1916 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
1931 {
return this->
find(__str.data(), __pos, __str.size()); }
1944 find(
const _CharT* __s, size_type __pos = 0)
const
1946 __glibcxx_requires_string(__s);
1947 return this->
find(__s, __pos, traits_type::length(__s));
1961 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
1976 {
return this->
rfind(__str.data(), __pos, __str.size()); }
1991 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2004 rfind(
const _CharT* __s, size_type __pos = npos)
const
2006 __glibcxx_requires_string(__s);
2007 return this->
rfind(__s, __pos, traits_type::length(__s));
2021 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2037 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2052 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2067 __glibcxx_requires_string(__s);
2068 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2084 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2085 {
return this->
find(__c, __pos); }
2101 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2116 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2129 find_last_of(
const _CharT* __s, size_type __pos = npos)
const
2131 __glibcxx_requires_string(__s);
2132 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2148 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2149 {
return this->
rfind(__c, __pos); }
2180 size_type __n)
const;
2195 __glibcxx_requires_string(__s);
2243 size_type __n)
const;
2258 __glibcxx_requires_string(__s);
2289 substr(size_type __pos = 0, size_type __n = npos)
const
2291 _M_check(__pos,
"basic_string::substr"), __n); }
2310 const size_type __size = this->
size();
2311 const size_type __osize = __str.size();
2312 const size_type __len =
std::min(__size, __osize);
2314 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2316 __r = _S_compare(__size, __osize);
2367 size_type __pos2, size_type __n2)
const;
2384 compare(
const _CharT* __s)
const;
2408 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2435 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2436 size_type __n2)
const;
2438 _GLIBCXX_END_NAMESPACE_CXX11
2439 #else // !_GLIBCXX_USE_CXX11_ABI
2504 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2507 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2511 typedef _Traits traits_type;
2512 typedef typename _Traits::char_type value_type;
2513 typedef _Alloc allocator_type;
2514 typedef typename _CharT_alloc_type::size_type size_type;
2515 typedef typename _CharT_alloc_type::difference_type difference_type;
2516 typedef typename _CharT_alloc_type::reference reference;
2517 typedef typename _CharT_alloc_type::const_reference const_reference;
2518 typedef typename _CharT_alloc_type::pointer pointer;
2519 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2520 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2521 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2543 size_type _M_length;
2544 size_type _M_capacity;
2545 _Atomic_word _M_refcount;
2548 struct _Rep : _Rep_base
2551 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2566 static const size_type _S_max_size;
2567 static const _CharT _S_terminal;
2571 static size_type _S_empty_rep_storage[];
2574 _S_empty_rep() _GLIBCXX_NOEXCEPT
2579 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2580 return *
reinterpret_cast<_Rep*
>(__p);
2584 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2585 {
return this->_M_refcount < 0; }
2588 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2589 {
return this->_M_refcount > 0; }
2592 _M_set_leaked() _GLIBCXX_NOEXCEPT
2593 { this->_M_refcount = -1; }
2596 _M_set_sharable() _GLIBCXX_NOEXCEPT
2597 { this->_M_refcount = 0; }
2600 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2602 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2603 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2606 this->_M_set_sharable();
2607 this->_M_length = __n;
2608 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2615 _M_refdata()
throw()
2616 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2619 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2621 return (!_M_is_leaked() && __alloc1 == __alloc2)
2622 ? _M_refcopy() : _M_clone(__alloc1);
2627 _S_create(size_type, size_type,
const _Alloc&);
2630 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2632 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2633 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2637 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2638 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2641 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2648 _M_destroy(
const _Alloc&)
throw();
2651 _M_refcopy()
throw()
2653 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2654 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2656 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2657 return _M_refdata();
2661 _M_clone(
const _Alloc&, size_type __res = 0);
2665 struct _Alloc_hider : _Alloc
2667 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2668 : _Alloc(__a), _M_p(__dat) { }
2678 static const size_type npos =
static_cast<size_type
>(-1);
2682 mutable _Alloc_hider _M_dataplus;
2685 _M_data() const _GLIBCXX_NOEXCEPT
2686 {
return _M_dataplus._M_p; }
2689 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2690 {
return (_M_dataplus._M_p = __p); }
2693 _M_rep() const _GLIBCXX_NOEXCEPT
2694 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2699 _M_ibegin() const _GLIBCXX_NOEXCEPT
2700 {
return iterator(_M_data()); }
2703 _M_iend() const _GLIBCXX_NOEXCEPT
2704 {
return iterator(_M_data() + this->
size()); }
2709 if (!_M_rep()->_M_is_leaked())
2714 _M_check(size_type __pos,
const char* __s)
const
2716 if (__pos > this->
size())
2717 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
2718 "this->size() (which is %zu)"),
2719 __s, __pos, this->
size());
2724 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
2727 __throw_length_error(__N(__s));
2732 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2734 const bool __testoff = __off < this->
size() - __pos;
2735 return __testoff ? __off : this->
size() - __pos;
2740 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2742 return (less<const _CharT*>()(__s, _M_data())
2743 || less<const _CharT*>()(_M_data() + this->
size(), __s));
2749 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2752 traits_type::assign(*__d, *__s);
2754 traits_type::copy(__d, __s, __n);
2758 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2761 traits_type::assign(*__d, *__s);
2767 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2770 traits_type::assign(*__d, __c);
2772 traits_type::assign(__d, __n, __c);
2777 template<
class _Iterator>
2779 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2782 for (; __k1 != __k2; ++__k1, ++__p)
2783 traits_type::assign(*__p, *__k1);
2787 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2788 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2791 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2793 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2796 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2797 { _M_copy(__p, __k1, __k2 - __k1); }
2800 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2802 { _M_copy(__p, __k1, __k2 - __k1); }
2805 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2807 const difference_type __d = difference_type(__n1 - __n2);
2809 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2810 return __gnu_cxx::__numeric_traits<int>::__max;
2811 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2812 return __gnu_cxx::__numeric_traits<int>::__min;
2818 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2824 _S_empty_rep() _GLIBCXX_NOEXCEPT
2825 {
return _Rep::_S_empty_rep(); }
2836 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2837 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2839 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2861 size_type __n = npos);
2870 size_type __n,
const _Alloc& __a);
2882 const _Alloc& __a = _Alloc());
2888 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2895 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2897 #if __cplusplus >= 201103L
2906 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2909 : _M_dataplus(__str._M_dataplus)
2911 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2912 __str._M_data(_S_empty_rep()._M_refdata());
2914 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
2923 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc());
2932 template<
class _InputIterator>
2933 basic_string(_InputIterator __beg, _InputIterator __end,
2934 const _Alloc& __a = _Alloc());
2948 {
return this->
assign(__str); }
2956 {
return this->
assign(__s); }
2972 #if __cplusplus >= 201103L
2996 this->
assign(__l.begin(), __l.size());
3010 return iterator(_M_data());
3019 {
return const_iterator(_M_data()); }
3029 return iterator(_M_data() + this->
size());
3038 {
return const_iterator(_M_data() + this->
size()); }
3047 {
return reverse_iterator(this->
end()); }
3054 const_reverse_iterator
3056 {
return const_reverse_iterator(this->
end()); }
3065 {
return reverse_iterator(this->
begin()); }
3072 const_reverse_iterator
3074 {
return const_reverse_iterator(this->
begin()); }
3076 #if __cplusplus >= 201103L
3083 {
return const_iterator(this->_M_data()); }
3091 {
return const_iterator(this->_M_data() + this->
size()); }
3098 const_reverse_iterator
3100 {
return const_reverse_iterator(this->
end()); }
3107 const_reverse_iterator
3109 {
return const_reverse_iterator(this->
begin()); }
3118 {
return _M_rep()->_M_length; }
3124 {
return _M_rep()->_M_length; }
3129 {
return _Rep::_S_max_size; }
3142 resize(size_type __n, _CharT __c);
3156 { this->
resize(__n, _CharT()); }
3158 #if __cplusplus >= 201103L
3179 {
return _M_rep()->_M_capacity; }
3199 reserve(size_type __res_arg = 0);
3207 { _M_mutate(0, this->
size(), 0); }
3215 {
return this->
size() == 0; }
3231 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3232 return _M_data()[__pos];
3250 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3252 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3254 return _M_data()[__pos];
3270 if (__n >= this->
size())
3271 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3272 "(which is %zu) >= this->size() "
3275 return _M_data()[__n];
3293 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3294 "(which is %zu) >= this->size() "
3298 return _M_data()[__n];
3301 #if __cplusplus >= 201103L
3343 {
return this->
append(__str); }
3352 {
return this->
append(__s); }
3366 #if __cplusplus >= 201103L
3374 {
return this->
append(__l.begin(), __l.size()); }
3408 append(
const _CharT* __s, size_type __n);
3418 __glibcxx_requires_string(__s);
3419 return this->
append(__s, traits_type::length(__s));
3431 append(size_type __n, _CharT __c);
3433 #if __cplusplus >= 201103L
3441 {
return this->
append(__l.begin(), __l.size()); }
3452 template<
class _InputIterator>
3454 append(_InputIterator __first, _InputIterator __last)
3455 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3464 const size_type __len = 1 + this->
size();
3465 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3467 traits_type::assign(_M_data()[this->
size()], __c);
3468 _M_rep()->_M_set_length_and_sharable(__len);
3479 #if __cplusplus >= 201103L
3512 {
return this->
assign(__str._M_data()
3513 + __str._M_check(__pos,
"basic_string::assign"),
3514 __str._M_limit(__pos, __n)); }
3527 assign(
const _CharT* __s, size_type __n);
3541 __glibcxx_requires_string(__s);
3542 return this->
assign(__s, traits_type::length(__s));
3556 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3566 template<
class _InputIterator>
3568 assign(_InputIterator __first, _InputIterator __last)
3569 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3571 #if __cplusplus >= 201103L
3579 {
return this->
assign(__l.begin(), __l.size()); }
3596 insert(iterator __p, size_type __n, _CharT __c)
3597 { this->
replace(__p, __p, __n, __c); }
3611 template<
class _InputIterator>
3613 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3614 { this->
replace(__p, __p, __beg, __end); }
3616 #if __cplusplus >= 201103L
3624 insert(iterator __p, initializer_list<_CharT> __l)
3626 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3627 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3645 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3667 size_type __pos2, size_type __n)
3668 {
return this->
insert(__pos1, __str._M_data()
3669 + __str._M_check(__pos2,
"basic_string::insert"),
3670 __str._M_limit(__pos2, __n)); }
3689 insert(size_type __pos,
const _CharT* __s, size_type __n);
3709 __glibcxx_requires_string(__s);
3710 return this->
insert(__pos, __s, traits_type::length(__s));
3730 insert(size_type __pos, size_type __n, _CharT __c)
3731 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3732 size_type(0), __n, __c); }
3750 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3751 const size_type __pos = __p - _M_ibegin();
3752 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3753 _M_rep()->_M_set_leaked();
3754 return iterator(_M_data() + __pos);
3773 erase(size_type __pos = 0, size_type __n = npos)
3775 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3776 _M_limit(__pos, __n), size_type(0));
3791 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3792 && __position < _M_iend());
3793 const size_type __pos = __position - _M_ibegin();
3794 _M_mutate(__pos, size_type(1), size_type(0));
3795 _M_rep()->_M_set_leaked();
3796 return iterator(_M_data() + __pos);
3809 erase(iterator __first, iterator __last);
3811 #if __cplusplus >= 201103L
3841 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3863 size_type __pos2, size_type __n2)
3864 {
return this->
replace(__pos1, __n1, __str._M_data()
3865 + __str._M_check(__pos2,
"basic_string::replace"),
3866 __str._M_limit(__pos2, __n2)); }
3887 replace(size_type __pos, size_type __n1,
const _CharT* __s,
3907 replace(size_type __pos, size_type __n1,
const _CharT* __s)
3909 __glibcxx_requires_string(__s);
3910 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
3931 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
3932 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
3933 _M_limit(__pos, __n1), __n2, __c); }
3950 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
3968 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
3970 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
3971 && __i2 <= _M_iend());
3972 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
3989 replace(iterator __i1, iterator __i2,
const _CharT* __s)
3991 __glibcxx_requires_string(__s);
3992 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4010 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4012 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4013 && __i2 <= _M_iend());
4014 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4032 template<
class _InputIterator>
4035 _InputIterator __k1, _InputIterator __k2)
4037 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4038 && __i2 <= _M_iend());
4039 __glibcxx_requires_valid_range(__k1, __k2);
4040 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4041 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4047 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4049 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4050 && __i2 <= _M_iend());
4051 __glibcxx_requires_valid_range(__k1, __k2);
4052 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4057 replace(iterator __i1, iterator __i2,
4058 const _CharT* __k1,
const _CharT* __k2)
4060 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4061 && __i2 <= _M_iend());
4062 __glibcxx_requires_valid_range(__k1, __k2);
4063 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4068 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4070 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4071 && __i2 <= _M_iend());
4072 __glibcxx_requires_valid_range(__k1, __k2);
4073 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4074 __k1.base(), __k2 - __k1);
4078 replace(iterator __i1, iterator __i2,
4079 const_iterator __k1, const_iterator __k2)
4081 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4082 && __i2 <= _M_iend());
4083 __glibcxx_requires_valid_range(__k1, __k2);
4084 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4085 __k1.base(), __k2 - __k1);
4088 #if __cplusplus >= 201103L
4104 initializer_list<_CharT> __l)
4105 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4109 template<
class _Integer>
4111 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4112 _Integer __val, __true_type)
4113 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4115 template<
class _InputIterator>
4117 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4118 _InputIterator __k2, __false_type);
4121 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4125 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4130 template<
class _InIterator>
4132 _S_construct_aux(_InIterator __beg, _InIterator __end,
4133 const _Alloc& __a, __false_type)
4135 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4136 return _S_construct(__beg, __end, __a, _Tag());
4141 template<
class _Integer>
4143 _S_construct_aux(_Integer __beg, _Integer __end,
4144 const _Alloc& __a, __true_type)
4145 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4149 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4150 {
return _S_construct(__req, __c, __a); }
4152 template<
class _InIterator>
4154 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4156 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4157 return _S_construct_aux(__beg, __end, __a, _Integral());
4161 template<
class _InIterator>
4163 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4164 input_iterator_tag);
4168 template<
class _FwdIterator>
4170 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4171 forward_iterator_tag);
4174 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4191 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4213 {
return _M_data(); }
4223 {
return _M_data(); }
4230 {
return _M_dataplus; }
4245 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4260 {
return this->
find(__str.data(), __pos, __str.size()); }
4273 find(
const _CharT* __s, size_type __pos = 0)
const
4275 __glibcxx_requires_string(__s);
4276 return this->
find(__s, __pos, traits_type::length(__s));
4290 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
4305 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4320 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4333 rfind(
const _CharT* __s, size_type __pos = npos)
const
4335 __glibcxx_requires_string(__s);
4336 return this->
rfind(__s, __pos, traits_type::length(__s));
4350 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
4366 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4381 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4396 __glibcxx_requires_string(__s);
4397 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4414 {
return this->
find(__c, __pos); }
4430 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4445 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4460 __glibcxx_requires_string(__s);
4461 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4478 {
return this->
rfind(__c, __pos); }
4509 size_type __n)
const;
4524 __glibcxx_requires_string(__s);
4572 size_type __n)
const;
4587 __glibcxx_requires_string(__s);
4618 substr(size_type __pos = 0, size_type __n = npos)
const
4620 _M_check(__pos,
"basic_string::substr"), __n); }
4639 const size_type __size = this->
size();
4640 const size_type __osize = __str.size();
4641 const size_type __len =
std::min(__size, __osize);
4643 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4645 __r = _S_compare(__size, __osize);
4696 size_type __pos2, size_type __n2)
const;
4713 compare(
const _CharT* __s)
const;
4737 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4764 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4765 size_type __n2)
const;
4767 #endif // !_GLIBCXX_USE_CXX11_ABI
4776 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4777 basic_string<_CharT, _Traits, _Alloc>
4782 __str.append(__rhs);
4792 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4793 basic_string<_CharT,_Traits,_Alloc>
4795 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4803 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4804 basic_string<_CharT,_Traits,_Alloc>
4805 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4813 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4814 inline basic_string<_CharT, _Traits, _Alloc>
4816 const _CharT* __rhs)
4819 __str.append(__rhs);
4829 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4830 inline basic_string<_CharT, _Traits, _Alloc>
4834 typedef typename __string_type::size_type __size_type;
4835 __string_type __str(__lhs);
4836 __str.append(__size_type(1), __rhs);
4840 #if __cplusplus >= 201103L
4841 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4842 inline basic_string<_CharT, _Traits, _Alloc>
4843 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4844 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4845 {
return std::move(__lhs.append(__rhs)); }
4847 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4848 inline basic_string<_CharT, _Traits, _Alloc>
4849 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4850 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4851 {
return std::move(__rhs.insert(0, __lhs)); }
4853 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4854 inline basic_string<_CharT, _Traits, _Alloc>
4855 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4856 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4858 const auto __size = __lhs.size() + __rhs.size();
4859 const bool __cond = (__size > __lhs.capacity()
4860 && __size <= __rhs.capacity());
4861 return __cond ?
std::move(__rhs.insert(0, __lhs))
4865 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4866 inline basic_string<_CharT, _Traits, _Alloc>
4868 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4869 {
return std::move(__rhs.insert(0, __lhs)); }
4871 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4872 inline basic_string<_CharT, _Traits, _Alloc>
4874 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4875 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4877 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4878 inline basic_string<_CharT, _Traits, _Alloc>
4879 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4880 const _CharT* __rhs)
4881 {
return std::move(__lhs.append(__rhs)); }
4883 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4884 inline basic_string<_CharT, _Traits, _Alloc>
4885 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4887 {
return std::move(__lhs.append(1, __rhs)); }
4897 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4901 {
return __lhs.compare(__rhs) == 0; }
4903 template<
typename _CharT>
4905 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
4906 operator==(
const basic_string<_CharT>& __lhs,
4907 const basic_string<_CharT>& __rhs)
4908 {
return (__lhs.size() == __rhs.size()
4918 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4920 operator==(
const _CharT* __lhs,
4922 {
return __rhs.compare(__lhs) == 0; }
4930 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4933 const _CharT* __rhs)
4934 {
return __lhs.compare(__rhs) == 0; }
4943 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4947 {
return !(__lhs == __rhs); }
4955 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4957 operator!=(
const _CharT* __lhs,
4959 {
return !(__lhs == __rhs); }
4967 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4970 const _CharT* __rhs)
4971 {
return !(__lhs == __rhs); }
4980 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4982 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4984 {
return __lhs.compare(__rhs) < 0; }
4992 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4994 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4995 const _CharT* __rhs)
4996 {
return __lhs.compare(__rhs) < 0; }
5004 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5008 {
return __rhs.compare(__lhs) > 0; }
5017 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5021 {
return __lhs.compare(__rhs) > 0; }
5029 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5032 const _CharT* __rhs)
5033 {
return __lhs.compare(__rhs) > 0; }
5041 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5045 {
return __rhs.compare(__lhs) < 0; }
5054 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5056 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5058 {
return __lhs.compare(__rhs) <= 0; }
5066 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5068 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5069 const _CharT* __rhs)
5070 {
return __lhs.compare(__rhs) <= 0; }
5078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5082 {
return __rhs.compare(__lhs) >= 0; }
5091 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5095 {
return __lhs.compare(__rhs) >= 0; }
5103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5106 const _CharT* __rhs)
5107 {
return __lhs.compare(__rhs) >= 0; }
5115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5119 {
return __rhs.compare(__lhs) <= 0; }
5128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5132 { __lhs.swap(__rhs); }
5147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5148 basic_istream<_CharT, _Traits>&
5149 operator>>(basic_istream<_CharT, _Traits>& __is,
5150 basic_string<_CharT, _Traits, _Alloc>& __str);
5153 basic_istream<char>&
5154 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
5165 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5166 inline basic_ostream<_CharT, _Traits>&
5167 operator<<(basic_ostream<_CharT, _Traits>& __os,
5172 return __ostream_insert(__os, __str.data(), __str.size());
5188 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5189 basic_istream<_CharT, _Traits>&
5190 getline(basic_istream<_CharT, _Traits>& __is,
5191 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
5205 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5206 inline basic_istream<_CharT, _Traits>&
5209 {
return std::getline(__is, __str, __is.widen(
'\n')); }
5211 #if __cplusplus >= 201103L
5213 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5214 inline basic_istream<_CharT, _Traits>&
5220 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5221 inline basic_istream<_CharT, _Traits>&
5228 basic_istream<char>&
5229 getline(basic_istream<char>& __in, basic_string<char>& __str,
5232 #ifdef _GLIBCXX_USE_WCHAR_T
5234 basic_istream<wchar_t>&
5235 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
5239 _GLIBCXX_END_NAMESPACE_VERSION
5242 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
5246 namespace std _GLIBCXX_VISIBILITY(default)
5248 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5249 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5253 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5254 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
5258 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5259 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
5262 inline unsigned long
5263 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5264 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
5268 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5269 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
5272 inline unsigned long long
5273 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5274 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
5279 stof(
const string& __str,
size_t* __idx = 0)
5280 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
5283 stod(
const string& __str,
size_t* __idx = 0)
5284 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
5287 stold(
const string& __str,
size_t* __idx = 0)
5288 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
5294 to_string(
int __val)
5295 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5299 to_string(
unsigned __val)
5300 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5301 4 *
sizeof(unsigned),
5305 to_string(
long __val)
5306 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5310 to_string(
unsigned long __val)
5311 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5312 4 *
sizeof(
unsigned long),
5316 to_string(
long long __val)
5317 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5318 4 *
sizeof(
long long),
5322 to_string(
unsigned long long __val)
5323 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5324 4 *
sizeof(
unsigned long long),
5328 to_string(
float __val)
5331 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5332 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5337 to_string(
double __val)
5340 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5341 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5346 to_string(
long double __val)
5349 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5350 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5354 #ifdef _GLIBCXX_USE_WCHAR_T
5356 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5357 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
5361 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5362 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
5365 inline unsigned long
5366 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5367 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
5371 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5372 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
5375 inline unsigned long long
5376 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5377 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
5382 stof(
const wstring& __str,
size_t* __idx = 0)
5383 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
5386 stod(
const wstring& __str,
size_t* __idx = 0)
5387 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
5390 stold(
const wstring& __str,
size_t* __idx = 0)
5391 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
5393 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5396 to_wstring(
int __val)
5397 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5401 to_wstring(
unsigned __val)
5402 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5403 4 *
sizeof(unsigned),
5407 to_wstring(
long __val)
5408 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5412 to_wstring(
unsigned long __val)
5413 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5414 4 *
sizeof(
unsigned long),
5418 to_wstring(
long long __val)
5419 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5420 4 *
sizeof(
long long),
5424 to_wstring(
unsigned long long __val)
5425 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5426 4 *
sizeof(
unsigned long long),
5430 to_wstring(
float __val)
5433 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5434 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5439 to_wstring(
double __val)
5442 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5443 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5448 to_wstring(
long double __val)
5451 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5452 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5455 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5458 _GLIBCXX_END_NAMESPACE_CXX11
5459 _GLIBCXX_END_NAMESPACE_VERSION
5464 #if __cplusplus >= 201103L
5468 namespace std _GLIBCXX_VISIBILITY(default)
5470 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5474 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5478 :
public __hash_base<size_t, string>
5481 operator()(
const string& __s)
const noexcept
5482 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5486 struct __is_fast_hash<
hash<
string>> : std::false_type
5489 #ifdef _GLIBCXX_USE_WCHAR_T
5493 :
public __hash_base<size_t, wstring>
5496 operator()(
const wstring& __s)
const noexcept
5497 {
return std::_Hash_impl::hash(__s.
data(),
5498 __s.
length() *
sizeof(wchar_t)); }
5502 struct __is_fast_hash<
hash<
wstring>> : std::false_type
5507 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5511 :
public __hash_base<size_t, u16string>
5514 operator()(
const u16string& __s)
const noexcept
5515 {
return std::_Hash_impl::hash(__s.
data(),
5516 __s.
length() *
sizeof(char16_t)); }
5526 :
public __hash_base<size_t, u32string>
5529 operator()(
const u32string& __s)
const noexcept
5530 {
return std::_Hash_impl::hash(__s.
data(),
5531 __s.
length() *
sizeof(char32_t)); }
5539 #if __cplusplus > 201103L
5541 #define __cpp_lib_string_udls 201304
5543 inline namespace literals
5545 inline namespace string_literals
5548 _GLIBCXX_DEFAULT_ABI_TAG
5549 inline basic_string<char>
5550 operator""s(
const char* __str,
size_t __len)
5551 {
return basic_string<char>{__str, __len}; }
5553 #ifdef _GLIBCXX_USE_WCHAR_T
5554 _GLIBCXX_DEFAULT_ABI_TAG
5555 inline basic_string<wchar_t>
5556 operator""s(
const wchar_t* __str,
size_t __len)
5557 {
return basic_string<wchar_t>{__str, __len}; }
5560 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5561 _GLIBCXX_DEFAULT_ABI_TAG
5562 inline basic_string<char16_t>
5563 operator""s(
const char16_t* __str,
size_t __len)
5564 {
return basic_string<char16_t>{__str, __len}; }
5566 _GLIBCXX_DEFAULT_ABI_TAG
5567 inline basic_string<char32_t>
5568 operator""s(
const char32_t* __str,
size_t __len)
5569 {
return basic_string<char32_t>{__str, __len}; }
5575 #endif // __cplusplus > 201103L
5577 _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.