34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
42 #if __cplusplus >= 201103L
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);
308 traits_type::move(__d, __s, __n);
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)
516 *
this = std::move(__str);
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
781 return _M_is_local() ? size_type(_S_local_capacity)
782 : _M_allocated_capacity;
803 reserve(size_type __res_arg = 0);
809 clear() _GLIBCXX_NOEXCEPT
810 { _M_set_length(0); }
817 empty() const _GLIBCXX_NOEXCEPT
818 {
return this->
size() == 0; }
832 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
834 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
835 return _M_data()[__pos];
853 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
855 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
856 return _M_data()[__pos];
870 at(size_type __n)
const
872 if (__n >= this->
size())
873 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
874 "(which is %zu) >= this->size() "
877 return _M_data()[__n];
894 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
895 "(which is %zu) >= this->size() "
898 return _M_data()[__n];
901 #if __cplusplus >= 201103L
915 front() const noexcept
931 back() const noexcept
943 {
return this->
append(__str); }
952 {
return this->
append(__s); }
966 #if __cplusplus >= 201103L
974 {
return this->
append(__l.begin(), __l.size()); }
984 {
return _M_append(__str._M_data(), __str.size()); }
1001 {
return _M_append(__str._M_data()
1002 + __str._M_check(__pos,
"basic_string::append"),
1003 __str._M_limit(__pos, __n)); }
1012 append(
const _CharT* __s, size_type __n)
1014 __glibcxx_requires_string_len(__s, __n);
1015 _M_check_length(size_type(0), __n,
"basic_string::append");
1016 return _M_append(__s, __n);
1025 append(
const _CharT* __s)
1027 __glibcxx_requires_string(__s);
1028 const size_type __n = traits_type::length(__s);
1029 _M_check_length(size_type(0), __n,
"basic_string::append");
1030 return _M_append(__s, __n);
1042 append(size_type __n, _CharT __c)
1043 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1045 #if __cplusplus >= 201103L
1052 append(initializer_list<_CharT> __l)
1053 {
return this->
append(__l.begin(), __l.size()); }
1064 #if __cplusplus >= 201103L
1065 template<
class _InputIterator,
1066 typename = std::_RequireInputIter<_InputIterator>>
1068 template<
class _InputIterator>
1071 append(_InputIterator __first, _InputIterator __last)
1081 const size_type __size = this->
size();
1083 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1084 traits_type::assign(this->_M_data()[__size], __c);
1085 this->_M_set_length(__size + 1);
1096 this->_M_assign(__str);
1100 #if __cplusplus >= 201103L
1114 return *
this = std::move(__str);
1133 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1134 + __str._M_check(__pos,
"basic_string::assign"),
1135 __str._M_limit(__pos, __n)); }
1148 assign(
const _CharT* __s, size_type __n)
1150 __glibcxx_requires_string_len(__s, __n);
1151 return _M_replace(size_type(0), this->
size(), __s, __n);
1164 assign(
const _CharT* __s)
1166 __glibcxx_requires_string(__s);
1167 return _M_replace(size_type(0), this->
size(), __s,
1168 traits_type::length(__s));
1181 assign(size_type __n, _CharT __c)
1182 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1192 #if __cplusplus >= 201103L
1193 template<
class _InputIterator,
1194 typename = std::_RequireInputIter<_InputIterator>>
1196 template<
class _InputIterator>
1199 assign(_InputIterator __first, _InputIterator __last)
1202 #if __cplusplus >= 201103L
1209 assign(initializer_list<_CharT> __l)
1210 {
return this->
assign(__l.begin(), __l.size()); }
1213 #if __cplusplus >= 201103L
1230 insert(const_iterator __p, size_type __n, _CharT __c)
1232 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1233 const size_type __pos = __p -
begin();
1234 this->
replace(__p, __p, __n, __c);
1235 return iterator(this->_M_data() + __pos);
1252 insert(iterator __p, size_type __n, _CharT __c)
1253 { this->
replace(__p, __p, __n, __c); }
1256 #if __cplusplus >= 201103L
1271 template<
class _InputIterator,
1272 typename = std::_RequireInputIter<_InputIterator>>
1274 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1276 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1277 const size_type __pos = __p -
begin();
1278 this->
replace(__p, __p, __beg, __end);
1279 return iterator(this->_M_data() + __pos);
1294 template<
class _InputIterator>
1296 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1297 { this->
replace(__p, __p, __beg, __end); }
1300 #if __cplusplus >= 201103L
1308 insert(iterator __p, initializer_list<_CharT> __l)
1310 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1311 this->
insert(__p -
begin(), __l.begin(), __l.size());
1329 {
return this->
replace(__pos1, size_type(0),
1330 __str._M_data(), __str.size()); }
1352 size_type __pos2, size_type __n)
1353 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1354 + __str._M_check(__pos2,
"basic_string::insert"),
1355 __str._M_limit(__pos2, __n)); }
1374 insert(size_type __pos,
const _CharT* __s, size_type __n)
1375 {
return this->
replace(__pos, size_type(0), __s, __n); }
1393 insert(size_type __pos,
const _CharT* __s)
1395 __glibcxx_requires_string(__s);
1396 return this->
replace(__pos, size_type(0), __s,
1397 traits_type::length(__s));
1417 insert(size_type __pos, size_type __n, _CharT __c)
1418 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1419 size_type(0), __n, __c); }
1435 insert(__const_iterator __p, _CharT __c)
1437 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1438 const size_type __pos = __p -
begin();
1439 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1440 return iterator(_M_data() + __pos);
1459 erase(size_type __pos = 0, size_type __n = npos)
1461 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1462 _M_limit(__pos, __n));
1475 erase(__const_iterator __position)
1477 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1478 && __position <
end());
1479 const size_type __pos = __position -
begin();
1480 this->_M_erase(__pos, size_type(1));
1481 return iterator(_M_data() + __pos);
1494 erase(__const_iterator __first, __const_iterator __last)
1496 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1497 && __last <=
end());
1498 const size_type __pos = __first -
begin();
1499 this->_M_erase(__pos, __last - __first);
1500 return iterator(this->_M_data() + __pos);
1503 #if __cplusplus >= 201103L
1511 { _M_erase(
size()-1, 1); }
1533 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1555 size_type __pos2, size_type __n2)
1556 {
return this->
replace(__pos1, __n1, __str._M_data()
1557 + __str._M_check(__pos2,
"basic_string::replace"),
1558 __str._M_limit(__pos2, __n2)); }
1579 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1582 __glibcxx_requires_string_len(__s, __n2);
1583 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1584 _M_limit(__pos, __n1), __s, __n2);
1604 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1606 __glibcxx_requires_string(__s);
1607 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1628 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1629 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1630 _M_limit(__pos, __n1), __n2, __c); }
1646 replace(__const_iterator __i1, __const_iterator __i2,
1648 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1666 replace(__const_iterator __i1, __const_iterator __i2,
1667 const _CharT* __s, size_type __n)
1669 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1671 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1688 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1690 __glibcxx_requires_string(__s);
1691 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1709 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1712 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1714 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1732 #if __cplusplus >= 201103L
1733 template<
class _InputIterator,
1734 typename = std::_RequireInputIter<_InputIterator>>
1736 replace(const_iterator __i1, const_iterator __i2,
1737 _InputIterator __k1, _InputIterator __k2)
1739 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1741 __glibcxx_requires_valid_range(__k1, __k2);
1742 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1743 std::__false_type());
1746 template<
class _InputIterator>
1747 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
1748 typename __enable_if_not_native_iterator<_InputIterator>::__type
1752 replace(iterator __i1, iterator __i2,
1753 _InputIterator __k1, _InputIterator __k2)
1755 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1757 __glibcxx_requires_valid_range(__k1, __k2);
1758 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1759 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1766 replace(__const_iterator __i1, __const_iterator __i2,
1767 _CharT* __k1, _CharT* __k2)
1769 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1771 __glibcxx_requires_valid_range(__k1, __k2);
1777 replace(__const_iterator __i1, __const_iterator __i2,
1778 const _CharT* __k1,
const _CharT* __k2)
1780 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1782 __glibcxx_requires_valid_range(__k1, __k2);
1788 replace(__const_iterator __i1, __const_iterator __i2,
1789 iterator __k1, iterator __k2)
1791 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1793 __glibcxx_requires_valid_range(__k1, __k2);
1795 __k1.base(), __k2 - __k1);
1799 replace(__const_iterator __i1, __const_iterator __i2,
1800 const_iterator __k1, const_iterator __k2)
1802 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1804 __glibcxx_requires_valid_range(__k1, __k2);
1806 __k1.base(), __k2 - __k1);
1809 #if __cplusplus >= 201103L
1825 initializer_list<_CharT> __l)
1826 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1830 template<
class _Integer>
1832 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1833 _Integer __n, _Integer __val, __true_type)
1834 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1836 template<
class _InputIterator>
1838 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1839 _InputIterator __k1, _InputIterator __k2,
1843 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1847 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1848 const size_type __len2);
1851 _M_append(
const _CharT* __s, size_type __n);
1868 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1888 c_str() const _GLIBCXX_NOEXCEPT
1889 {
return _M_data(); }
1898 data() const _GLIBCXX_NOEXCEPT
1899 {
return _M_data(); }
1906 {
return _M_get_allocator(); }
1921 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
1936 {
return this->
find(__str.data(), __pos, __str.size()); }
1949 find(
const _CharT* __s, size_type __pos = 0)
const
1951 __glibcxx_requires_string(__s);
1952 return this->
find(__s, __pos, traits_type::length(__s));
1966 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
1981 {
return this->
rfind(__str.data(), __pos, __str.size()); }
1996 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2009 rfind(
const _CharT* __s, size_type __pos = npos)
const
2011 __glibcxx_requires_string(__s);
2012 return this->
rfind(__s, __pos, traits_type::length(__s));
2026 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2042 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2057 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2072 __glibcxx_requires_string(__s);
2073 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2089 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2090 {
return this->
find(__c, __pos); }
2106 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2121 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2134 find_last_of(
const _CharT* __s, size_type __pos = npos)
const
2136 __glibcxx_requires_string(__s);
2137 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2153 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2154 {
return this->
rfind(__c, __pos); }
2185 size_type __n)
const;
2200 __glibcxx_requires_string(__s);
2248 size_type __n)
const;
2263 __glibcxx_requires_string(__s);
2294 substr(size_type __pos = 0, size_type __n = npos)
const
2296 _M_check(__pos,
"basic_string::substr"), __n); }
2315 const size_type __size = this->
size();
2316 const size_type __osize = __str.size();
2317 const size_type __len =
std::min(__size, __osize);
2319 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2321 __r = _S_compare(__size, __osize);
2372 size_type __pos2, size_type __n2)
const;
2389 compare(
const _CharT* __s)
const;
2413 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2440 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2441 size_type __n2)
const;
2443 _GLIBCXX_END_NAMESPACE_CXX11
2444 #else // !_GLIBCXX_USE_CXX11_ABI
2509 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2512 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2516 typedef _Traits traits_type;
2517 typedef typename _Traits::char_type value_type;
2518 typedef _Alloc allocator_type;
2519 typedef typename _CharT_alloc_type::size_type size_type;
2520 typedef typename _CharT_alloc_type::difference_type difference_type;
2521 typedef typename _CharT_alloc_type::reference reference;
2522 typedef typename _CharT_alloc_type::const_reference const_reference;
2523 typedef typename _CharT_alloc_type::pointer pointer;
2524 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2525 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2526 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2548 size_type _M_length;
2549 size_type _M_capacity;
2550 _Atomic_word _M_refcount;
2553 struct _Rep : _Rep_base
2556 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2571 static const size_type _S_max_size;
2572 static const _CharT _S_terminal;
2576 static size_type _S_empty_rep_storage[];
2579 _S_empty_rep() _GLIBCXX_NOEXCEPT
2584 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2585 return *
reinterpret_cast<_Rep*
>(__p);
2589 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2590 {
return this->_M_refcount < 0; }
2593 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2594 {
return this->_M_refcount > 0; }
2597 _M_set_leaked() _GLIBCXX_NOEXCEPT
2598 { this->_M_refcount = -1; }
2601 _M_set_sharable() _GLIBCXX_NOEXCEPT
2602 { this->_M_refcount = 0; }
2605 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2607 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2608 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2611 this->_M_set_sharable();
2612 this->_M_length = __n;
2613 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2620 _M_refdata()
throw()
2621 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2624 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2626 return (!_M_is_leaked() && __alloc1 == __alloc2)
2627 ? _M_refcopy() : _M_clone(__alloc1);
2632 _S_create(size_type, size_type,
const _Alloc&);
2635 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2637 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2638 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2642 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2643 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2646 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2653 _M_destroy(
const _Alloc&)
throw();
2656 _M_refcopy()
throw()
2658 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2659 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2661 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2662 return _M_refdata();
2666 _M_clone(
const _Alloc&, size_type __res = 0);
2670 struct _Alloc_hider : _Alloc
2672 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2673 : _Alloc(__a), _M_p(__dat) { }
2683 static const size_type npos =
static_cast<size_type
>(-1);
2687 mutable _Alloc_hider _M_dataplus;
2690 _M_data() const _GLIBCXX_NOEXCEPT
2691 {
return _M_dataplus._M_p; }
2694 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2695 {
return (_M_dataplus._M_p = __p); }
2698 _M_rep() const _GLIBCXX_NOEXCEPT
2699 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2704 _M_ibegin() const _GLIBCXX_NOEXCEPT
2705 {
return iterator(_M_data()); }
2708 _M_iend() const _GLIBCXX_NOEXCEPT
2709 {
return iterator(_M_data() + this->
size()); }
2714 if (!_M_rep()->_M_is_leaked())
2719 _M_check(size_type __pos,
const char* __s)
const
2721 if (__pos > this->
size())
2722 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
2723 "this->size() (which is %zu)"),
2724 __s, __pos, this->
size());
2729 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
2732 __throw_length_error(__N(__s));
2737 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2739 const bool __testoff = __off < this->
size() - __pos;
2740 return __testoff ? __off : this->
size() - __pos;
2745 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2747 return (less<const _CharT*>()(__s, _M_data())
2748 || less<const _CharT*>()(_M_data() + this->
size(), __s));
2754 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2757 traits_type::assign(*__d, *__s);
2759 traits_type::copy(__d, __s, __n);
2763 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2766 traits_type::assign(*__d, *__s);
2768 traits_type::move(__d, __s, __n);
2772 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2775 traits_type::assign(*__d, __c);
2777 traits_type::assign(__d, __n, __c);
2782 template<
class _Iterator>
2784 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2787 for (; __k1 != __k2; ++__k1, ++__p)
2788 traits_type::assign(*__p, *__k1);
2792 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2793 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2796 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2798 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2801 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2802 { _M_copy(__p, __k1, __k2 - __k1); }
2805 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2807 { _M_copy(__p, __k1, __k2 - __k1); }
2810 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2812 const difference_type __d = difference_type(__n1 - __n2);
2814 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2815 return __gnu_cxx::__numeric_traits<int>::__max;
2816 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2817 return __gnu_cxx::__numeric_traits<int>::__min;
2823 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2829 _S_empty_rep() _GLIBCXX_NOEXCEPT
2830 {
return _Rep::_S_empty_rep(); }
2841 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2842 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2844 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2866 size_type __n = npos);
2875 size_type __n,
const _Alloc& __a);
2887 const _Alloc& __a = _Alloc());
2893 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2900 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2902 #if __cplusplus >= 201103L
2911 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2914 : _M_dataplus(__str._M_dataplus)
2916 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
2917 __str._M_data(_S_empty_rep()._M_refdata());
2919 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
2937 template<
class _InputIterator>
2938 basic_string(_InputIterator __beg, _InputIterator __end,
2939 const _Alloc& __a = _Alloc());
2953 {
return this->
assign(__str); }
2961 {
return this->
assign(__s); }
2977 #if __cplusplus >= 201103L
3001 this->
assign(__l.begin(), __l.size());
3015 return iterator(_M_data());
3024 {
return const_iterator(_M_data()); }
3034 return iterator(_M_data() + this->
size());
3043 {
return const_iterator(_M_data() + this->
size()); }
3052 {
return reverse_iterator(this->
end()); }
3059 const_reverse_iterator
3061 {
return const_reverse_iterator(this->
end()); }
3070 {
return reverse_iterator(this->
begin()); }
3077 const_reverse_iterator
3079 {
return const_reverse_iterator(this->
begin()); }
3081 #if __cplusplus >= 201103L
3088 {
return const_iterator(this->_M_data()); }
3096 {
return const_iterator(this->_M_data() + this->
size()); }
3103 const_reverse_iterator
3105 {
return const_reverse_iterator(this->
end()); }
3112 const_reverse_iterator
3114 {
return const_reverse_iterator(this->
begin()); }
3123 {
return _M_rep()->_M_length; }
3129 {
return _M_rep()->_M_length; }
3134 {
return _Rep::_S_max_size; }
3147 resize(size_type __n, _CharT __c);
3161 { this->
resize(__n, _CharT()); }
3163 #if __cplusplus >= 201103L
3168 #if __cpp_exceptions
3186 {
return _M_rep()->_M_capacity; }
3206 reserve(size_type __res_arg = 0);
3214 { _M_mutate(0, this->
size(), 0); }
3222 {
return this->
size() == 0; }
3238 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3239 return _M_data()[__pos];
3257 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3259 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3261 return _M_data()[__pos];
3277 if (__n >= this->
size())
3278 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3279 "(which is %zu) >= this->size() "
3282 return _M_data()[__n];
3300 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3301 "(which is %zu) >= this->size() "
3305 return _M_data()[__n];
3308 #if __cplusplus >= 201103L
3350 {
return this->
append(__str); }
3359 {
return this->
append(__s); }
3373 #if __cplusplus >= 201103L
3381 {
return this->
append(__l.begin(), __l.size()); }
3415 append(
const _CharT* __s, size_type __n);
3425 __glibcxx_requires_string(__s);
3426 return this->
append(__s, traits_type::length(__s));
3438 append(size_type __n, _CharT __c);
3440 #if __cplusplus >= 201103L
3448 {
return this->
append(__l.begin(), __l.size()); }
3459 template<
class _InputIterator>
3461 append(_InputIterator __first, _InputIterator __last)
3462 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3471 const size_type __len = 1 + this->
size();
3472 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3474 traits_type::assign(_M_data()[this->
size()], __c);
3475 _M_rep()->_M_set_length_and_sharable(__len);
3486 #if __cplusplus >= 201103L
3519 {
return this->
assign(__str._M_data()
3520 + __str._M_check(__pos,
"basic_string::assign"),
3521 __str._M_limit(__pos, __n)); }
3534 assign(
const _CharT* __s, size_type __n);
3548 __glibcxx_requires_string(__s);
3549 return this->
assign(__s, traits_type::length(__s));
3563 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3573 template<
class _InputIterator>
3575 assign(_InputIterator __first, _InputIterator __last)
3576 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3578 #if __cplusplus >= 201103L
3586 {
return this->
assign(__l.begin(), __l.size()); }
3603 insert(iterator __p, size_type __n, _CharT __c)
3604 { this->
replace(__p, __p, __n, __c); }
3618 template<
class _InputIterator>
3620 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3621 { this->
replace(__p, __p, __beg, __end); }
3623 #if __cplusplus >= 201103L
3633 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3634 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3652 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3674 size_type __pos2, size_type __n)
3675 {
return this->
insert(__pos1, __str._M_data()
3676 + __str._M_check(__pos2,
"basic_string::insert"),
3677 __str._M_limit(__pos2, __n)); }
3696 insert(size_type __pos,
const _CharT* __s, size_type __n);
3716 __glibcxx_requires_string(__s);
3717 return this->
insert(__pos, __s, traits_type::length(__s));
3737 insert(size_type __pos, size_type __n, _CharT __c)
3738 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3739 size_type(0), __n, __c); }
3757 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3758 const size_type __pos = __p - _M_ibegin();
3759 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3760 _M_rep()->_M_set_leaked();
3761 return iterator(_M_data() + __pos);
3780 erase(size_type __pos = 0, size_type __n = npos)
3782 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3783 _M_limit(__pos, __n), size_type(0));
3798 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3799 && __position < _M_iend());
3800 const size_type __pos = __position - _M_ibegin();
3801 _M_mutate(__pos, size_type(1), size_type(0));
3802 _M_rep()->_M_set_leaked();
3803 return iterator(_M_data() + __pos);
3816 erase(iterator __first, iterator __last);
3818 #if __cplusplus >= 201103L
3848 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3870 size_type __pos2, size_type __n2)
3871 {
return this->
replace(__pos1, __n1, __str._M_data()
3872 + __str._M_check(__pos2,
"basic_string::replace"),
3873 __str._M_limit(__pos2, __n2)); }
3894 replace(size_type __pos, size_type __n1,
const _CharT* __s,
3914 replace(size_type __pos, size_type __n1,
const _CharT* __s)
3916 __glibcxx_requires_string(__s);
3917 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
3938 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
3939 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
3940 _M_limit(__pos, __n1), __n2, __c); }
3957 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
3975 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
3977 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
3978 && __i2 <= _M_iend());
3979 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
3996 replace(iterator __i1, iterator __i2,
const _CharT* __s)
3998 __glibcxx_requires_string(__s);
3999 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4017 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4019 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4020 && __i2 <= _M_iend());
4021 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4039 template<
class _InputIterator>
4042 _InputIterator __k1, _InputIterator __k2)
4044 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4045 && __i2 <= _M_iend());
4046 __glibcxx_requires_valid_range(__k1, __k2);
4047 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4048 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4054 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4056 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4057 && __i2 <= _M_iend());
4058 __glibcxx_requires_valid_range(__k1, __k2);
4059 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4064 replace(iterator __i1, iterator __i2,
4065 const _CharT* __k1,
const _CharT* __k2)
4067 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4068 && __i2 <= _M_iend());
4069 __glibcxx_requires_valid_range(__k1, __k2);
4070 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4075 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4077 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4078 && __i2 <= _M_iend());
4079 __glibcxx_requires_valid_range(__k1, __k2);
4080 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4081 __k1.base(), __k2 - __k1);
4085 replace(iterator __i1, iterator __i2,
4086 const_iterator __k1, const_iterator __k2)
4088 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4089 && __i2 <= _M_iend());
4090 __glibcxx_requires_valid_range(__k1, __k2);
4091 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4092 __k1.base(), __k2 - __k1);
4095 #if __cplusplus >= 201103L
4112 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4116 template<
class _Integer>
4118 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4119 _Integer __val, __true_type)
4120 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4122 template<
class _InputIterator>
4124 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4125 _InputIterator __k2, __false_type);
4128 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4132 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4137 template<
class _InIterator>
4139 _S_construct_aux(_InIterator __beg, _InIterator __end,
4140 const _Alloc& __a, __false_type)
4142 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4143 return _S_construct(__beg, __end, __a, _Tag());
4148 template<
class _Integer>
4150 _S_construct_aux(_Integer __beg, _Integer __end,
4151 const _Alloc& __a, __true_type)
4152 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4156 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4157 {
return _S_construct(__req, __c, __a); }
4159 template<
class _InIterator>
4161 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4163 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4164 return _S_construct_aux(__beg, __end, __a, _Integral());
4168 template<
class _InIterator>
4170 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4171 input_iterator_tag);
4175 template<
class _FwdIterator>
4177 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4178 forward_iterator_tag);
4181 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4198 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4220 {
return _M_data(); }
4230 {
return _M_data(); }
4237 {
return _M_dataplus; }
4252 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4267 {
return this->
find(__str.data(), __pos, __str.size()); }
4280 find(
const _CharT* __s, size_type __pos = 0)
const
4282 __glibcxx_requires_string(__s);
4283 return this->
find(__s, __pos, traits_type::length(__s));
4297 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
4312 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4327 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4340 rfind(
const _CharT* __s, size_type __pos = npos)
const
4342 __glibcxx_requires_string(__s);
4343 return this->
rfind(__s, __pos, traits_type::length(__s));
4357 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
4373 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4388 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4403 __glibcxx_requires_string(__s);
4404 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4421 {
return this->
find(__c, __pos); }
4437 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4452 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4467 __glibcxx_requires_string(__s);
4468 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4485 {
return this->
rfind(__c, __pos); }
4516 size_type __n)
const;
4531 __glibcxx_requires_string(__s);
4579 size_type __n)
const;
4594 __glibcxx_requires_string(__s);
4625 substr(size_type __pos = 0, size_type __n = npos)
const
4627 _M_check(__pos,
"basic_string::substr"), __n); }
4646 const size_type __size = this->
size();
4647 const size_type __osize = __str.size();
4648 const size_type __len =
std::min(__size, __osize);
4650 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4652 __r = _S_compare(__size, __osize);
4703 size_type __pos2, size_type __n2)
const;
4720 compare(
const _CharT* __s)
const;
4744 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4771 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4772 size_type __n2)
const;
4774 #endif // !_GLIBCXX_USE_CXX11_ABI
4783 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4784 basic_string<_CharT, _Traits, _Alloc>
4789 __str.append(__rhs);
4799 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4800 basic_string<_CharT,_Traits,_Alloc>
4802 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4810 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4811 basic_string<_CharT,_Traits,_Alloc>
4812 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4820 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4821 inline basic_string<_CharT, _Traits, _Alloc>
4823 const _CharT* __rhs)
4826 __str.append(__rhs);
4836 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4837 inline basic_string<_CharT, _Traits, _Alloc>
4841 typedef typename __string_type::size_type __size_type;
4842 __string_type __str(__lhs);
4843 __str.append(__size_type(1), __rhs);
4847 #if __cplusplus >= 201103L
4848 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4849 inline basic_string<_CharT, _Traits, _Alloc>
4850 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4851 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4852 {
return std::move(__lhs.append(__rhs)); }
4854 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4855 inline basic_string<_CharT, _Traits, _Alloc>
4856 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4857 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4858 {
return std::move(__rhs.insert(0, __lhs)); }
4860 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4861 inline basic_string<_CharT, _Traits, _Alloc>
4862 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4863 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4865 const auto __size = __lhs.size() + __rhs.size();
4866 const bool __cond = (__size > __lhs.capacity()
4867 && __size <= __rhs.capacity());
4868 return __cond ? std::move(__rhs.insert(0, __lhs))
4869 : std::move(__lhs.append(__rhs));
4872 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4873 inline basic_string<_CharT, _Traits, _Alloc>
4875 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4876 {
return std::move(__rhs.insert(0, __lhs)); }
4878 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4879 inline basic_string<_CharT, _Traits, _Alloc>
4881 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4882 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4884 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4885 inline basic_string<_CharT, _Traits, _Alloc>
4886 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4887 const _CharT* __rhs)
4888 {
return std::move(__lhs.append(__rhs)); }
4890 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4891 inline basic_string<_CharT, _Traits, _Alloc>
4892 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4894 {
return std::move(__lhs.append(1, __rhs)); }
4904 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4908 {
return __lhs.compare(__rhs) == 0; }
4910 template<
typename _CharT>
4912 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
4913 operator==(
const basic_string<_CharT>& __lhs,
4914 const basic_string<_CharT>& __rhs)
4915 {
return (__lhs.size() == __rhs.size()
4925 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4927 operator==(
const _CharT* __lhs,
4929 {
return __rhs.compare(__lhs) == 0; }
4937 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4940 const _CharT* __rhs)
4941 {
return __lhs.compare(__rhs) == 0; }
4950 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4954 {
return !(__lhs == __rhs); }
4962 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4964 operator!=(
const _CharT* __lhs,
4966 {
return !(__lhs == __rhs); }
4974 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4977 const _CharT* __rhs)
4978 {
return !(__lhs == __rhs); }
4987 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4989 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4991 {
return __lhs.compare(__rhs) < 0; }
4999 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5001 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5002 const _CharT* __rhs)
5003 {
return __lhs.compare(__rhs) < 0; }
5011 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5013 operator<(
const _CharT* __lhs,
5015 {
return __rhs.compare(__lhs) > 0; }
5024 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5028 {
return __lhs.compare(__rhs) > 0; }
5036 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5039 const _CharT* __rhs)
5040 {
return __lhs.compare(__rhs) > 0; }
5048 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5050 operator>(
const _CharT* __lhs,
5052 {
return __rhs.compare(__lhs) < 0; }
5061 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5063 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5065 {
return __lhs.compare(__rhs) <= 0; }
5073 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5075 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5076 const _CharT* __rhs)
5077 {
return __lhs.compare(__rhs) <= 0; }
5085 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5087 operator<=(
const _CharT* __lhs,
5089 {
return __rhs.compare(__lhs) >= 0; }
5098 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5102 {
return __lhs.compare(__rhs) >= 0; }
5110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5113 const _CharT* __rhs)
5114 {
return __lhs.compare(__rhs) >= 0; }
5122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5124 operator>=(
const _CharT* __lhs,
5126 {
return __rhs.compare(__lhs) <= 0; }
5135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5139 { __lhs.swap(__rhs); }
5154 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5155 basic_istream<_CharT, _Traits>&
5156 operator>>(basic_istream<_CharT, _Traits>& __is,
5157 basic_string<_CharT, _Traits, _Alloc>& __str);
5160 basic_istream<char>&
5161 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
5172 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5173 inline basic_ostream<_CharT, _Traits>&
5174 operator<<(basic_ostream<_CharT, _Traits>& __os,
5179 return __ostream_insert(__os, __str.data(), __str.size());
5195 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5196 basic_istream<_CharT, _Traits>&
5197 getline(basic_istream<_CharT, _Traits>& __is,
5198 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
5212 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5213 inline basic_istream<_CharT, _Traits>&
5218 #if __cplusplus >= 201103L
5220 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5221 inline basic_istream<_CharT, _Traits>&
5227 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5228 inline basic_istream<_CharT, _Traits>&
5235 basic_istream<char>&
5236 getline(basic_istream<char>& __in, basic_string<char>& __str,
5239 #ifdef _GLIBCXX_USE_WCHAR_T
5241 basic_istream<wchar_t>&
5242 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
5246 _GLIBCXX_END_NAMESPACE_VERSION
5249 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
5253 namespace std _GLIBCXX_VISIBILITY(default)
5255 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5256 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5260 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5261 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
5265 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5266 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
5269 inline unsigned long
5270 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5271 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
5275 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5276 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
5279 inline unsigned long long
5280 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5281 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
5286 stof(
const string& __str,
size_t* __idx = 0)
5287 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
5290 stod(
const string& __str,
size_t* __idx = 0)
5291 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
5294 stold(
const string& __str,
size_t* __idx = 0)
5295 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
5301 to_string(
int __val)
5302 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5306 to_string(
unsigned __val)
5307 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5308 4 *
sizeof(unsigned),
5312 to_string(
long __val)
5313 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5317 to_string(
unsigned long __val)
5318 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5319 4 *
sizeof(
unsigned long),
5323 to_string(
long long __val)
5324 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5325 4 *
sizeof(
long long),
5329 to_string(
unsigned long long __val)
5330 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5331 4 *
sizeof(
unsigned long long),
5335 to_string(
float __val)
5338 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5339 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5344 to_string(
double __val)
5347 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5348 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5353 to_string(
long double __val)
5356 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5357 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5361 #ifdef _GLIBCXX_USE_WCHAR_T
5363 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5364 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
5368 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5369 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
5372 inline unsigned long
5373 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5374 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
5378 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5379 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
5382 inline unsigned long long
5383 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5384 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
5389 stof(
const wstring& __str,
size_t* __idx = 0)
5390 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
5393 stod(
const wstring& __str,
size_t* __idx = 0)
5394 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
5397 stold(
const wstring& __str,
size_t* __idx = 0)
5398 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
5400 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5403 to_wstring(
int __val)
5404 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5408 to_wstring(
unsigned __val)
5409 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5410 4 *
sizeof(unsigned),
5414 to_wstring(
long __val)
5415 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5419 to_wstring(
unsigned long __val)
5420 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5421 4 *
sizeof(
unsigned long),
5425 to_wstring(
long long __val)
5426 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5427 4 *
sizeof(
long long),
5431 to_wstring(
unsigned long long __val)
5432 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5433 4 *
sizeof(
unsigned long long),
5437 to_wstring(
float __val)
5440 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5441 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5446 to_wstring(
double __val)
5449 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5450 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5455 to_wstring(
long double __val)
5458 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5459 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5462 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
5465 _GLIBCXX_END_NAMESPACE_CXX11
5466 _GLIBCXX_END_NAMESPACE_VERSION
5471 #if __cplusplus >= 201103L
5475 namespace std _GLIBCXX_VISIBILITY(default)
5477 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5481 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
5485 :
public __hash_base<size_t, string>
5488 operator()(
const string& __s)
const noexcept
5489 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5496 #ifdef _GLIBCXX_USE_WCHAR_T
5500 :
public __hash_base<size_t, wstring>
5503 operator()(
const wstring& __s)
const noexcept
5504 {
return std::_Hash_impl::hash(__s.
data(),
5505 __s.
length() *
sizeof(wchar_t)); }
5514 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5518 :
public __hash_base<size_t, u16string>
5521 operator()(
const u16string& __s)
const noexcept
5522 {
return std::_Hash_impl::hash(__s.
data(),
5523 __s.
length() *
sizeof(char16_t)); }
5533 :
public __hash_base<size_t, u32string>
5536 operator()(
const u32string& __s)
const noexcept
5537 {
return std::_Hash_impl::hash(__s.
data(),
5538 __s.
length() *
sizeof(char32_t)); }
5546 #if __cplusplus > 201103L
5548 #define __cpp_lib_string_udls 201304
5550 inline namespace literals
5552 inline namespace string_literals
5555 _GLIBCXX_DEFAULT_ABI_TAG
5556 inline basic_string<char>
5557 operator""s(
const char* __str,
size_t __len)
5558 {
return basic_string<char>{__str, __len}; }
5560 #ifdef _GLIBCXX_USE_WCHAR_T
5561 _GLIBCXX_DEFAULT_ABI_TAG
5562 inline basic_string<wchar_t>
5563 operator""s(
const wchar_t* __str,
size_t __len)
5564 {
return basic_string<wchar_t>{__str, __len}; }
5567 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
5568 _GLIBCXX_DEFAULT_ABI_TAG
5569 inline basic_string<char16_t>
5570 operator""s(
const char16_t* __str,
size_t __len)
5571 {
return basic_string<char16_t>{__str, __len}; }
5573 _GLIBCXX_DEFAULT_ABI_TAG
5574 inline basic_string<char32_t>
5575 operator""s(
const char32_t* __str,
size_t __len)
5576 {
return basic_string<char32_t>{__str, __len}; }
5582 #endif // __cplusplus > 201103L
5584 _GLIBCXX_END_NAMESPACE_VERSION
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
const_reverse_iterator rend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
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(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, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
const _CharT * data() const noexcept
Return const pointer to contents.
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.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
Primary class template hash.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
const_reference back() const noexcept
Uniform interface to C++98 and C++0x allocators.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
Template class basic_istream.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
const_reverse_iterator crbegin() const noexcept
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
const_iterator cbegin() const noexcept
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
const_reverse_iterator rbegin() const noexcept
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.
Managing sequences of characters and character-like objects.
Uniform interface to all pointer-like types.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
const_iterator end() const noexcept
int compare(const basic_string &__str) const
Compare to a string.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(const _CharT *__s)
Append a C string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
Forward iterators support a superset of input iterator operations.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
static const size_type npos
Value returned by various member functions when they fail.
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.
reverse_iterator rbegin()
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string()
Default constructor creates an empty string.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
basic_string< wchar_t > wstring
A string of wchar_t.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
Basis for explicit traits specializations.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
ISO C++ entities toplevel namespace is std.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
char_type widen(char __c) const
Widens characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & append(const basic_string &__str)
Append a string to this string.
~basic_string() noexcept
Destroy the string instance.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const_iterator begin() const noexcept
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
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.
const_reference front() const noexcept
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
bool empty() const noexcept
iterator erase(iterator __position)
Remove one character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
const_iterator cend() const noexcept
void pop_back()
Remove the last character.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.