34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 #if _GLIBCXX_USE_CXX11_ABI 52 _GLIBCXX_BEGIN_NAMESPACE_CXX11
71 template<
typename _CharT,
typename _Traits,
typename _Alloc>
75 rebind<_CharT>::other _Char_alloc_type;
80 typedef _Traits traits_type;
81 typedef typename _Traits::char_type value_type;
82 typedef _Char_alloc_type allocator_type;
83 typedef typename _Alloc_traits::size_type size_type;
84 typedef typename _Alloc_traits::difference_type difference_type;
85 typedef typename _Alloc_traits::reference reference;
86 typedef typename _Alloc_traits::const_reference const_reference;
87 typedef typename _Alloc_traits::pointer pointer;
88 typedef typename _Alloc_traits::const_pointer const_pointer;
89 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
90 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
96 static const size_type
npos =
static_cast<size_type
>(-1);
100 #if __cplusplus < 201103L 101 typedef iterator __const_iterator;
103 typedef const_iterator __const_iterator;
107 struct _Alloc_hider : allocator_type
109 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
110 : allocator_type(__a), _M_p(__dat) { }
115 _Alloc_hider _M_dataplus;
116 size_type _M_string_length;
118 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
122 _CharT _M_local_buf[_S_local_capacity + 1];
123 size_type _M_allocated_capacity;
128 { _M_dataplus._M_p = __p; }
131 _M_length(size_type __length)
132 { _M_string_length = __length; }
136 {
return _M_dataplus._M_p; }
141 #if __cplusplus >= 201103L 144 return pointer(_M_local_buf);
149 _M_local_data()
const 151 #if __cplusplus >= 201103L 154 return const_pointer(_M_local_buf);
159 _M_capacity(size_type __capacity)
160 { _M_allocated_capacity = __capacity; }
163 _M_set_length(size_type __n)
166 traits_type::assign(_M_data()[__n], _CharT());
171 {
return _M_data() == _M_local_data(); }
175 _M_create(size_type&, size_type);
181 _M_destroy(_M_allocated_capacity);
185 _M_destroy(size_type __size)
throw()
186 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
190 template<
typename _InIterator>
192 _M_construct_aux(_InIterator __beg, _InIterator __end,
195 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
196 _M_construct(__beg, __end, _Tag());
201 template<
typename _Integer>
203 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
204 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
207 _M_construct_aux_2(size_type __req, _CharT __c)
208 { _M_construct(__req, __c); }
210 template<
typename _InIterator>
212 _M_construct(_InIterator __beg, _InIterator __end)
214 typedef typename std::__is_integer<_InIterator>::__type _Integral;
215 _M_construct_aux(__beg, __end, _Integral());
219 template<
typename _InIterator>
221 _M_construct(_InIterator __beg, _InIterator __end,
226 template<
typename _FwdIterator>
228 _M_construct(_FwdIterator __beg, _FwdIterator __end,
232 _M_construct(size_type __req, _CharT __c);
236 {
return _M_dataplus; }
238 const allocator_type&
239 _M_get_allocator()
const 240 {
return _M_dataplus; }
244 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 247 template<
typename _Tp,
bool _Requires =
248 !__are_same<_Tp, _CharT*>::__value
249 && !__are_same<_Tp, const _CharT*>::__value
250 && !__are_same<_Tp, iterator>::__value
251 && !__are_same<_Tp, const_iterator>::__value>
252 struct __enable_if_not_native_iterator
254 template<
typename _Tp>
255 struct __enable_if_not_native_iterator<_Tp, false> { };
259 _M_check(size_type __pos,
const char* __s)
const 261 if (__pos > this->
size())
262 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 263 "this->size() (which is %zu)"),
264 __s, __pos, this->
size());
269 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 272 __throw_length_error(__N(__s));
278 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
280 const bool __testoff = __off < this->
size() - __pos;
281 return __testoff ? __off : this->
size() - __pos;
286 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
288 return (less<const _CharT*>()(__s, _M_data())
289 || less<const _CharT*>()(_M_data() + this->
size(), __s));
295 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
298 traits_type::assign(*__d, *__s);
300 traits_type::copy(__d, __s, __n);
304 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
307 traits_type::assign(*__d, *__s);
309 traits_type::move(__d, __s, __n);
313 _S_assign(_CharT* __d, size_type __n, _CharT __c)
316 traits_type::assign(*__d, __c);
318 traits_type::assign(__d, __n, __c);
323 template<
class _Iterator>
325 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
327 for (; __k1 != __k2; ++__k1, (void)++__p)
328 traits_type::assign(*__p, *__k1);
332 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
333 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
336 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
338 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
341 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
342 { _S_copy(__p, __k1, __k2 - __k1); }
345 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
347 { _S_copy(__p, __k1, __k2 - __k1); }
350 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
352 const difference_type __d = difference_type(__n1 - __n2);
354 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
355 return __gnu_cxx::__numeric_traits<int>::__max;
356 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
357 return __gnu_cxx::__numeric_traits<int>::__min;
366 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
370 _M_erase(size_type __pos, size_type __n);
381 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
382 : _M_dataplus(_M_local_data())
383 { _M_set_length(0); }
390 : _M_dataplus(_M_local_data(), __a)
391 { _M_set_length(0); }
398 : _M_dataplus(_M_local_data(),
399 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
400 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
411 size_type __n = npos)
412 : _M_dataplus(_M_local_data())
414 const _CharT* __start = __str._M_data()
415 + __str._M_check(__pos,
"basic_string::basic_string");
416 _M_construct(__start, __start + __str._M_limit(__pos, __n));
426 basic_string(
const basic_string& __str, size_type __pos,
427 size_type __n,
const _Alloc& __a)
428 : _M_dataplus(_M_local_data(), __a)
430 const _CharT* __start
431 = __str._M_data() + __str._M_check(__pos,
"string::string");
432 _M_construct(__start, __start + __str._M_limit(__pos, __n));
445 const _Alloc& __a = _Alloc())
446 : _M_dataplus(_M_local_data(), __a)
447 { _M_construct(__s, __s + __n); }
454 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
455 : _M_dataplus(_M_local_data(), __a)
456 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
464 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
465 : _M_dataplus(_M_local_data(), __a)
466 { _M_construct(__n, __c); }
468 #if __cplusplus >= 201103L 477 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
479 if (__str._M_is_local())
481 traits_type::copy(_M_local_buf, __str._M_local_buf,
482 _S_local_capacity + 1);
486 _M_data(__str._M_data());
487 _M_capacity(__str._M_allocated_capacity);
493 _M_length(__str.length());
494 __str._M_data(__str._M_local_data());
495 __str._M_set_length(0);
503 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
504 : _M_dataplus(_M_local_data(), __a)
505 { _M_construct(__l.begin(), __l.end()); }
507 basic_string(
const basic_string& __str,
const _Alloc& __a)
508 : _M_dataplus(_M_local_data(), __a)
509 { _M_construct(__str.begin(), __str.end()); }
512 noexcept(_Alloc_traits::_S_always_equal())
513 : _M_dataplus(_M_local_data(), __a)
515 if (__str._M_is_local())
517 traits_type::copy(_M_local_buf, __str._M_local_buf,
518 _S_local_capacity + 1);
519 _M_length(__str.length());
520 __str._M_set_length(0);
522 else if (_Alloc_traits::_S_always_equal()
523 || __str.get_allocator() == __a)
525 _M_data(__str._M_data());
526 _M_length(__str.length());
527 _M_capacity(__str._M_allocated_capacity);
528 __str._M_data(__str._M_local_buf);
529 __str._M_set_length(0);
532 _M_construct(__str.begin(), __str.end());
543 #if __cplusplus >= 201103L 544 template<
typename _InputIterator,
545 typename = std::_RequireInputIter<_InputIterator>>
547 template<
typename _InputIterator>
549 basic_string(_InputIterator __beg, _InputIterator __end,
550 const _Alloc& __a = _Alloc())
551 : _M_dataplus(_M_local_data(), __a)
552 { _M_construct(__beg, __end); }
567 #if __cplusplus >= 201103L 568 if (_Alloc_traits::_S_propagate_on_copy_assign())
570 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
571 && _M_get_allocator() != __str._M_get_allocator())
574 _M_destroy(_M_allocated_capacity);
575 _M_data(_M_local_data());
578 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
581 return this->
assign(__str);
590 {
return this->
assign(__s); }
606 #if __cplusplus >= 201103L 619 noexcept(_Alloc_traits::_S_nothrow_move())
621 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
622 && !_Alloc_traits::_S_always_equal()
623 && _M_get_allocator() != __str._M_get_allocator())
626 _M_destroy(_M_allocated_capacity);
627 _M_data(_M_local_data());
631 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
633 if (!__str._M_is_local()
634 && (_Alloc_traits::_S_propagate_on_move_assign()
635 || _Alloc_traits::_S_always_equal()))
637 pointer __data =
nullptr;
638 size_type __capacity;
641 if (_Alloc_traits::_S_always_equal())
644 __capacity = _M_allocated_capacity;
647 _M_destroy(_M_allocated_capacity);
650 _M_data(__str._M_data());
651 _M_length(__str.length());
652 _M_capacity(__str._M_allocated_capacity);
655 __str._M_data(__data);
656 __str._M_capacity(__capacity);
659 __str._M_data(__str._M_local_buf);
674 this->
assign(__l.begin(), __l.size());
685 begin() _GLIBCXX_NOEXCEPT
686 {
return iterator(_M_data()); }
693 begin() const _GLIBCXX_NOEXCEPT
694 {
return const_iterator(_M_data()); }
701 end() _GLIBCXX_NOEXCEPT
702 {
return iterator(_M_data() + this->
size()); }
709 end() const _GLIBCXX_NOEXCEPT
710 {
return const_iterator(_M_data() + this->
size()); }
718 rbegin() _GLIBCXX_NOEXCEPT
719 {
return reverse_iterator(this->
end()); }
726 const_reverse_iterator
727 rbegin() const _GLIBCXX_NOEXCEPT
728 {
return const_reverse_iterator(this->
end()); }
736 rend() _GLIBCXX_NOEXCEPT
737 {
return reverse_iterator(this->
begin()); }
744 const_reverse_iterator
745 rend() const _GLIBCXX_NOEXCEPT
746 {
return const_reverse_iterator(this->
begin()); }
748 #if __cplusplus >= 201103L 755 {
return const_iterator(this->_M_data()); }
762 cend() const noexcept
763 {
return const_iterator(this->_M_data() + this->
size()); }
770 const_reverse_iterator
772 {
return const_reverse_iterator(this->
end()); }
779 const_reverse_iterator
780 crend() const noexcept
781 {
return const_reverse_iterator(this->
begin()); }
789 size() const _GLIBCXX_NOEXCEPT
790 {
return _M_string_length; }
795 length() const _GLIBCXX_NOEXCEPT
796 {
return _M_string_length; }
801 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
814 resize(size_type __n, _CharT __c);
828 { this->
resize(__n, _CharT()); }
830 #if __cplusplus >= 201103L 854 return _M_is_local() ? size_type(_S_local_capacity)
855 : _M_allocated_capacity;
876 reserve(size_type __res_arg = 0);
882 clear() _GLIBCXX_NOEXCEPT
883 { _M_set_length(0); }
890 empty() const _GLIBCXX_NOEXCEPT
891 {
return this->
size() == 0; }
905 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
907 __glibcxx_assert(__pos <=
size());
908 return _M_data()[__pos];
926 __glibcxx_assert(__pos <=
size());
928 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
929 return _M_data()[__pos];
943 at(size_type __n)
const 945 if (__n >= this->
size())
946 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 947 "(which is %zu) >= this->size() " 950 return _M_data()[__n];
967 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 968 "(which is %zu) >= this->size() " 971 return _M_data()[__n];
974 #if __cplusplus >= 201103L 982 __glibcxx_assert(!
empty());
991 front() const noexcept
993 __glibcxx_assert(!
empty());
1004 __glibcxx_assert(!
empty());
1013 back() const noexcept
1015 __glibcxx_assert(!
empty());
1028 {
return this->
append(__str); }
1037 {
return this->
append(__s); }
1051 #if __cplusplus >= 201103L 1059 {
return this->
append(__l.begin(), __l.size()); }
1068 append(
const basic_string& __str)
1069 {
return _M_append(__str._M_data(), __str.size()); }
1085 append(
const basic_string& __str, size_type __pos, size_type __n)
1086 {
return _M_append(__str._M_data()
1087 + __str._M_check(__pos,
"basic_string::append"),
1088 __str._M_limit(__pos, __n)); }
1097 append(
const _CharT* __s, size_type __n)
1099 __glibcxx_requires_string_len(__s, __n);
1100 _M_check_length(size_type(0), __n,
"basic_string::append");
1101 return _M_append(__s, __n);
1110 append(
const _CharT* __s)
1112 __glibcxx_requires_string(__s);
1113 const size_type __n = traits_type::length(__s);
1114 _M_check_length(size_type(0), __n,
"basic_string::append");
1115 return _M_append(__s, __n);
1127 append(size_type __n, _CharT __c)
1128 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1130 #if __cplusplus >= 201103L 1137 append(initializer_list<_CharT> __l)
1138 {
return this->
append(__l.begin(), __l.size()); }
1149 #if __cplusplus >= 201103L 1150 template<
class _InputIterator,
1151 typename = std::_RequireInputIter<_InputIterator>>
1153 template<
class _InputIterator>
1156 append(_InputIterator __first, _InputIterator __last)
1166 const size_type __size = this->
size();
1168 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1169 traits_type::assign(this->_M_data()[__size], __c);
1170 this->_M_set_length(__size + 1);
1179 assign(
const basic_string& __str)
1181 this->_M_assign(__str);
1185 #if __cplusplus >= 201103L 1195 assign(basic_string&& __str)
1196 noexcept(_Alloc_traits::_S_nothrow_move())
1200 return *
this = std::move(__str);
1218 assign(
const basic_string& __str, size_type __pos, size_type __n)
1219 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1220 + __str._M_check(__pos,
"basic_string::assign"),
1221 __str._M_limit(__pos, __n)); }
1234 assign(
const _CharT* __s, size_type __n)
1236 __glibcxx_requires_string_len(__s, __n);
1237 return _M_replace(size_type(0), this->
size(), __s, __n);
1250 assign(
const _CharT* __s)
1252 __glibcxx_requires_string(__s);
1253 return _M_replace(size_type(0), this->
size(), __s,
1254 traits_type::length(__s));
1267 assign(size_type __n, _CharT __c)
1268 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1278 #if __cplusplus >= 201103L 1279 template<
class _InputIterator,
1280 typename = std::_RequireInputIter<_InputIterator>>
1282 template<
class _InputIterator>
1285 assign(_InputIterator __first, _InputIterator __last)
1288 #if __cplusplus >= 201103L 1295 assign(initializer_list<_CharT> __l)
1296 {
return this->
assign(__l.begin(), __l.size()); }
1299 #if __cplusplus >= 201103L 1316 insert(const_iterator __p, size_type __n, _CharT __c)
1318 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1319 const size_type __pos = __p -
begin();
1320 this->
replace(__p, __p, __n, __c);
1321 return iterator(this->_M_data() + __pos);
1338 insert(iterator __p, size_type __n, _CharT __c)
1339 { this->
replace(__p, __p, __n, __c); }
1342 #if __cplusplus >= 201103L 1357 template<
class _InputIterator,
1358 typename = std::_RequireInputIter<_InputIterator>>
1360 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1362 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1363 const size_type __pos = __p -
begin();
1364 this->
replace(__p, __p, __beg, __end);
1365 return iterator(this->_M_data() + __pos);
1380 template<
class _InputIterator>
1382 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1383 { this->
replace(__p, __p, __beg, __end); }
1386 #if __cplusplus >= 201103L 1394 insert(iterator __p, initializer_list<_CharT> __l)
1396 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1397 this->
insert(__p -
begin(), __l.begin(), __l.size());
1414 insert(size_type __pos1,
const basic_string& __str)
1415 {
return this->
replace(__pos1, size_type(0),
1416 __str._M_data(), __str.size()); }
1437 insert(size_type __pos1,
const basic_string& __str,
1438 size_type __pos2, size_type __n)
1439 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1440 + __str._M_check(__pos2,
"basic_string::insert"),
1441 __str._M_limit(__pos2, __n)); }
1460 insert(size_type __pos,
const _CharT* __s, size_type __n)
1461 {
return this->
replace(__pos, size_type(0), __s, __n); }
1479 insert(size_type __pos,
const _CharT* __s)
1481 __glibcxx_requires_string(__s);
1482 return this->
replace(__pos, size_type(0), __s,
1483 traits_type::length(__s));
1503 insert(size_type __pos, size_type __n, _CharT __c)
1504 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1505 size_type(0), __n, __c); }
1521 insert(__const_iterator __p, _CharT __c)
1523 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1524 const size_type __pos = __p -
begin();
1525 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1526 return iterator(_M_data() + __pos);
1545 erase(size_type __pos = 0, size_type __n = npos)
1547 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1548 _M_limit(__pos, __n));
1561 erase(__const_iterator __position)
1563 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1564 && __position <
end());
1565 const size_type __pos = __position -
begin();
1566 this->_M_erase(__pos, size_type(1));
1567 return iterator(_M_data() + __pos);
1580 erase(__const_iterator __first, __const_iterator __last)
1582 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1583 && __last <=
end());
1584 const size_type __pos = __first -
begin();
1585 this->_M_erase(__pos, __last - __first);
1586 return iterator(this->_M_data() + __pos);
1589 #if __cplusplus >= 201103L 1598 __glibcxx_assert(!
empty());
1599 _M_erase(
size() - 1, 1);
1621 replace(size_type __pos, size_type __n,
const basic_string& __str)
1622 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1643 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1644 size_type __pos2, size_type __n2)
1645 {
return this->
replace(__pos1, __n1, __str._M_data()
1646 + __str._M_check(__pos2,
"basic_string::replace"),
1647 __str._M_limit(__pos2, __n2)); }
1668 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1671 __glibcxx_requires_string_len(__s, __n2);
1672 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1673 _M_limit(__pos, __n1), __s, __n2);
1693 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1695 __glibcxx_requires_string(__s);
1696 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1717 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1718 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1719 _M_limit(__pos, __n1), __n2, __c); }
1735 replace(__const_iterator __i1, __const_iterator __i2,
1736 const basic_string& __str)
1737 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1755 replace(__const_iterator __i1, __const_iterator __i2,
1756 const _CharT* __s, size_type __n)
1758 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1760 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1777 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1779 __glibcxx_requires_string(__s);
1780 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1798 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1801 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1803 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1821 #if __cplusplus >= 201103L 1822 template<
class _InputIterator,
1823 typename = std::_RequireInputIter<_InputIterator>>
1825 replace(const_iterator __i1, const_iterator __i2,
1826 _InputIterator __k1, _InputIterator __k2)
1828 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1830 __glibcxx_requires_valid_range(__k1, __k2);
1831 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1832 std::__false_type());
1835 template<
class _InputIterator>
1836 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1837 typename __enable_if_not_native_iterator<_InputIterator>::__type
1841 replace(iterator __i1, iterator __i2,
1842 _InputIterator __k1, _InputIterator __k2)
1844 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1846 __glibcxx_requires_valid_range(__k1, __k2);
1847 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1848 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1855 replace(__const_iterator __i1, __const_iterator __i2,
1856 _CharT* __k1, _CharT* __k2)
1858 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1860 __glibcxx_requires_valid_range(__k1, __k2);
1866 replace(__const_iterator __i1, __const_iterator __i2,
1867 const _CharT* __k1,
const _CharT* __k2)
1869 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1871 __glibcxx_requires_valid_range(__k1, __k2);
1877 replace(__const_iterator __i1, __const_iterator __i2,
1878 iterator __k1, iterator __k2)
1880 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1882 __glibcxx_requires_valid_range(__k1, __k2);
1884 __k1.base(), __k2 - __k1);
1888 replace(__const_iterator __i1, __const_iterator __i2,
1889 const_iterator __k1, const_iterator __k2)
1891 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1893 __glibcxx_requires_valid_range(__k1, __k2);
1895 __k1.base(), __k2 - __k1);
1898 #if __cplusplus >= 201103L 1913 basic_string&
replace(const_iterator __i1, const_iterator __i2,
1914 initializer_list<_CharT> __l)
1915 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1919 template<
class _Integer>
1921 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1922 _Integer __n, _Integer __val, __true_type)
1923 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1925 template<
class _InputIterator>
1927 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1928 _InputIterator __k1, _InputIterator __k2,
1932 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1936 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1937 const size_type __len2);
1940 _M_append(
const _CharT* __s, size_type __n);
1957 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1967 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
1977 c_str() const _GLIBCXX_NOEXCEPT
1978 {
return _M_data(); }
1987 data() const _GLIBCXX_NOEXCEPT
1988 {
return _M_data(); }
1995 {
return _M_get_allocator(); }
2010 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2023 find(
const basic_string& __str, size_type __pos = 0) const
2025 {
return this->
find(__str.data(), __pos, __str.size()); }
2038 find(
const _CharT* __s, size_type __pos = 0)
const 2040 __glibcxx_requires_string(__s);
2041 return this->
find(__s, __pos, traits_type::length(__s));
2055 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2068 rfind(const basic_string& __str, size_type __pos = npos) const
2070 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2085 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2098 rfind(
const _CharT* __s, size_type __pos = npos)
const 2100 __glibcxx_requires_string(__s);
2101 return this->
rfind(__s, __pos, traits_type::length(__s));
2115 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2129 find_first_of(const basic_string& __str, size_type __pos = 0) const
2131 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2146 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2161 __glibcxx_requires_string(__s);
2162 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2178 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2179 {
return this->
find(__c, __pos); }
2193 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2195 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2210 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2223 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2225 __glibcxx_requires_string(__s);
2226 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2242 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2243 {
return this->
rfind(__c, __pos); }
2274 size_type __n)
const;
2289 __glibcxx_requires_string(__s);
2337 size_type __n)
const;
2352 __glibcxx_requires_string(__s);
2383 substr(size_type __pos = 0, size_type __n = npos)
const 2385 _M_check(__pos,
"basic_string::substr"), __n); }
2402 compare(
const basic_string& __str)
const 2404 const size_type __size = this->
size();
2405 const size_type __osize = __str.size();
2406 const size_type __len =
std::min(__size, __osize);
2408 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2410 __r = _S_compare(__size, __osize);
2434 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2460 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2461 size_type __pos2, size_type __n2)
const;
2478 compare(
const _CharT* __s)
const;
2502 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2529 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2530 size_type __n2)
const;
2532 _GLIBCXX_END_NAMESPACE_CXX11
2533 #else // !_GLIBCXX_USE_CXX11_ABI 2598 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2601 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2605 typedef _Traits traits_type;
2606 typedef typename _Traits::char_type value_type;
2607 typedef _Alloc allocator_type;
2608 typedef typename _CharT_alloc_type::size_type size_type;
2609 typedef typename _CharT_alloc_type::difference_type difference_type;
2610 typedef typename _CharT_alloc_type::reference reference;
2611 typedef typename _CharT_alloc_type::const_reference const_reference;
2612 typedef typename _CharT_alloc_type::pointer pointer;
2613 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2614 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2615 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2637 size_type _M_length;
2638 size_type _M_capacity;
2639 _Atomic_word _M_refcount;
2642 struct _Rep : _Rep_base
2645 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2660 static const size_type _S_max_size;
2661 static const _CharT _S_terminal;
2665 static size_type _S_empty_rep_storage[];
2668 _S_empty_rep() _GLIBCXX_NOEXCEPT
2673 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2674 return *
reinterpret_cast<_Rep*
>(__p);
2678 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2680 #if defined(__GTHREADS) 2685 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
2687 return this->_M_refcount < 0;
2692 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2694 #if defined(__GTHREADS) 2700 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
2702 return this->_M_refcount > 0;
2707 _M_set_leaked() _GLIBCXX_NOEXCEPT
2708 { this->_M_refcount = -1; }
2711 _M_set_sharable() _GLIBCXX_NOEXCEPT
2712 { this->_M_refcount = 0; }
2715 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2717 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2718 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2721 this->_M_set_sharable();
2722 this->_M_length = __n;
2723 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2730 _M_refdata()
throw()
2731 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2734 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2736 return (!_M_is_leaked() && __alloc1 == __alloc2)
2737 ? _M_refcopy() : _M_clone(__alloc1);
2742 _S_create(size_type, size_type,
const _Alloc&);
2745 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2747 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2748 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2752 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2761 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2764 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2771 _M_destroy(
const _Alloc&)
throw();
2774 _M_refcopy()
throw()
2776 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2777 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2779 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2780 return _M_refdata();
2784 _M_clone(
const _Alloc&, size_type __res = 0);
2788 struct _Alloc_hider : _Alloc
2790 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2791 : _Alloc(__a), _M_p(__dat) { }
2801 static const size_type npos =
static_cast<size_type
>(-1);
2805 mutable _Alloc_hider _M_dataplus;
2808 _M_data() const _GLIBCXX_NOEXCEPT
2809 {
return _M_dataplus._M_p; }
2812 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2813 {
return (_M_dataplus._M_p = __p); }
2816 _M_rep()
const _GLIBCXX_NOEXCEPT
2817 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2822 _M_ibegin()
const _GLIBCXX_NOEXCEPT
2823 {
return iterator(_M_data()); }
2826 _M_iend()
const _GLIBCXX_NOEXCEPT
2827 {
return iterator(_M_data() + this->
size()); }
2832 if (!_M_rep()->_M_is_leaked())
2837 _M_check(size_type __pos,
const char* __s)
const 2839 if (__pos > this->
size())
2840 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2841 "this->size() (which is %zu)"),
2842 __s, __pos, this->
size());
2847 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2850 __throw_length_error(__N(__s));
2855 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2857 const bool __testoff = __off < this->
size() - __pos;
2858 return __testoff ? __off : this->
size() - __pos;
2863 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2872 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2875 traits_type::assign(*__d, *__s);
2877 traits_type::copy(__d, __s, __n);
2881 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2884 traits_type::assign(*__d, *__s);
2886 traits_type::move(__d, __s, __n);
2890 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2893 traits_type::assign(*__d, __c);
2895 traits_type::assign(__d, __n, __c);
2900 template<
class _Iterator>
2902 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2904 for (; __k1 != __k2; ++__k1, (void)++__p)
2905 traits_type::assign(*__p, *__k1);
2909 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2910 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2913 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2915 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2918 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2919 { _M_copy(__p, __k1, __k2 - __k1); }
2922 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2924 { _M_copy(__p, __k1, __k2 - __k1); }
2927 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2929 const difference_type __d = difference_type(__n1 - __n2);
2931 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2932 return __gnu_cxx::__numeric_traits<int>::__max;
2933 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2934 return __gnu_cxx::__numeric_traits<int>::__min;
2940 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2946 _S_empty_rep() _GLIBCXX_NOEXCEPT
2947 {
return _Rep::_S_empty_rep(); }
2958 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2959 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2961 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2982 basic_string(
const basic_string& __str, size_type __pos,
2983 size_type __n = npos);
2991 basic_string(
const basic_string& __str, size_type __pos,
2992 size_type __n,
const _Alloc& __a);
3004 const _Alloc& __a = _Alloc());
3010 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3017 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3019 #if __cplusplus >= 201103L 3028 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3031 : _M_dataplus(__str._M_dataplus)
3033 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3034 __str._M_data(_S_empty_rep()._M_refdata());
3036 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3054 template<
class _InputIterator>
3055 basic_string(_InputIterator __beg, _InputIterator __end,
3056 const _Alloc& __a = _Alloc());
3070 {
return this->
assign(__str); }
3078 {
return this->
assign(__s); }
3094 #if __cplusplus >= 201103L 3118 this->
assign(__l.begin(), __l.size());
3132 return iterator(_M_data());
3141 {
return const_iterator(_M_data()); }
3151 return iterator(_M_data() + this->
size());
3160 {
return const_iterator(_M_data() + this->
size()); }
3169 {
return reverse_iterator(this->
end()); }
3176 const_reverse_iterator
3178 {
return const_reverse_iterator(this->
end()); }
3187 {
return reverse_iterator(this->
begin()); }
3194 const_reverse_iterator
3196 {
return const_reverse_iterator(this->
begin()); }
3198 #if __cplusplus >= 201103L 3205 {
return const_iterator(this->_M_data()); }
3213 {
return const_iterator(this->_M_data() + this->
size()); }
3220 const_reverse_iterator
3222 {
return const_reverse_iterator(this->
end()); }
3229 const_reverse_iterator
3231 {
return const_reverse_iterator(this->
begin()); }
3240 {
return _M_rep()->_M_length; }
3246 {
return _M_rep()->_M_length; }
3251 {
return _Rep::_S_max_size; }
3264 resize(size_type __n, _CharT __c);
3278 { this->
resize(__n, _CharT()); }
3280 #if __cplusplus >= 201103L 3285 #if __cpp_exceptions 3303 {
return _M_rep()->_M_capacity; }
3323 reserve(size_type __res_arg = 0);
3331 { _M_mutate(0, this->
size(), 0); }
3339 {
return this->
size() == 0; }
3355 __glibcxx_assert(__pos <=
size());
3356 return _M_data()[__pos];
3374 __glibcxx_assert(__pos <=
size());
3376 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3378 return _M_data()[__pos];
3394 if (__n >= this->
size())
3395 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3396 "(which is %zu) >= this->size() " 3399 return _M_data()[__n];
3417 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3418 "(which is %zu) >= this->size() " 3422 return _M_data()[__n];
3425 #if __cplusplus >= 201103L 3433 __glibcxx_assert(!
empty());
3444 __glibcxx_assert(!
empty());
3455 __glibcxx_assert(!
empty());
3466 __glibcxx_assert(!
empty());
3479 {
return this->
append(__str); }
3488 {
return this->
append(__s); }
3502 #if __cplusplus >= 201103L 3510 {
return this->
append(__l.begin(), __l.size()); }
3519 append(
const basic_string& __str);
3535 append(
const basic_string& __str, size_type __pos, size_type __n);
3544 append(
const _CharT* __s, size_type __n);
3554 __glibcxx_requires_string(__s);
3555 return this->
append(__s, traits_type::length(__s));
3567 append(size_type __n, _CharT __c);
3569 #if __cplusplus >= 201103L 3577 {
return this->
append(__l.begin(), __l.size()); }
3588 template<
class _InputIterator>
3590 append(_InputIterator __first, _InputIterator __last)
3591 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3600 const size_type __len = 1 + this->
size();
3601 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3603 traits_type::assign(_M_data()[this->
size()], __c);
3604 _M_rep()->_M_set_length_and_sharable(__len);
3613 assign(
const basic_string& __str);
3615 #if __cplusplus >= 201103L 3647 assign(
const basic_string& __str, size_type __pos, size_type __n)
3648 {
return this->
assign(__str._M_data()
3649 + __str._M_check(__pos,
"basic_string::assign"),
3650 __str._M_limit(__pos, __n)); }
3663 assign(
const _CharT* __s, size_type __n);
3677 __glibcxx_requires_string(__s);
3678 return this->
assign(__s, traits_type::length(__s));
3692 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3702 template<
class _InputIterator>
3704 assign(_InputIterator __first, _InputIterator __last)
3705 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3707 #if __cplusplus >= 201103L 3715 {
return this->
assign(__l.begin(), __l.size()); }
3732 insert(iterator __p, size_type __n, _CharT __c)
3733 { this->
replace(__p, __p, __n, __c); }
3747 template<
class _InputIterator>
3749 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3750 { this->
replace(__p, __p, __beg, __end); }
3752 #if __cplusplus >= 201103L 3762 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3763 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3780 insert(size_type __pos1,
const basic_string& __str)
3781 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3802 insert(size_type __pos1,
const basic_string& __str,
3803 size_type __pos2, size_type __n)
3804 {
return this->
insert(__pos1, __str._M_data()
3805 + __str._M_check(__pos2,
"basic_string::insert"),
3806 __str._M_limit(__pos2, __n)); }
3825 insert(size_type __pos,
const _CharT* __s, size_type __n);
3845 __glibcxx_requires_string(__s);
3846 return this->
insert(__pos, __s, traits_type::length(__s));
3866 insert(size_type __pos, size_type __n, _CharT __c)
3867 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3868 size_type(0), __n, __c); }
3886 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3887 const size_type __pos = __p - _M_ibegin();
3888 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3889 _M_rep()->_M_set_leaked();
3890 return iterator(_M_data() + __pos);
3909 erase(size_type __pos = 0, size_type __n = npos)
3911 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3912 _M_limit(__pos, __n), size_type(0));
3927 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3928 && __position < _M_iend());
3929 const size_type __pos = __position - _M_ibegin();
3930 _M_mutate(__pos, size_type(1), size_type(0));
3931 _M_rep()->_M_set_leaked();
3932 return iterator(_M_data() + __pos);
3945 erase(iterator __first, iterator __last);
3947 #if __cplusplus >= 201103L 3956 __glibcxx_assert(!
empty());
3979 replace(size_type __pos, size_type __n,
const basic_string& __str)
3980 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4001 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4002 size_type __pos2, size_type __n2)
4003 {
return this->
replace(__pos1, __n1, __str._M_data()
4004 + __str._M_check(__pos2,
"basic_string::replace"),
4005 __str._M_limit(__pos2, __n2)); }
4026 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4046 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4048 __glibcxx_requires_string(__s);
4049 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4070 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4071 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4072 _M_limit(__pos, __n1), __n2, __c); }
4088 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4089 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4107 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4109 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4110 && __i2 <= _M_iend());
4111 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4128 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4130 __glibcxx_requires_string(__s);
4131 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4149 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4151 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4152 && __i2 <= _M_iend());
4153 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4171 template<
class _InputIterator>
4174 _InputIterator __k1, _InputIterator __k2)
4176 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4177 && __i2 <= _M_iend());
4178 __glibcxx_requires_valid_range(__k1, __k2);
4179 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4180 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4186 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4188 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4189 && __i2 <= _M_iend());
4190 __glibcxx_requires_valid_range(__k1, __k2);
4191 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4196 replace(iterator __i1, iterator __i2,
4197 const _CharT* __k1,
const _CharT* __k2)
4199 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4200 && __i2 <= _M_iend());
4201 __glibcxx_requires_valid_range(__k1, __k2);
4202 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4207 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4209 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4210 && __i2 <= _M_iend());
4211 __glibcxx_requires_valid_range(__k1, __k2);
4212 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4213 __k1.base(), __k2 - __k1);
4217 replace(iterator __i1, iterator __i2,
4218 const_iterator __k1, const_iterator __k2)
4220 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4221 && __i2 <= _M_iend());
4222 __glibcxx_requires_valid_range(__k1, __k2);
4223 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4224 __k1.base(), __k2 - __k1);
4227 #if __cplusplus >= 201103L 4242 basic_string&
replace(iterator __i1, iterator __i2,
4244 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4248 template<
class _Integer>
4250 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4251 _Integer __val, __true_type)
4252 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4254 template<
class _InputIterator>
4256 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4257 _InputIterator __k2, __false_type);
4260 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4264 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4269 template<
class _InIterator>
4271 _S_construct_aux(_InIterator __beg, _InIterator __end,
4272 const _Alloc& __a, __false_type)
4274 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4275 return _S_construct(__beg, __end, __a, _Tag());
4280 template<
class _Integer>
4282 _S_construct_aux(_Integer __beg, _Integer __end,
4283 const _Alloc& __a, __true_type)
4284 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4288 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4289 {
return _S_construct(__req, __c, __a); }
4291 template<
class _InIterator>
4293 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4295 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4296 return _S_construct_aux(__beg, __end, __a, _Integral());
4300 template<
class _InIterator>
4302 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4307 template<
class _FwdIterator>
4309 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4313 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4330 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4341 swap(basic_string& __s);
4352 {
return _M_data(); }
4362 {
return _M_data(); }
4369 {
return _M_dataplus; }
4384 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4397 find(
const basic_string& __str, size_type __pos = 0) const
4399 {
return this->
find(__str.data(), __pos, __str.size()); }
4412 find(
const _CharT* __s, size_type __pos = 0)
const 4414 __glibcxx_requires_string(__s);
4415 return this->
find(__s, __pos, traits_type::length(__s));
4429 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4442 rfind(
const basic_string& __str, size_type __pos = npos) const
4444 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4459 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4472 rfind(
const _CharT* __s, size_type __pos = npos)
const 4474 __glibcxx_requires_string(__s);
4475 return this->
rfind(__s, __pos, traits_type::length(__s));
4489 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4505 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4520 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4535 __glibcxx_requires_string(__s);
4536 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4553 {
return this->
find(__c, __pos); }
4569 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4584 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4599 __glibcxx_requires_string(__s);
4600 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4617 {
return this->
rfind(__c, __pos); }
4648 size_type __n)
const;
4663 __glibcxx_requires_string(__s);
4711 size_type __n)
const;
4726 __glibcxx_requires_string(__s);
4757 substr(size_type __pos = 0, size_type __n = npos)
const 4759 _M_check(__pos,
"basic_string::substr"), __n); }
4778 const size_type __size = this->
size();
4779 const size_type __osize = __str.size();
4780 const size_type __len =
std::min(__size, __osize);
4782 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4784 __r = _S_compare(__size, __osize);
4808 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
4834 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
4835 size_type __pos2, size_type __n2)
const;
4852 compare(
const _CharT* __s)
const;
4876 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4903 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4904 size_type __n2)
const;
4906 # ifdef _GLIBCXX_TM_TS_INTERNAL 4908 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
4911 ::_txnal_cow_string_c_str(
const void *that);
4913 ::_txnal_cow_string_D1(
void *that);
4915 ::_txnal_cow_string_D1_commit(
void *that);
4918 #endif // !_GLIBCXX_USE_CXX11_ABI 4927 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4933 __str.append(__rhs);
4943 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4954 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4964 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4967 const _CharT* __rhs)
4970 __str.append(__rhs);
4980 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4985 typedef typename __string_type::size_type __size_type;
4986 __string_type __str(__lhs);
4987 __str.append(__size_type(1), __rhs);
4991 #if __cplusplus >= 201103L 4992 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4996 {
return std::move(__lhs.append(__rhs)); }
4998 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5002 {
return std::move(__rhs.insert(0, __lhs)); }
5004 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5009 const auto __size = __lhs.size() + __rhs.size();
5010 const bool __cond = (__size > __lhs.capacity()
5011 && __size <= __rhs.capacity());
5012 return __cond ? std::move(__rhs.insert(0, __lhs))
5013 : std::move(__lhs.append(__rhs));
5016 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5020 {
return std::move(__rhs.insert(0, __lhs)); }
5022 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5026 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5028 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5031 const _CharT* __rhs)
5032 {
return std::move(__lhs.append(__rhs)); }
5034 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5038 {
return std::move(__lhs.append(1, __rhs)); }
5048 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5053 {
return __lhs.compare(__rhs) == 0; }
5055 template<
typename _CharT>
5057 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5060 {
return (__lhs.
size() == __rhs.
size()
5070 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5072 operator==(
const _CharT* __lhs,
5074 {
return __rhs.compare(__lhs) == 0; }
5082 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5085 const _CharT* __rhs)
5086 {
return __lhs.compare(__rhs) == 0; }
5095 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5100 {
return !(__lhs == __rhs); }
5108 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5110 operator!=(
const _CharT* __lhs,
5112 {
return !(__lhs == __rhs); }
5120 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5123 const _CharT* __rhs)
5124 {
return !(__lhs == __rhs); }
5133 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5135 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5138 {
return __lhs.
compare(__rhs) < 0; }
5146 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5148 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5149 const _CharT* __rhs)
5150 {
return __lhs.
compare(__rhs) < 0; }
5158 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5160 operator<(
const _CharT* __lhs,
5162 {
return __rhs.compare(__lhs) > 0; }
5171 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5176 {
return __lhs.compare(__rhs) > 0; }
5184 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5187 const _CharT* __rhs)
5188 {
return __lhs.compare(__rhs) > 0; }
5196 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5198 operator>(
const _CharT* __lhs,
5200 {
return __rhs.compare(__lhs) < 0; }
5209 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5211 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5214 {
return __lhs.
compare(__rhs) <= 0; }
5222 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5224 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5225 const _CharT* __rhs)
5226 {
return __lhs.
compare(__rhs) <= 0; }
5234 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5236 operator<=(
const _CharT* __lhs,
5238 {
return __rhs.compare(__lhs) >= 0; }
5247 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5252 {
return __lhs.compare(__rhs) >= 0; }
5260 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5263 const _CharT* __rhs)
5264 {
return __lhs.compare(__rhs) >= 0; }
5272 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5274 operator>=(
const _CharT* __lhs,
5276 {
return __rhs.compare(__lhs) <= 0; }
5285 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5289 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5290 { __lhs.swap(__rhs); }
5305 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5323 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5325 operator<<(basic_ostream<_CharT, _Traits>& __os,
5330 return __ostream_insert(__os, __str.
data(), __str.
size());
5346 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5363 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5369 #if __cplusplus >= 201103L 5371 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5378 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5390 #ifdef _GLIBCXX_USE_WCHAR_T 5397 _GLIBCXX_END_NAMESPACE_VERSION
5400 #if __cplusplus >= 201103L 5404 namespace std _GLIBCXX_VISIBILITY(default)
5406 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5407 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5409 #if _GLIBCXX_USE_C99_STDLIB 5412 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5413 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5417 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5418 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5421 inline unsigned long 5422 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5423 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5427 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5428 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5431 inline unsigned long long 5432 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5433 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5438 stof(
const string& __str,
size_t* __idx = 0)
5439 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5442 stod(
const string& __str,
size_t* __idx = 0)
5443 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5446 stold(
const string& __str,
size_t* __idx = 0)
5447 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5448 #endif // _GLIBCXX_USE_C99_STDLIB 5450 #if _GLIBCXX_USE_C99_STDIO 5455 to_string(
int __val)
5456 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5460 to_string(
unsigned __val)
5461 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5462 4 *
sizeof(unsigned),
5466 to_string(
long __val)
5467 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5471 to_string(
unsigned long __val)
5472 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5473 4 *
sizeof(
unsigned long),
5477 to_string(
long long __val)
5478 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5479 4 *
sizeof(
long long),
5483 to_string(
unsigned long long __val)
5484 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5485 4 *
sizeof(
unsigned long long),
5489 to_string(
float __val)
5492 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5493 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5498 to_string(
double __val)
5501 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5502 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5507 to_string(
long double __val)
5510 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5511 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5514 #endif // _GLIBCXX_USE_C99_STDIO 5516 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 5518 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5519 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5523 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5524 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5527 inline unsigned long 5528 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5529 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5533 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5534 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5537 inline unsigned long long 5538 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5539 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5544 stof(
const wstring& __str,
size_t* __idx = 0)
5545 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5548 stod(
const wstring& __str,
size_t* __idx = 0)
5549 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5552 stold(
const wstring& __str,
size_t* __idx = 0)
5553 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5555 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5558 to_wstring(
int __val)
5559 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5563 to_wstring(
unsigned __val)
5564 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5565 4 *
sizeof(unsigned),
5569 to_wstring(
long __val)
5570 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5574 to_wstring(
unsigned long __val)
5575 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5576 4 *
sizeof(
unsigned long),
5580 to_wstring(
long long __val)
5581 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5582 4 *
sizeof(
long long),
5586 to_wstring(
unsigned long long __val)
5587 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5588 4 *
sizeof(
unsigned long long),
5592 to_wstring(
float __val)
5595 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5596 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5601 to_wstring(
double __val)
5604 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5605 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5610 to_wstring(
long double __val)
5613 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5614 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5617 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5618 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 5620 _GLIBCXX_END_NAMESPACE_CXX11
5621 _GLIBCXX_END_NAMESPACE_VERSION
5626 #if __cplusplus >= 201103L 5630 namespace std _GLIBCXX_VISIBILITY(default)
5632 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5636 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5640 :
public __hash_base<size_t, string>
5643 operator()(
const string& __s)
const noexcept
5644 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5651 #ifdef _GLIBCXX_USE_WCHAR_T 5655 :
public __hash_base<size_t, wstring>
5658 operator()(
const wstring& __s)
const noexcept
5659 {
return std::_Hash_impl::hash(__s.
data(),
5660 __s.
length() *
sizeof(wchar_t)); }
5669 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5673 :
public __hash_base<size_t, u16string>
5676 operator()(
const u16string& __s)
const noexcept
5677 {
return std::_Hash_impl::hash(__s.
data(),
5678 __s.
length() *
sizeof(char16_t)); }
5688 :
public __hash_base<size_t, u32string>
5691 operator()(
const u32string& __s)
const noexcept
5692 {
return std::_Hash_impl::hash(__s.
data(),
5693 __s.
length() *
sizeof(char32_t)); }
5701 _GLIBCXX_END_NAMESPACE_VERSION
5703 #if __cplusplus > 201103L 5705 #define __cpp_lib_string_udls 201304 5707 inline namespace literals
5709 inline namespace string_literals
5711 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5713 _GLIBCXX_DEFAULT_ABI_TAG
5715 operator""s(
const char* __str,
size_t __len)
5718 #ifdef _GLIBCXX_USE_WCHAR_T 5719 _GLIBCXX_DEFAULT_ABI_TAG
5721 operator""s(
const wchar_t* __str,
size_t __len)
5725 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5726 _GLIBCXX_DEFAULT_ABI_TAG
5728 operator""s(
const char16_t* __str,
size_t __len)
5731 _GLIBCXX_DEFAULT_ABI_TAG
5733 operator""s(
const char32_t* __str,
size_t __len)
5737 _GLIBCXX_END_NAMESPACE_VERSION
5741 #endif // __cplusplus > 201103L
static const size_type npos
Value returned by various member functions when they fail.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string()
Default constructor creates an empty string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
Uniform interface to C++98 and C++11 allocators.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
size_type capacity() const noexcept
const_iterator cend() const noexcept
const_reverse_iterator crbegin() const noexcept
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
const_reference back() const noexcept
const _CharT * data() const noexcept
Return const pointer to contents.
Managing sequences of characters and character-like objects.
Template class basic_ostream.
int compare(const basic_string &__str) const
Compare to a string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_iterator cbegin() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
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_reverse_iterator rbegin() const noexcept
reverse_iterator rbegin()
bool empty() const noexcept
Uniform interface to all pointer-like types.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
const_reference front() const noexcept
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
void push_back(_CharT __c)
Append a single character.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
iterator erase(iterator __position)
Remove one character.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
Template class basic_istream.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
const_reverse_iterator rend() const noexcept
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.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in 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.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
char_type widen(char __c) const
Widens characters.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
reference at(size_type __n)
Provides access to the data contained in the string.
const_iterator begin() const noexcept
size_type max_size() const noexcept
Returns the size() of the largest possible string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
One of the comparison functors.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
Basis for explicit traits specializations.
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 & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_reverse_iterator crend() const noexcept
Forward iterators support a superset of input iterator operations.
void pop_back()
Remove the last character.
const_iterator end() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
ISO C++ entities toplevel namespace is std.
basic_string & operator+=(const _CharT *__s)
Append a C string.
Primary class template hash.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
~basic_string() noexcept
Destroy the string instance.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.