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));
427 basic_string(
const basic_string& __str, size_type __pos,
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()); }
508 basic_string(
const basic_string& __str,
const _Alloc& __a)
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()); }
1072 append(
const basic_string& __str)
1073 {
return _M_append(__str._M_data(), __str.size()); }
1089 append(
const basic_string& __str, size_type __pos, size_type __n)
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);
1183 assign(
const basic_string& __str)
1185 this->_M_assign(__str);
1189 #if __cplusplus >= 201103L 1199 assign(basic_string&& __str)
1200 noexcept(_Alloc_traits::_S_nothrow_move())
1204 return *
this = std::move(__str);
1222 assign(
const basic_string& __str, size_type __pos, size_type __n)
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());
1418 insert(size_type __pos1,
const basic_string& __str)
1419 {
return this->
replace(__pos1, size_type(0),
1420 __str._M_data(), __str.size()); }
1441 insert(size_type __pos1,
const basic_string& __str,
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); }
1622 replace(size_type __pos, size_type __n,
const basic_string& __str)
1623 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1644 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
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,
1737 const basic_string& __str)
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 1914 basic_string&
replace(const_iterator __i1, const_iterator __i2,
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;
1968 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
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;
2024 find(
const basic_string& __str, size_type __pos = 0) 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;
2069 rfind(const basic_string& __str, size_type __pos = npos) const
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;
2130 find_first_of(
const basic_string& __str, size_type __pos = 0) const
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); }
2194 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 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;
2224 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2226 __glibcxx_requires_string(__s);
2227 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2243 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
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); }
2403 compare(
const basic_string& __str)
const 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);
2435 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2461 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
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;
2534 template<
typename,
typename,
typename>
friend class basic_stringbuf;
2536 _GLIBCXX_END_NAMESPACE_CXX11
2537 #else // !_GLIBCXX_USE_CXX11_ABI 2602 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2605 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2609 typedef _Traits traits_type;
2610 typedef typename _Traits::char_type value_type;
2611 typedef _Alloc allocator_type;
2612 typedef typename _CharT_alloc_type::size_type size_type;
2613 typedef typename _CharT_alloc_type::difference_type difference_type;
2614 typedef typename _CharT_alloc_type::reference reference;
2615 typedef typename _CharT_alloc_type::const_reference const_reference;
2616 typedef typename _CharT_alloc_type::pointer pointer;
2617 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2618 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2619 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2641 size_type _M_length;
2642 size_type _M_capacity;
2643 _Atomic_word _M_refcount;
2646 struct _Rep : _Rep_base
2649 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2664 static const size_type _S_max_size;
2665 static const _CharT _S_terminal;
2669 static size_type _S_empty_rep_storage[];
2672 _S_empty_rep() _GLIBCXX_NOEXCEPT
2677 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2678 return *
reinterpret_cast<_Rep*
>(__p);
2682 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2683 {
return this->_M_refcount < 0; }
2686 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2687 {
return this->_M_refcount > 0; }
2690 _M_set_leaked() _GLIBCXX_NOEXCEPT
2691 { this->_M_refcount = -1; }
2694 _M_set_sharable() _GLIBCXX_NOEXCEPT
2695 { this->_M_refcount = 0; }
2698 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2700 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2701 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2704 this->_M_set_sharable();
2705 this->_M_length = __n;
2706 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2713 _M_refdata()
throw()
2714 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2717 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2719 return (!_M_is_leaked() && __alloc1 == __alloc2)
2720 ? _M_refcopy() : _M_clone(__alloc1);
2725 _S_create(size_type, size_type,
const _Alloc&);
2728 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2730 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2731 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2735 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2736 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2739 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2746 _M_destroy(
const _Alloc&)
throw();
2749 _M_refcopy()
throw()
2751 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2752 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2754 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2755 return _M_refdata();
2759 _M_clone(
const _Alloc&, size_type __res = 0);
2763 struct _Alloc_hider : _Alloc
2765 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2766 : _Alloc(__a), _M_p(__dat) { }
2776 static const size_type npos =
static_cast<size_type
>(-1);
2780 mutable _Alloc_hider _M_dataplus;
2783 _M_data() const _GLIBCXX_NOEXCEPT
2784 {
return _M_dataplus._M_p; }
2787 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2788 {
return (_M_dataplus._M_p = __p); }
2791 _M_rep()
const _GLIBCXX_NOEXCEPT
2792 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2797 _M_ibegin()
const _GLIBCXX_NOEXCEPT
2798 {
return iterator(_M_data()); }
2801 _M_iend()
const _GLIBCXX_NOEXCEPT
2802 {
return iterator(_M_data() + this->
size()); }
2807 if (!_M_rep()->_M_is_leaked())
2812 _M_check(size_type __pos,
const char* __s)
const 2814 if (__pos > this->
size())
2815 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2816 "this->size() (which is %zu)"),
2817 __s, __pos, this->
size());
2822 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2825 __throw_length_error(__N(__s));
2830 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2832 const bool __testoff = __off < this->
size() - __pos;
2833 return __testoff ? __off : this->
size() - __pos;
2838 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2847 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2850 traits_type::assign(*__d, *__s);
2852 traits_type::copy(__d, __s, __n);
2856 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2859 traits_type::assign(*__d, *__s);
2861 traits_type::move(__d, __s, __n);
2865 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2868 traits_type::assign(*__d, __c);
2870 traits_type::assign(__d, __n, __c);
2875 template<
class _Iterator>
2877 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2879 for (; __k1 != __k2; ++__k1, ++__p)
2880 traits_type::assign(*__p, *__k1);
2884 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2885 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2888 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2890 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2893 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2894 { _M_copy(__p, __k1, __k2 - __k1); }
2897 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2899 { _M_copy(__p, __k1, __k2 - __k1); }
2902 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2904 const difference_type __d = difference_type(__n1 - __n2);
2906 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2907 return __gnu_cxx::__numeric_traits<int>::__max;
2908 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2909 return __gnu_cxx::__numeric_traits<int>::__min;
2915 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2921 _S_empty_rep() _GLIBCXX_NOEXCEPT
2922 {
return _Rep::_S_empty_rep(); }
2933 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2934 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2936 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2957 basic_string(
const basic_string& __str, size_type __pos,
2958 size_type __n = npos);
2966 basic_string(
const basic_string& __str, size_type __pos,
2967 size_type __n,
const _Alloc& __a);
2979 const _Alloc& __a = _Alloc());
2985 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2992 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2994 #if __cplusplus >= 201103L 3003 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3006 : _M_dataplus(__str._M_dataplus)
3008 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3009 __str._M_data(_S_empty_rep()._M_refdata());
3011 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3029 template<
class _InputIterator>
3030 basic_string(_InputIterator __beg, _InputIterator __end,
3031 const _Alloc& __a = _Alloc());
3045 {
return this->
assign(__str); }
3053 {
return this->
assign(__s); }
3069 #if __cplusplus >= 201103L 3093 this->
assign(__l.begin(), __l.size());
3107 return iterator(_M_data());
3116 {
return const_iterator(_M_data()); }
3126 return iterator(_M_data() + this->
size());
3135 {
return const_iterator(_M_data() + this->
size()); }
3144 {
return reverse_iterator(this->
end()); }
3151 const_reverse_iterator
3153 {
return const_reverse_iterator(this->
end()); }
3162 {
return reverse_iterator(this->
begin()); }
3169 const_reverse_iterator
3171 {
return const_reverse_iterator(this->
begin()); }
3173 #if __cplusplus >= 201103L 3180 {
return const_iterator(this->_M_data()); }
3188 {
return const_iterator(this->_M_data() + this->
size()); }
3195 const_reverse_iterator
3197 {
return const_reverse_iterator(this->
end()); }
3204 const_reverse_iterator
3206 {
return const_reverse_iterator(this->
begin()); }
3215 {
return _M_rep()->_M_length; }
3221 {
return _M_rep()->_M_length; }
3226 {
return _Rep::_S_max_size; }
3239 resize(size_type __n, _CharT __c);
3253 { this->
resize(__n, _CharT()); }
3255 #if __cplusplus >= 201103L 3260 #if __cpp_exceptions 3278 {
return _M_rep()->_M_capacity; }
3298 reserve(size_type __res_arg = 0);
3306 { _M_mutate(0, this->
size(), 0); }
3314 {
return this->
size() == 0; }
3330 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3331 return _M_data()[__pos];
3349 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3351 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3353 return _M_data()[__pos];
3369 if (__n >= this->
size())
3370 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3371 "(which is %zu) >= this->size() " 3374 return _M_data()[__n];
3392 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3393 "(which is %zu) >= this->size() " 3397 return _M_data()[__n];
3400 #if __cplusplus >= 201103L 3442 {
return this->
append(__str); }
3451 {
return this->
append(__s); }
3465 #if __cplusplus >= 201103L 3473 {
return this->
append(__l.begin(), __l.size()); }
3482 append(
const basic_string& __str);
3498 append(
const basic_string& __str, size_type __pos, size_type __n);
3507 append(
const _CharT* __s, size_type __n);
3517 __glibcxx_requires_string(__s);
3518 return this->
append(__s, traits_type::length(__s));
3530 append(size_type __n, _CharT __c);
3532 #if __cplusplus >= 201103L 3540 {
return this->
append(__l.begin(), __l.size()); }
3551 template<
class _InputIterator>
3553 append(_InputIterator __first, _InputIterator __last)
3554 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3563 const size_type __len = 1 + this->
size();
3564 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3566 traits_type::assign(_M_data()[this->
size()], __c);
3567 _M_rep()->_M_set_length_and_sharable(__len);
3576 assign(
const basic_string& __str);
3578 #if __cplusplus >= 201103L 3610 assign(
const basic_string& __str, size_type __pos, size_type __n)
3611 {
return this->
assign(__str._M_data()
3612 + __str._M_check(__pos,
"basic_string::assign"),
3613 __str._M_limit(__pos, __n)); }
3626 assign(
const _CharT* __s, size_type __n);
3640 __glibcxx_requires_string(__s);
3641 return this->
assign(__s, traits_type::length(__s));
3655 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3665 template<
class _InputIterator>
3667 assign(_InputIterator __first, _InputIterator __last)
3668 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3670 #if __cplusplus >= 201103L 3678 {
return this->
assign(__l.begin(), __l.size()); }
3695 insert(iterator __p, size_type __n, _CharT __c)
3696 { this->
replace(__p, __p, __n, __c); }
3710 template<
class _InputIterator>
3712 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3713 { this->
replace(__p, __p, __beg, __end); }
3715 #if __cplusplus >= 201103L 3725 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3726 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3743 insert(size_type __pos1,
const basic_string& __str)
3744 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3765 insert(size_type __pos1,
const basic_string& __str,
3766 size_type __pos2, size_type __n)
3767 {
return this->
insert(__pos1, __str._M_data()
3768 + __str._M_check(__pos2,
"basic_string::insert"),
3769 __str._M_limit(__pos2, __n)); }
3788 insert(size_type __pos,
const _CharT* __s, size_type __n);
3808 __glibcxx_requires_string(__s);
3809 return this->
insert(__pos, __s, traits_type::length(__s));
3829 insert(size_type __pos, size_type __n, _CharT __c)
3830 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3831 size_type(0), __n, __c); }
3849 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3850 const size_type __pos = __p - _M_ibegin();
3851 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3852 _M_rep()->_M_set_leaked();
3853 return iterator(_M_data() + __pos);
3872 erase(size_type __pos = 0, size_type __n = npos)
3874 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3875 _M_limit(__pos, __n), size_type(0));
3890 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3891 && __position < _M_iend());
3892 const size_type __pos = __position - _M_ibegin();
3893 _M_mutate(__pos, size_type(1), size_type(0));
3894 _M_rep()->_M_set_leaked();
3895 return iterator(_M_data() + __pos);
3908 erase(iterator __first, iterator __last);
3910 #if __cplusplus >= 201103L 3939 replace(size_type __pos, size_type __n,
const basic_string& __str)
3940 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3961 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
3962 size_type __pos2, size_type __n2)
3963 {
return this->
replace(__pos1, __n1, __str._M_data()
3964 + __str._M_check(__pos2,
"basic_string::replace"),
3965 __str._M_limit(__pos2, __n2)); }
3986 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4006 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4008 __glibcxx_requires_string(__s);
4009 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4030 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4031 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4032 _M_limit(__pos, __n1), __n2, __c); }
4048 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4049 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4067 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4069 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4070 && __i2 <= _M_iend());
4071 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4088 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4090 __glibcxx_requires_string(__s);
4091 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4109 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4111 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4112 && __i2 <= _M_iend());
4113 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4131 template<
class _InputIterator>
4134 _InputIterator __k1, _InputIterator __k2)
4136 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4137 && __i2 <= _M_iend());
4138 __glibcxx_requires_valid_range(__k1, __k2);
4139 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4140 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4146 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4148 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4149 && __i2 <= _M_iend());
4150 __glibcxx_requires_valid_range(__k1, __k2);
4151 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4156 replace(iterator __i1, iterator __i2,
4157 const _CharT* __k1,
const _CharT* __k2)
4159 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4160 && __i2 <= _M_iend());
4161 __glibcxx_requires_valid_range(__k1, __k2);
4162 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4167 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4169 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4170 && __i2 <= _M_iend());
4171 __glibcxx_requires_valid_range(__k1, __k2);
4172 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4173 __k1.base(), __k2 - __k1);
4177 replace(iterator __i1, iterator __i2,
4178 const_iterator __k1, const_iterator __k2)
4180 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4181 && __i2 <= _M_iend());
4182 __glibcxx_requires_valid_range(__k1, __k2);
4183 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4184 __k1.base(), __k2 - __k1);
4187 #if __cplusplus >= 201103L 4202 basic_string&
replace(iterator __i1, iterator __i2,
4204 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4208 template<
class _Integer>
4210 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4211 _Integer __val, __true_type)
4212 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4214 template<
class _InputIterator>
4216 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4217 _InputIterator __k2, __false_type);
4220 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4224 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4229 template<
class _InIterator>
4231 _S_construct_aux(_InIterator __beg, _InIterator __end,
4232 const _Alloc& __a, __false_type)
4234 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4235 return _S_construct(__beg, __end, __a, _Tag());
4240 template<
class _Integer>
4242 _S_construct_aux(_Integer __beg, _Integer __end,
4243 const _Alloc& __a, __true_type)
4244 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4248 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4249 {
return _S_construct(__req, __c, __a); }
4251 template<
class _InIterator>
4253 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4255 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4256 return _S_construct_aux(__beg, __end, __a, _Integral());
4260 template<
class _InIterator>
4262 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4267 template<
class _FwdIterator>
4269 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4273 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4290 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4301 swap(basic_string& __s);
4312 {
return _M_data(); }
4322 {
return _M_data(); }
4329 {
return _M_dataplus; }
4344 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4357 find(
const basic_string& __str, size_type __pos = 0) const
4359 {
return this->
find(__str.data(), __pos, __str.size()); }
4372 find(
const _CharT* __s, size_type __pos = 0)
const 4374 __glibcxx_requires_string(__s);
4375 return this->
find(__s, __pos, traits_type::length(__s));
4389 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4402 rfind(
const basic_string& __str, size_type __pos = npos)
const 4404 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4419 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4432 rfind(
const _CharT* __s, size_type __pos = npos)
const 4434 __glibcxx_requires_string(__s);
4435 return this->
rfind(__s, __pos, traits_type::length(__s));
4449 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4465 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4480 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4495 __glibcxx_requires_string(__s);
4496 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4513 {
return this->
find(__c, __pos); }
4529 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4544 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4559 __glibcxx_requires_string(__s);
4560 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4577 {
return this->
rfind(__c, __pos); }
4608 size_type __n)
const;
4623 __glibcxx_requires_string(__s);
4671 size_type __n)
const;
4686 __glibcxx_requires_string(__s);
4717 substr(size_type __pos = 0, size_type __n = npos)
const 4719 _M_check(__pos,
"basic_string::substr"), __n); }
4738 const size_type __size = this->
size();
4739 const size_type __osize = __str.size();
4740 const size_type __len =
std::min(__size, __osize);
4742 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4744 __r = _S_compare(__size, __osize);
4768 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
4794 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
4795 size_type __pos2, size_type __n2)
const;
4812 compare(
const _CharT* __s)
const;
4836 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4863 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4864 size_type __n2)
const;
4866 #endif // !_GLIBCXX_USE_CXX11_ABI 4875 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4881 __str.append(__rhs);
4891 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4902 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4912 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4915 const _CharT* __rhs)
4918 __str.append(__rhs);
4928 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4933 typedef typename __string_type::size_type __size_type;
4934 __string_type __str(__lhs);
4935 __str.append(__size_type(1), __rhs);
4939 #if __cplusplus >= 201103L 4940 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4944 {
return std::move(__lhs.append(__rhs)); }
4946 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4950 {
return std::move(__rhs.insert(0, __lhs)); }
4952 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4957 const auto __size = __lhs.size() + __rhs.size();
4958 const bool __cond = (__size > __lhs.capacity()
4959 && __size <= __rhs.capacity());
4960 return __cond ? std::move(__rhs.insert(0, __lhs))
4961 : std::move(__lhs.append(__rhs));
4964 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4968 {
return std::move(__rhs.insert(0, __lhs)); }
4970 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4974 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4976 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4979 const _CharT* __rhs)
4980 {
return std::move(__lhs.append(__rhs)); }
4982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4986 {
return std::move(__lhs.append(1, __rhs)); }
4996 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5001 {
return __lhs.compare(__rhs) == 0; }
5003 template<
typename _CharT>
5005 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5008 {
return (__lhs.
size() == __rhs.
size()
5018 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5020 operator==(
const _CharT* __lhs,
5022 {
return __rhs.compare(__lhs) == 0; }
5030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5033 const _CharT* __rhs)
5034 {
return __lhs.compare(__rhs) == 0; }
5043 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5048 {
return !(__lhs == __rhs); }
5056 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5058 operator!=(
const _CharT* __lhs,
5060 {
return !(__lhs == __rhs); }
5068 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5071 const _CharT* __rhs)
5072 {
return !(__lhs == __rhs); }
5081 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5083 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5086 {
return __lhs.
compare(__rhs) < 0; }
5094 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5096 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5097 const _CharT* __rhs)
5098 {
return __lhs.
compare(__rhs) < 0; }
5106 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5108 operator<(
const _CharT* __lhs,
5110 {
return __rhs.compare(__lhs) > 0; }
5119 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5124 {
return __lhs.compare(__rhs) > 0; }
5132 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5135 const _CharT* __rhs)
5136 {
return __lhs.compare(__rhs) > 0; }
5144 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5146 operator>(
const _CharT* __lhs,
5148 {
return __rhs.compare(__lhs) < 0; }
5157 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5159 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5162 {
return __lhs.
compare(__rhs) <= 0; }
5170 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5172 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5173 const _CharT* __rhs)
5174 {
return __lhs.
compare(__rhs) <= 0; }
5182 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5184 operator<=(
const _CharT* __lhs,
5186 {
return __rhs.compare(__lhs) >= 0; }
5195 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5200 {
return __lhs.compare(__rhs) >= 0; }
5208 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5211 const _CharT* __rhs)
5212 {
return __lhs.compare(__rhs) >= 0; }
5220 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5222 operator>=(
const _CharT* __lhs,
5224 {
return __rhs.compare(__lhs) <= 0; }
5233 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5237 #if __cplusplus >= 201103L 5238 noexcept(noexcept(__lhs.swap(__rhs)))
5240 { __lhs.swap(__rhs); }
5255 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5273 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5275 operator<<(basic_ostream<_CharT, _Traits>& __os,
5280 return __ostream_insert(__os, __str.
data(), __str.
size());
5296 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5313 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5319 #if __cplusplus >= 201103L 5321 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5328 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5340 #ifdef _GLIBCXX_USE_WCHAR_T 5347 _GLIBCXX_END_NAMESPACE_VERSION
5350 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99) 5354 namespace std _GLIBCXX_VISIBILITY(default)
5356 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5357 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5361 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5362 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5366 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5367 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5370 inline unsigned long 5371 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5372 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5376 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5377 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5380 inline unsigned long long 5381 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5382 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5387 stof(
const string& __str,
size_t* __idx = 0)
5388 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5391 stod(
const string& __str,
size_t* __idx = 0)
5392 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5395 stold(
const string& __str,
size_t* __idx = 0)
5396 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5402 to_string(
int __val)
5403 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5407 to_string(
unsigned __val)
5408 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5409 4 *
sizeof(unsigned),
5413 to_string(
long __val)
5414 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5418 to_string(
unsigned long __val)
5419 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5420 4 *
sizeof(
unsigned long),
5424 to_string(
long long __val)
5425 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5426 4 *
sizeof(
long long),
5430 to_string(
unsigned long long __val)
5431 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5432 4 *
sizeof(
unsigned long long),
5436 to_string(
float __val)
5439 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5440 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5445 to_string(
double __val)
5448 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5449 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5454 to_string(
long double __val)
5457 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5458 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5462 #ifdef _GLIBCXX_USE_WCHAR_T 5464 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5465 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5469 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5470 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5473 inline unsigned long 5474 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5475 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5479 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5480 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5483 inline unsigned long long 5484 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5485 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5490 stof(
const wstring& __str,
size_t* __idx = 0)
5491 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5494 stod(
const wstring& __str,
size_t* __idx = 0)
5495 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5498 stold(
const wstring& __str,
size_t* __idx = 0)
5499 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5501 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5504 to_wstring(
int __val)
5505 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5509 to_wstring(
unsigned __val)
5510 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5511 4 *
sizeof(unsigned),
5515 to_wstring(
long __val)
5516 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5520 to_wstring(
unsigned long __val)
5521 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5522 4 *
sizeof(
unsigned long),
5526 to_wstring(
long long __val)
5527 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5528 4 *
sizeof(
long long),
5532 to_wstring(
unsigned long long __val)
5533 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5534 4 *
sizeof(
unsigned long long),
5538 to_wstring(
float __val)
5541 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5542 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5547 to_wstring(
double __val)
5550 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5551 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5556 to_wstring(
long double __val)
5559 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5560 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5563 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5566 _GLIBCXX_END_NAMESPACE_CXX11
5567 _GLIBCXX_END_NAMESPACE_VERSION
5572 #if __cplusplus >= 201103L 5576 namespace std _GLIBCXX_VISIBILITY(default)
5578 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5582 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5586 :
public __hash_base<size_t, string>
5589 operator()(
const string& __s)
const noexcept
5590 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5597 #ifdef _GLIBCXX_USE_WCHAR_T 5601 :
public __hash_base<size_t, wstring>
5604 operator()(
const wstring& __s)
const noexcept
5605 {
return std::_Hash_impl::hash(__s.
data(),
5606 __s.
length() *
sizeof(wchar_t)); }
5615 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5619 :
public __hash_base<size_t, u16string>
5622 operator()(
const u16string& __s)
const noexcept
5623 {
return std::_Hash_impl::hash(__s.
data(),
5624 __s.
length() *
sizeof(char16_t)); }
5634 :
public __hash_base<size_t, u32string>
5637 operator()(
const u32string& __s)
const noexcept
5638 {
return std::_Hash_impl::hash(__s.
data(),
5639 __s.
length() *
sizeof(char32_t)); }
5647 _GLIBCXX_END_NAMESPACE_VERSION
5649 #if __cplusplus > 201103L 5651 #define __cpp_lib_string_udls 201304 5653 inline namespace literals
5655 inline namespace string_literals
5657 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5659 _GLIBCXX_DEFAULT_ABI_TAG
5661 operator""s(
const char* __str,
size_t __len)
5664 #ifdef _GLIBCXX_USE_WCHAR_T 5665 _GLIBCXX_DEFAULT_ABI_TAG
5667 operator""s(
const wchar_t* __str,
size_t __len)
5671 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5672 _GLIBCXX_DEFAULT_ABI_TAG
5674 operator""s(
const char16_t* __str,
size_t __len)
5677 _GLIBCXX_DEFAULT_ABI_TAG
5679 operator""s(
const char32_t* __str,
size_t __len)
5683 _GLIBCXX_END_NAMESPACE_VERSION
5687 #endif // __cplusplus > 201103L basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
const_reverse_iterator crbegin() const noexcept
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.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove 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, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_iterator cend() const noexcept
bool empty() const noexcept
Template class basic_ostream.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list 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, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
const_iterator cbegin() const noexcept
Uniform interface to all pointer-like types.
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=(_CharT __c)
Set value to string of length 1.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & append(const _CharT *__s)
Append a C string.
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.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
One of the comparison functors.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
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.
const_reverse_iterator rend() const noexcept
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
reverse_iterator rbegin()
Uniform interface to C++98 and C++0x allocators.
iterator erase(iterator __position)
Remove one character.
void pop_back()
Remove the last character.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
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.
ISO C++ entities toplevel namespace is std.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
const _CharT * data() const noexcept
Return const pointer to contents.
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_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
const_iterator begin() const noexcept
const_reference front() const noexcept
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.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
Template class basic_istream.
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.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string()
Default constructor creates an empty string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reference back() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C 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.
const_reverse_iterator crend() const noexcept
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
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 __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.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
Primary class template hash.
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.
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.
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.
Managing sequences of characters and character-like objects.
Forward iterators support a superset of input iterator operations.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & operator+=(_CharT __c)
Append a character.
char_type widen(char __c) const
Widens characters.
iterator insert(iterator __p, _CharT __c)
Insert one 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_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.