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)
326 for (; __k1 != __k2; ++__k1, ++__p)
327 traits_type::assign(*__p, *__k1);
331 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
332 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
335 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
337 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
340 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
341 { _S_copy(__p, __k1, __k2 - __k1); }
344 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
346 { _S_copy(__p, __k1, __k2 - __k1); }
349 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
351 const difference_type __d = difference_type(__n1 - __n2);
353 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
354 return __gnu_cxx::__numeric_traits<int>::__max;
355 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
356 return __gnu_cxx::__numeric_traits<int>::__min;
365 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
369 _M_erase(size_type __pos, size_type __n);
380 #if __cplusplus >= 201103L 381 noexcept(is_nothrow_default_constructible<_Alloc>::value)
383 : _M_dataplus(_M_local_data())
384 { _M_set_length(0); }
391 : _M_dataplus(_M_local_data(), __a)
392 { _M_set_length(0); }
399 : _M_dataplus(_M_local_data(),
400 _Alloc_traits::_S_select_on_copy(__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 noexcept(_Alloc_traits::_S_always_equal())
514 : _M_dataplus(_M_local_data(), __a)
516 if (__str._M_is_local())
518 traits_type::copy(_M_local_buf, __str._M_local_buf,
519 _S_local_capacity + 1);
520 _M_length(__str.length());
521 __str._M_set_length(0);
523 else if (_Alloc_traits::_S_always_equal()
524 || __str.get_allocator() == __a)
526 _M_data(__str._M_data());
527 _M_length(__str.length());
528 _M_capacity(__str._M_allocated_capacity);
529 __str._M_data(__str._M_local_buf);
530 __str._M_set_length(0);
533 _M_construct(__str.begin(), __str.end());
544 #if __cplusplus >= 201103L 545 template<
typename _InputIterator,
546 typename = std::_RequireInputIter<_InputIterator>>
548 template<
typename _InputIterator>
550 basic_string(_InputIterator __beg, _InputIterator __end,
551 const _Alloc& __a = _Alloc())
552 : _M_dataplus(_M_local_data(), __a)
553 { _M_construct(__beg, __end); }
568 #if __cplusplus >= 201103L 569 if (_Alloc_traits::_S_propagate_on_copy_assign())
571 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
572 && _M_get_allocator() != __str._M_get_allocator())
576 if (__str.size() <= _S_local_capacity)
578 _M_destroy(_M_allocated_capacity);
579 _M_data(_M_local_data());
584 const auto __len = __str.size();
585 auto __alloc = __str._M_get_allocator();
587 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
588 _M_destroy(_M_allocated_capacity);
591 _M_set_length(__len);
594 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
597 return this->
assign(__str);
606 {
return this->
assign(__s); }
622 #if __cplusplus >= 201103L 635 noexcept(_Alloc_traits::_S_nothrow_move())
637 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
638 && !_Alloc_traits::_S_always_equal()
639 && _M_get_allocator() != __str._M_get_allocator())
642 _M_destroy(_M_allocated_capacity);
643 _M_data(_M_local_data());
647 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
649 if (!__str._M_is_local()
650 && (_Alloc_traits::_S_propagate_on_move_assign()
651 || _Alloc_traits::_S_always_equal()))
653 pointer __data =
nullptr;
654 size_type __capacity;
657 if (_Alloc_traits::_S_always_equal())
660 __capacity = _M_allocated_capacity;
663 _M_destroy(_M_allocated_capacity);
666 _M_data(__str._M_data());
667 _M_length(__str.length());
668 _M_capacity(__str._M_allocated_capacity);
671 __str._M_data(__data);
672 __str._M_capacity(__capacity);
675 __str._M_data(__str._M_local_buf);
690 this->
assign(__l.begin(), __l.size());
701 begin() _GLIBCXX_NOEXCEPT
702 {
return iterator(_M_data()); }
709 begin() const _GLIBCXX_NOEXCEPT
710 {
return const_iterator(_M_data()); }
717 end() _GLIBCXX_NOEXCEPT
718 {
return iterator(_M_data() + this->
size()); }
725 end() const _GLIBCXX_NOEXCEPT
726 {
return const_iterator(_M_data() + this->
size()); }
734 rbegin() _GLIBCXX_NOEXCEPT
735 {
return reverse_iterator(this->
end()); }
742 const_reverse_iterator
743 rbegin() const _GLIBCXX_NOEXCEPT
744 {
return const_reverse_iterator(this->
end()); }
752 rend() _GLIBCXX_NOEXCEPT
753 {
return reverse_iterator(this->
begin()); }
760 const_reverse_iterator
761 rend() const _GLIBCXX_NOEXCEPT
762 {
return const_reverse_iterator(this->
begin()); }
764 #if __cplusplus >= 201103L 771 {
return const_iterator(this->_M_data()); }
778 cend() const noexcept
779 {
return const_iterator(this->_M_data() + this->
size()); }
786 const_reverse_iterator
788 {
return const_reverse_iterator(this->
end()); }
795 const_reverse_iterator
796 crend() const noexcept
797 {
return const_reverse_iterator(this->
begin()); }
805 size() const _GLIBCXX_NOEXCEPT
806 {
return _M_string_length; }
811 length() const _GLIBCXX_NOEXCEPT
812 {
return _M_string_length; }
817 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
830 resize(size_type __n, _CharT __c);
844 { this->
resize(__n, _CharT()); }
846 #if __cplusplus >= 201103L 870 return _M_is_local() ? size_type(_S_local_capacity)
871 : _M_allocated_capacity;
892 reserve(size_type __res_arg = 0);
898 clear() _GLIBCXX_NOEXCEPT
899 { _M_set_length(0); }
906 empty() const _GLIBCXX_NOEXCEPT
907 {
return this->
size() == 0; }
921 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
923 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
924 return _M_data()[__pos];
942 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
944 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
945 return _M_data()[__pos];
959 at(size_type __n)
const 961 if (__n >= this->
size())
962 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 963 "(which is %zu) >= this->size() " 966 return _M_data()[__n];
983 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 984 "(which is %zu) >= this->size() " 987 return _M_data()[__n];
990 #if __cplusplus >= 201103L 1004 front() const noexcept
1020 back() const noexcept
1032 {
return this->
append(__str); }
1041 {
return this->
append(__s); }
1055 #if __cplusplus >= 201103L 1063 {
return this->
append(__l.begin(), __l.size()); }
1073 {
return _M_append(__str._M_data(), __str.size()); }
1090 {
return _M_append(__str._M_data()
1091 + __str._M_check(__pos,
"basic_string::append"),
1092 __str._M_limit(__pos, __n)); }
1101 append(
const _CharT* __s, size_type __n)
1103 __glibcxx_requires_string_len(__s, __n);
1104 _M_check_length(size_type(0), __n,
"basic_string::append");
1105 return _M_append(__s, __n);
1114 append(
const _CharT* __s)
1116 __glibcxx_requires_string(__s);
1117 const size_type __n = traits_type::length(__s);
1118 _M_check_length(size_type(0), __n,
"basic_string::append");
1119 return _M_append(__s, __n);
1131 append(size_type __n, _CharT __c)
1132 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1134 #if __cplusplus >= 201103L 1141 append(initializer_list<_CharT> __l)
1142 {
return this->
append(__l.begin(), __l.size()); }
1153 #if __cplusplus >= 201103L 1154 template<
class _InputIterator,
1155 typename = std::_RequireInputIter<_InputIterator>>
1157 template<
class _InputIterator>
1160 append(_InputIterator __first, _InputIterator __last)
1170 const size_type __size = this->
size();
1172 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1173 traits_type::assign(this->_M_data()[__size], __c);
1174 this->_M_set_length(__size + 1);
1185 this->_M_assign(__str);
1189 #if __cplusplus >= 201103L 1200 noexcept(_Alloc_traits::_S_nothrow_move())
1204 return *
this = std::move(__str);
1223 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1224 + __str._M_check(__pos,
"basic_string::assign"),
1225 __str._M_limit(__pos, __n)); }
1238 assign(
const _CharT* __s, size_type __n)
1240 __glibcxx_requires_string_len(__s, __n);
1241 return _M_replace(size_type(0), this->
size(), __s, __n);
1254 assign(
const _CharT* __s)
1256 __glibcxx_requires_string(__s);
1257 return _M_replace(size_type(0), this->
size(), __s,
1258 traits_type::length(__s));
1271 assign(size_type __n, _CharT __c)
1272 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1282 #if __cplusplus >= 201103L 1283 template<
class _InputIterator,
1284 typename = std::_RequireInputIter<_InputIterator>>
1286 template<
class _InputIterator>
1289 assign(_InputIterator __first, _InputIterator __last)
1292 #if __cplusplus >= 201103L 1299 assign(initializer_list<_CharT> __l)
1300 {
return this->
assign(__l.begin(), __l.size()); }
1303 #if __cplusplus >= 201103L 1320 insert(const_iterator __p, size_type __n, _CharT __c)
1322 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1323 const size_type __pos = __p -
begin();
1324 this->
replace(__p, __p, __n, __c);
1325 return iterator(this->_M_data() + __pos);
1342 insert(iterator __p, size_type __n, _CharT __c)
1343 { this->
replace(__p, __p, __n, __c); }
1346 #if __cplusplus >= 201103L 1361 template<
class _InputIterator,
1362 typename = std::_RequireInputIter<_InputIterator>>
1364 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1366 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1367 const size_type __pos = __p -
begin();
1368 this->
replace(__p, __p, __beg, __end);
1369 return iterator(this->_M_data() + __pos);
1384 template<
class _InputIterator>
1386 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1387 { this->
replace(__p, __p, __beg, __end); }
1390 #if __cplusplus >= 201103L 1398 insert(iterator __p, initializer_list<_CharT> __l)
1400 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1401 this->
insert(__p -
begin(), __l.begin(), __l.size());
1419 {
return this->
replace(__pos1, size_type(0),
1420 __str._M_data(), __str.size()); }
1442 size_type __pos2, size_type __n)
1443 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1444 + __str._M_check(__pos2,
"basic_string::insert"),
1445 __str._M_limit(__pos2, __n)); }
1464 insert(size_type __pos,
const _CharT* __s, size_type __n)
1465 {
return this->
replace(__pos, size_type(0), __s, __n); }
1483 insert(size_type __pos,
const _CharT* __s)
1485 __glibcxx_requires_string(__s);
1486 return this->
replace(__pos, size_type(0), __s,
1487 traits_type::length(__s));
1507 insert(size_type __pos, size_type __n, _CharT __c)
1508 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1509 size_type(0), __n, __c); }
1525 insert(__const_iterator __p, _CharT __c)
1527 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1528 const size_type __pos = __p -
begin();
1529 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1530 return iterator(_M_data() + __pos);
1549 erase(size_type __pos = 0, size_type __n =
npos)
1551 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1552 _M_limit(__pos, __n));
1565 erase(__const_iterator __position)
1567 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1568 && __position <
end());
1569 const size_type __pos = __position -
begin();
1570 this->_M_erase(__pos, size_type(1));
1571 return iterator(_M_data() + __pos);
1584 erase(__const_iterator __first, __const_iterator __last)
1586 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1587 && __last <=
end());
1588 const size_type __pos = __first -
begin();
1589 this->_M_erase(__pos, __last - __first);
1590 return iterator(this->_M_data() + __pos);
1593 #if __cplusplus >= 201103L 1601 { _M_erase(
size()-1, 1); }
1623 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1645 size_type __pos2, size_type __n2)
1646 {
return this->
replace(__pos1, __n1, __str._M_data()
1647 + __str._M_check(__pos2,
"basic_string::replace"),
1648 __str._M_limit(__pos2, __n2)); }
1669 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1672 __glibcxx_requires_string_len(__s, __n2);
1673 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1674 _M_limit(__pos, __n1), __s, __n2);
1694 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1696 __glibcxx_requires_string(__s);
1697 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1718 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1719 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1720 _M_limit(__pos, __n1), __n2, __c); }
1736 replace(__const_iterator __i1, __const_iterator __i2,
1738 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1756 replace(__const_iterator __i1, __const_iterator __i2,
1757 const _CharT* __s, size_type __n)
1759 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1761 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1778 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1780 __glibcxx_requires_string(__s);
1781 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1799 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1802 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1804 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1822 #if __cplusplus >= 201103L 1823 template<
class _InputIterator,
1824 typename = std::_RequireInputIter<_InputIterator>>
1826 replace(const_iterator __i1, const_iterator __i2,
1827 _InputIterator __k1, _InputIterator __k2)
1829 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1831 __glibcxx_requires_valid_range(__k1, __k2);
1832 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1833 std::__false_type());
1836 template<
class _InputIterator>
1837 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1838 typename __enable_if_not_native_iterator<_InputIterator>::__type
1842 replace(iterator __i1, iterator __i2,
1843 _InputIterator __k1, _InputIterator __k2)
1845 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1847 __glibcxx_requires_valid_range(__k1, __k2);
1848 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1849 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1856 replace(__const_iterator __i1, __const_iterator __i2,
1857 _CharT* __k1, _CharT* __k2)
1859 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1861 __glibcxx_requires_valid_range(__k1, __k2);
1867 replace(__const_iterator __i1, __const_iterator __i2,
1868 const _CharT* __k1,
const _CharT* __k2)
1870 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1872 __glibcxx_requires_valid_range(__k1, __k2);
1878 replace(__const_iterator __i1, __const_iterator __i2,
1879 iterator __k1, iterator __k2)
1881 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1883 __glibcxx_requires_valid_range(__k1, __k2);
1885 __k1.base(), __k2 - __k1);
1889 replace(__const_iterator __i1, __const_iterator __i2,
1890 const_iterator __k1, const_iterator __k2)
1892 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1894 __glibcxx_requires_valid_range(__k1, __k2);
1896 __k1.base(), __k2 - __k1);
1899 #if __cplusplus >= 201103L 1915 initializer_list<_CharT> __l)
1916 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1920 template<
class _Integer>
1922 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1923 _Integer __n, _Integer __val, __true_type)
1924 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1926 template<
class _InputIterator>
1928 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1929 _InputIterator __k1, _InputIterator __k2,
1933 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1937 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1938 const size_type __len2);
1941 _M_append(
const _CharT* __s, size_type __n);
1958 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1978 c_str() const _GLIBCXX_NOEXCEPT
1979 {
return _M_data(); }
1988 data() const _GLIBCXX_NOEXCEPT
1989 {
return _M_data(); }
1996 {
return _M_get_allocator(); }
2011 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2026 {
return this->
find(__str.data(), __pos, __str.size()); }
2039 find(
const _CharT* __s, size_type __pos = 0)
const 2041 __glibcxx_requires_string(__s);
2042 return this->
find(__s, __pos, traits_type::length(__s));
2056 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2071 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2086 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2099 rfind(
const _CharT* __s, size_type __pos =
npos)
const 2101 __glibcxx_requires_string(__s);
2102 return this->
rfind(__s, __pos, traits_type::length(__s));
2116 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2132 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2147 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2162 __glibcxx_requires_string(__s);
2163 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2179 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2180 {
return this->
find(__c, __pos); }
2196 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2211 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2226 __glibcxx_requires_string(__s);
2227 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2244 {
return this->
rfind(__c, __pos); }
2275 size_type __n)
const;
2290 __glibcxx_requires_string(__s);
2338 size_type __n)
const;
2353 __glibcxx_requires_string(__s);
2384 substr(size_type __pos = 0, size_type __n =
npos)
const 2386 _M_check(__pos,
"basic_string::substr"), __n); }
2405 const size_type __size = this->
size();
2406 const size_type __osize = __str.size();
2407 const size_type __len =
std::min(__size, __osize);
2409 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2411 __r = _S_compare(__size, __osize);
2462 size_type __pos2, size_type __n2)
const;
2479 compare(
const _CharT* __s)
const;
2503 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2530 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2531 size_type __n2)
const;
2533 _GLIBCXX_END_NAMESPACE_CXX11
2534 #else // !_GLIBCXX_USE_CXX11_ABI 2599 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2602 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2606 typedef _Traits traits_type;
2607 typedef typename _Traits::char_type value_type;
2608 typedef _Alloc allocator_type;
2609 typedef typename _CharT_alloc_type::size_type size_type;
2610 typedef typename _CharT_alloc_type::difference_type difference_type;
2611 typedef typename _CharT_alloc_type::reference reference;
2612 typedef typename _CharT_alloc_type::const_reference const_reference;
2613 typedef typename _CharT_alloc_type::pointer pointer;
2614 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2615 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2616 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2638 size_type _M_length;
2639 size_type _M_capacity;
2640 _Atomic_word _M_refcount;
2643 struct _Rep : _Rep_base
2646 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2661 static const size_type _S_max_size;
2662 static const _CharT _S_terminal;
2666 static size_type _S_empty_rep_storage[];
2669 _S_empty_rep() _GLIBCXX_NOEXCEPT
2674 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2675 return *
reinterpret_cast<_Rep*
>(__p);
2679 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2680 {
return this->_M_refcount < 0; }
2683 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2684 {
return this->_M_refcount > 0; }
2687 _M_set_leaked() _GLIBCXX_NOEXCEPT
2688 { this->_M_refcount = -1; }
2691 _M_set_sharable() _GLIBCXX_NOEXCEPT
2692 { this->_M_refcount = 0; }
2695 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2697 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2698 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2701 this->_M_set_sharable();
2702 this->_M_length = __n;
2703 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2710 _M_refdata()
throw()
2711 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2714 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2716 return (!_M_is_leaked() && __alloc1 == __alloc2)
2717 ? _M_refcopy() : _M_clone(__alloc1);
2722 _S_create(size_type, size_type,
const _Alloc&);
2725 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2727 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2728 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2732 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2733 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2736 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2743 _M_destroy(
const _Alloc&)
throw();
2746 _M_refcopy()
throw()
2748 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2749 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2751 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2752 return _M_refdata();
2756 _M_clone(
const _Alloc&, size_type __res = 0);
2760 struct _Alloc_hider : _Alloc
2762 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2763 : _Alloc(__a), _M_p(__dat) { }
2773 static const size_type
npos =
static_cast<size_type
>(-1);
2777 mutable _Alloc_hider _M_dataplus;
2780 _M_data() const _GLIBCXX_NOEXCEPT
2781 {
return _M_dataplus._M_p; }
2784 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2785 {
return (_M_dataplus._M_p = __p); }
2788 _M_rep() const _GLIBCXX_NOEXCEPT
2789 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2794 _M_ibegin() const _GLIBCXX_NOEXCEPT
2795 {
return iterator(_M_data()); }
2798 _M_iend() const _GLIBCXX_NOEXCEPT
2799 {
return iterator(_M_data() + this->
size()); }
2804 if (!_M_rep()->_M_is_leaked())
2809 _M_check(size_type __pos,
const char* __s)
const 2811 if (__pos > this->
size())
2812 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2813 "this->size() (which is %zu)"),
2814 __s, __pos, this->
size());
2819 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2822 __throw_length_error(__N(__s));
2827 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2829 const bool __testoff = __off < this->
size() - __pos;
2830 return __testoff ? __off : this->
size() - __pos;
2835 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2837 return (less<const _CharT*>()(__s, _M_data())
2838 || less<const _CharT*>()(_M_data() + this->
size(), __s));
2844 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2847 traits_type::assign(*__d, *__s);
2849 traits_type::copy(__d, __s, __n);
2853 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2856 traits_type::assign(*__d, *__s);
2858 traits_type::move(__d, __s, __n);
2862 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2865 traits_type::assign(*__d, __c);
2867 traits_type::assign(__d, __n, __c);
2872 template<
class _Iterator>
2874 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2876 for (; __k1 != __k2; ++__k1, ++__p)
2877 traits_type::assign(*__p, *__k1);
2881 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2882 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2885 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2887 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2890 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2891 { _M_copy(__p, __k1, __k2 - __k1); }
2894 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2896 { _M_copy(__p, __k1, __k2 - __k1); }
2899 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2901 const difference_type __d = difference_type(__n1 - __n2);
2903 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2904 return __gnu_cxx::__numeric_traits<int>::__max;
2905 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2906 return __gnu_cxx::__numeric_traits<int>::__min;
2912 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2918 _S_empty_rep() _GLIBCXX_NOEXCEPT
2919 {
return _Rep::_S_empty_rep(); }
2930 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2931 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2933 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2955 size_type __n =
npos);
2964 size_type __n,
const _Alloc& __a);
2976 const _Alloc& __a = _Alloc());
2982 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2989 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2991 #if __cplusplus >= 201103L 3000 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3003 : _M_dataplus(__str._M_dataplus)
3005 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3006 __str._M_data(_S_empty_rep()._M_refdata());
3008 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3026 template<
class _InputIterator>
3027 basic_string(_InputIterator __beg, _InputIterator __end,
3028 const _Alloc& __a = _Alloc());
3042 {
return this->
assign(__str); }
3050 {
return this->
assign(__s); }
3066 #if __cplusplus >= 201103L 3090 this->
assign(__l.begin(), __l.size());
3104 return iterator(_M_data());
3113 {
return const_iterator(_M_data()); }
3123 return iterator(_M_data() + this->
size());
3132 {
return const_iterator(_M_data() + this->
size()); }
3148 const_reverse_iterator
3166 const_reverse_iterator
3170 #if __cplusplus >= 201103L 3177 {
return const_iterator(this->_M_data()); }
3185 {
return const_iterator(this->_M_data() + this->
size()); }
3192 const_reverse_iterator
3201 const_reverse_iterator
3212 {
return _M_rep()->_M_length; }
3218 {
return _M_rep()->_M_length; }
3223 {
return _Rep::_S_max_size; }
3236 resize(size_type __n, _CharT __c);
3250 { this->
resize(__n, _CharT()); }
3252 #if __cplusplus >= 201103L 3257 #if __cpp_exceptions 3275 {
return _M_rep()->_M_capacity; }
3295 reserve(size_type __res_arg = 0);
3303 { _M_mutate(0, this->
size(), 0); }
3311 {
return this->
size() == 0; }
3327 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3328 return _M_data()[__pos];
3346 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3348 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3350 return _M_data()[__pos];
3366 if (__n >= this->
size())
3367 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3368 "(which is %zu) >= this->size() " 3371 return _M_data()[__n];
3389 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3390 "(which is %zu) >= this->size() " 3394 return _M_data()[__n];
3397 #if __cplusplus >= 201103L 3439 {
return this->
append(__str); }
3448 {
return this->
append(__s); }
3462 #if __cplusplus >= 201103L 3470 {
return this->
append(__l.begin(), __l.size()); }
3504 append(
const _CharT* __s, size_type __n);
3514 __glibcxx_requires_string(__s);
3515 return this->
append(__s, traits_type::length(__s));
3527 append(size_type __n, _CharT __c);
3529 #if __cplusplus >= 201103L 3537 {
return this->
append(__l.begin(), __l.size()); }
3548 template<
class _InputIterator>
3550 append(_InputIterator __first, _InputIterator __last)
3551 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3560 const size_type __len = 1 + this->
size();
3561 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3563 traits_type::assign(_M_data()[this->
size()], __c);
3564 _M_rep()->_M_set_length_and_sharable(__len);
3575 #if __cplusplus >= 201103L 3608 {
return this->
assign(__str._M_data()
3609 + __str._M_check(__pos,
"basic_string::assign"),
3610 __str._M_limit(__pos, __n)); }
3623 assign(
const _CharT* __s, size_type __n);
3637 __glibcxx_requires_string(__s);
3638 return this->
assign(__s, traits_type::length(__s));
3652 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3662 template<
class _InputIterator>
3664 assign(_InputIterator __first, _InputIterator __last)
3665 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3667 #if __cplusplus >= 201103L 3675 {
return this->
assign(__l.begin(), __l.size()); }
3692 insert(iterator __p, size_type __n, _CharT __c)
3693 { this->
replace(__p, __p, __n, __c); }
3707 template<
class _InputIterator>
3709 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3710 { this->
replace(__p, __p, __beg, __end); }
3712 #if __cplusplus >= 201103L 3722 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3723 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3741 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3763 size_type __pos2, size_type __n)
3764 {
return this->
insert(__pos1, __str._M_data()
3765 + __str._M_check(__pos2,
"basic_string::insert"),
3766 __str._M_limit(__pos2, __n)); }
3785 insert(size_type __pos,
const _CharT* __s, size_type __n);
3805 __glibcxx_requires_string(__s);
3806 return this->
insert(__pos, __s, traits_type::length(__s));
3826 insert(size_type __pos, size_type __n, _CharT __c)
3827 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3828 size_type(0), __n, __c); }
3846 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3847 const size_type __pos = __p - _M_ibegin();
3848 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3849 _M_rep()->_M_set_leaked();
3850 return iterator(_M_data() + __pos);
3871 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3872 _M_limit(__pos, __n), size_type(0));
3887 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3888 && __position < _M_iend());
3889 const size_type __pos = __position - _M_ibegin();
3890 _M_mutate(__pos, size_type(1), size_type(0));
3891 _M_rep()->_M_set_leaked();
3892 return iterator(_M_data() + __pos);
3907 #if __cplusplus >= 201103L 3937 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3959 size_type __pos2, size_type __n2)
3960 {
return this->
replace(__pos1, __n1, __str._M_data()
3961 + __str._M_check(__pos2,
"basic_string::replace"),
3962 __str._M_limit(__pos2, __n2)); }
3983 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4003 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4005 __glibcxx_requires_string(__s);
4006 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4027 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4028 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4029 _M_limit(__pos, __n1), __n2, __c); }
4046 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4064 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4066 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4067 && __i2 <= _M_iend());
4068 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4085 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4087 __glibcxx_requires_string(__s);
4088 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4106 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4108 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4109 && __i2 <= _M_iend());
4110 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4128 template<
class _InputIterator>
4131 _InputIterator __k1, _InputIterator __k2)
4133 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4134 && __i2 <= _M_iend());
4135 __glibcxx_requires_valid_range(__k1, __k2);
4136 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4137 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4145 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4146 && __i2 <= _M_iend());
4147 __glibcxx_requires_valid_range(__k1, __k2);
4148 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4153 replace(iterator __i1, iterator __i2,
4154 const _CharT* __k1,
const _CharT* __k2)
4156 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4157 && __i2 <= _M_iend());
4158 __glibcxx_requires_valid_range(__k1, __k2);
4159 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4164 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4166 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4167 && __i2 <= _M_iend());
4168 __glibcxx_requires_valid_range(__k1, __k2);
4169 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4170 __k1.base(), __k2 - __k1);
4174 replace(iterator __i1, iterator __i2,
4175 const_iterator __k1, const_iterator __k2)
4177 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4178 && __i2 <= _M_iend());
4179 __glibcxx_requires_valid_range(__k1, __k2);
4180 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4181 __k1.base(), __k2 - __k1);
4184 #if __cplusplus >= 201103L 4201 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4205 template<
class _Integer>
4208 _Integer __val, __true_type)
4209 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4211 template<
class _InputIterator>
4213 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4214 _InputIterator __k2, __false_type);
4217 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4221 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4226 template<
class _InIterator>
4228 _S_construct_aux(_InIterator __beg, _InIterator __end,
4229 const _Alloc& __a, __false_type)
4231 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4232 return _S_construct(__beg, __end, __a, _Tag());
4237 template<
class _Integer>
4239 _S_construct_aux(_Integer __beg, _Integer __end,
4240 const _Alloc& __a, __true_type)
4241 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4245 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4246 {
return _S_construct(__req, __c, __a); }
4248 template<
class _InIterator>
4250 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4252 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4253 return _S_construct_aux(__beg, __end, __a, _Integral());
4257 template<
class _InIterator>
4259 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4260 input_iterator_tag);
4264 template<
class _FwdIterator>
4266 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4267 forward_iterator_tag);
4270 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4287 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4309 {
return _M_data(); }
4319 {
return _M_data(); }
4326 {
return _M_dataplus; }
4341 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4356 {
return this->
find(__str.data(), __pos, __str.size()); }
4369 find(
const _CharT* __s, size_type __pos = 0)
const 4371 __glibcxx_requires_string(__s);
4372 return this->
find(__s, __pos, traits_type::length(__s));
4386 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
4401 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4416 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4431 __glibcxx_requires_string(__s);
4432 return this->
rfind(__s, __pos, traits_type::length(__s));
4446 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
4462 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4477 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4492 __glibcxx_requires_string(__s);
4493 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4510 {
return this->
find(__c, __pos); }
4526 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4541 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4556 __glibcxx_requires_string(__s);
4557 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4574 {
return this->
rfind(__c, __pos); }
4605 size_type __n)
const;
4620 __glibcxx_requires_string(__s);
4668 size_type __n)
const;
4683 __glibcxx_requires_string(__s);
4716 _M_check(__pos,
"basic_string::substr"), __n); }
4735 const size_type __size = this->
size();
4736 const size_type __osize = __str.size();
4737 const size_type __len =
std::min(__size, __osize);
4739 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4741 __r = _S_compare(__size, __osize);
4792 size_type __pos2, size_type __n2)
const;
4809 compare(
const _CharT* __s)
const;
4833 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4860 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4861 size_type __n2)
const;
4863 #endif // !_GLIBCXX_USE_CXX11_ABI 4872 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4873 basic_string<_CharT, _Traits, _Alloc>
4878 __str.append(__rhs);
4888 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4889 basic_string<_CharT,_Traits,_Alloc>
4891 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4899 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4900 basic_string<_CharT,_Traits,_Alloc>
4901 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
4909 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4910 inline basic_string<_CharT, _Traits, _Alloc>
4912 const _CharT* __rhs)
4915 __str.append(__rhs);
4925 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4926 inline basic_string<_CharT, _Traits, _Alloc>
4930 typedef typename __string_type::size_type __size_type;
4931 __string_type __str(__lhs);
4932 __str.append(__size_type(1), __rhs);
4936 #if __cplusplus >= 201103L 4937 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4938 inline basic_string<_CharT, _Traits, _Alloc>
4939 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4940 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4941 {
return std::move(__lhs.append(__rhs)); }
4943 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4944 inline basic_string<_CharT, _Traits, _Alloc>
4945 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4946 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4947 {
return std::move(__rhs.insert(0, __lhs)); }
4949 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4950 inline basic_string<_CharT, _Traits, _Alloc>
4951 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4952 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4954 const auto __size = __lhs.size() + __rhs.size();
4955 const bool __cond = (__size > __lhs.capacity()
4956 && __size <= __rhs.capacity());
4957 return __cond ? std::move(__rhs.insert(0, __lhs))
4958 : std::move(__lhs.append(__rhs));
4961 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4962 inline basic_string<_CharT, _Traits, _Alloc>
4964 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4965 {
return std::move(__rhs.insert(0, __lhs)); }
4967 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4968 inline basic_string<_CharT, _Traits, _Alloc>
4970 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
4971 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4973 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4974 inline basic_string<_CharT, _Traits, _Alloc>
4975 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4976 const _CharT* __rhs)
4977 {
return std::move(__lhs.append(__rhs)); }
4979 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4980 inline basic_string<_CharT, _Traits, _Alloc>
4981 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
4983 {
return std::move(__lhs.append(1, __rhs)); }
4993 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4998 {
return __lhs.compare(__rhs) == 0; }
5000 template<
typename _CharT>
5002 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5003 operator==(
const basic_string<_CharT>& __lhs,
5004 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
5005 {
return (__lhs.size() == __rhs.size()
5015 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5017 operator==(
const _CharT* __lhs,
5019 {
return __rhs.compare(__lhs) == 0; }
5027 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5030 const _CharT* __rhs)
5031 {
return __lhs.compare(__rhs) == 0; }
5040 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5045 {
return !(__lhs == __rhs); }
5053 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5055 operator!=(
const _CharT* __lhs,
5057 {
return !(__lhs == __rhs); }
5065 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5068 const _CharT* __rhs)
5069 {
return !(__lhs == __rhs); }
5078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5080 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5083 {
return __lhs.
compare(__rhs) < 0; }
5091 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5093 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5094 const _CharT* __rhs)
5095 {
return __lhs.compare(__rhs) < 0; }
5103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5105 operator<(
const _CharT* __lhs,
5107 {
return __rhs.compare(__lhs) > 0; }
5116 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5121 {
return __lhs.compare(__rhs) > 0; }
5129 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5132 const _CharT* __rhs)
5133 {
return __lhs.compare(__rhs) > 0; }
5141 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5143 operator>(
const _CharT* __lhs,
5145 {
return __rhs.compare(__lhs) < 0; }
5154 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5156 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5159 {
return __lhs.
compare(__rhs) <= 0; }
5167 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5169 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5170 const _CharT* __rhs)
5171 {
return __lhs.compare(__rhs) <= 0; }
5179 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5181 operator<=(
const _CharT* __lhs,
5183 {
return __rhs.compare(__lhs) >= 0; }
5192 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5197 {
return __lhs.compare(__rhs) >= 0; }
5205 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5208 const _CharT* __rhs)
5209 {
return __lhs.compare(__rhs) >= 0; }
5217 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5219 operator>=(
const _CharT* __lhs,
5221 {
return __rhs.compare(__lhs) <= 0; }
5230 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5234 #if __cplusplus >= 201103L 5235 noexcept(noexcept(__lhs.swap(__rhs)))
5237 { __lhs.swap(__rhs); }
5252 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5253 basic_istream<_CharT, _Traits>&
5254 operator>>(basic_istream<_CharT, _Traits>& __is,
5255 basic_string<_CharT, _Traits, _Alloc>& __str);
5258 basic_istream<char>&
5259 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
5270 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5271 inline basic_ostream<_CharT, _Traits>&
5272 operator<<(basic_ostream<_CharT, _Traits>& __os,
5277 return __ostream_insert(__os, __str.data(), __str.size());
5293 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5294 basic_istream<_CharT, _Traits>&
5295 getline(basic_istream<_CharT, _Traits>& __is,
5296 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
5310 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5311 inline basic_istream<_CharT, _Traits>&
5316 #if __cplusplus >= 201103L 5318 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5319 inline basic_istream<_CharT, _Traits>&
5325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5326 inline basic_istream<_CharT, _Traits>&
5333 basic_istream<char>&
5334 getline(basic_istream<char>& __in, basic_string<char>& __str,
5337 #ifdef _GLIBCXX_USE_WCHAR_T 5339 basic_istream<wchar_t>&
5340 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
5344 _GLIBCXX_END_NAMESPACE_VERSION
5347 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99) 5351 namespace std _GLIBCXX_VISIBILITY(default)
5353 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5354 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5358 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5359 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
5363 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5364 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
5367 inline unsigned long 5368 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5369 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
5373 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5374 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
5377 inline unsigned long long 5378 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5379 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
5384 stof(
const string& __str,
size_t* __idx = 0)
5385 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
5388 stod(
const string& __str,
size_t* __idx = 0)
5389 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
5392 stold(
const string& __str,
size_t* __idx = 0)
5393 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
5399 to_string(
int __val)
5400 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5404 to_string(
unsigned __val)
5405 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5406 4 *
sizeof(unsigned),
5410 to_string(
long __val)
5411 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5415 to_string(
unsigned long __val)
5416 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5417 4 *
sizeof(
unsigned long),
5421 to_string(
long long __val)
5422 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5423 4 *
sizeof(
long long),
5427 to_string(
unsigned long long __val)
5428 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5429 4 *
sizeof(
unsigned long long),
5433 to_string(
float __val)
5436 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5437 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5442 to_string(
double __val)
5445 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5446 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5451 to_string(
long double __val)
5454 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5455 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5459 #ifdef _GLIBCXX_USE_WCHAR_T 5461 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5462 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
5466 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5467 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
5470 inline unsigned long 5471 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5472 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
5476 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5477 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
5480 inline unsigned long long 5481 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5482 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
5487 stof(
const wstring& __str,
size_t* __idx = 0)
5488 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
5491 stod(
const wstring& __str,
size_t* __idx = 0)
5492 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
5495 stold(
const wstring& __str,
size_t* __idx = 0)
5496 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
5498 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5501 to_wstring(
int __val)
5502 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5506 to_wstring(
unsigned __val)
5507 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5508 4 *
sizeof(unsigned),
5512 to_wstring(
long __val)
5513 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5517 to_wstring(
unsigned long __val)
5518 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5519 4 *
sizeof(
unsigned long),
5523 to_wstring(
long long __val)
5524 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5525 4 *
sizeof(
long long),
5529 to_wstring(
unsigned long long __val)
5530 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5531 4 *
sizeof(
unsigned long long),
5535 to_wstring(
float __val)
5538 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5539 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5544 to_wstring(
double __val)
5547 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5548 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5553 to_wstring(
long double __val)
5556 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5557 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5560 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5563 _GLIBCXX_END_NAMESPACE_CXX11
5564 _GLIBCXX_END_NAMESPACE_VERSION
5569 #if __cplusplus >= 201103L 5573 namespace std _GLIBCXX_VISIBILITY(default)
5575 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5579 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5583 :
public __hash_base<size_t, string>
5586 operator()(
const string& __s)
const noexcept
5587 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5594 #ifdef _GLIBCXX_USE_WCHAR_T 5598 :
public __hash_base<size_t, wstring>
5601 operator()(
const wstring& __s)
const noexcept
5602 {
return std::_Hash_impl::hash(__s.
data(),
5603 __s.
length() *
sizeof(wchar_t)); }
5612 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5616 :
public __hash_base<size_t, u16string>
5619 operator()(
const u16string& __s)
const noexcept
5620 {
return std::_Hash_impl::hash(__s.
data(),
5621 __s.
length() *
sizeof(char16_t)); }
5631 :
public __hash_base<size_t, u32string>
5634 operator()(
const u32string& __s)
const noexcept
5635 {
return std::_Hash_impl::hash(__s.
data(),
5636 __s.
length() *
sizeof(char32_t)); }
5644 _GLIBCXX_END_NAMESPACE_VERSION
5646 #if __cplusplus > 201103L 5648 #define __cpp_lib_string_udls 201304 5650 inline namespace literals
5652 inline namespace string_literals
5654 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5656 _GLIBCXX_DEFAULT_ABI_TAG
5657 inline basic_string<char>
5658 operator""s(
const char* __str,
size_t __len)
5659 {
return basic_string<char>{__str, __len}; }
5661 #ifdef _GLIBCXX_USE_WCHAR_T 5662 _GLIBCXX_DEFAULT_ABI_TAG
5663 inline basic_string<wchar_t>
5664 operator""s(
const wchar_t* __str,
size_t __len)
5665 {
return basic_string<wchar_t>{__str, __len}; }
5668 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5669 _GLIBCXX_DEFAULT_ABI_TAG
5670 inline basic_string<char16_t>
5671 operator""s(
const char16_t* __str,
size_t __len)
5672 {
return basic_string<char16_t>{__str, __len}; }
5674 _GLIBCXX_DEFAULT_ABI_TAG
5675 inline basic_string<char32_t>
5676 operator""s(
const char32_t* __str,
size_t __len)
5677 {
return basic_string<char32_t>{__str, __len}; }
5680 _GLIBCXX_END_NAMESPACE_VERSION
5684 #endif // __cplusplus > 201103L bool empty() const noexcept
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
Uniform interface to all pointer-like types.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & append(const _CharT *__s)
Append a C string.
const_reverse_iterator crbegin() const noexcept
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
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.
const_iterator cend() const noexcept
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const_iterator cbegin() const noexcept
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string< wchar_t > wstring
A string of wchar_t.
const_reverse_iterator rend() const noexcept
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string & append(const basic_string &__str)
Append a string to this string.
reverse_iterator rbegin()
Uniform interface to C++98 and C++0x allocators.
iterator erase(iterator __position)
Remove one character.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
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.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
ISO C++ entities toplevel namespace is std.
const_iterator begin() const noexcept
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
Basis for explicit traits specializations.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
void pop_back()
Remove the last character.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string()
Default constructor creates an empty string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
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 _CharT *__s)
Replace range of characters with C string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type capacity() const noexcept
Template class basic_istream.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
Primary class template hash.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
int compare(const basic_string &__str) const
Compare to a string.
const_reference front() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
const_iterator end() const noexcept
void insert(iterator __p, initializer_list< _CharT > __l)
Insert 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_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
void push_back(_CharT __c)
Append a single character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
Managing sequences of characters and character-like objects.
void resize(size_type __n)
Resizes the string to the specified number of characters.
Forward iterators support a superset of input iterator operations.
const_reference back() const noexcept
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.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
basic_string & operator+=(_CharT __c)
Append a character.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
iterator insert(iterator __p, _CharT __c)
Insert one character.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(const basic_string &__str)
Set value to contents of another 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_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
~basic_string() noexcept
Destroy the string instance.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a 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 & operator+=(const _CharT *__s)
Append a C string.
char_type widen(char __c) const
Widens characters.
reference at(size_type __n)
Provides access to the data contained in the string.
static const size_type npos
Value returned by various member functions when they fail.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.