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())
575 if (__str.size() <= _S_local_capacity)
577 _M_destroy(_M_allocated_capacity);
578 _M_data(_M_local_data());
583 const auto __len = __str.size();
584 auto __alloc = __str._M_get_allocator();
586 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
587 _M_destroy(_M_allocated_capacity);
590 _M_set_length(__len);
593 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
596 return this->
assign(__str);
605 {
return this->
assign(__s); }
621 #if __cplusplus >= 201103L 634 noexcept(_Alloc_traits::_S_nothrow_move())
636 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
637 && !_Alloc_traits::_S_always_equal()
638 && _M_get_allocator() != __str._M_get_allocator())
641 _M_destroy(_M_allocated_capacity);
642 _M_data(_M_local_data());
646 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
648 if (!__str._M_is_local()
649 && (_Alloc_traits::_S_propagate_on_move_assign()
650 || _Alloc_traits::_S_always_equal()))
652 pointer __data =
nullptr;
653 size_type __capacity;
656 if (_Alloc_traits::_S_always_equal())
659 __capacity = _M_allocated_capacity;
662 _M_destroy(_M_allocated_capacity);
665 _M_data(__str._M_data());
666 _M_length(__str.length());
667 _M_capacity(__str._M_allocated_capacity);
670 __str._M_data(__data);
671 __str._M_capacity(__capacity);
674 __str._M_data(__str._M_local_buf);
689 this->
assign(__l.begin(), __l.size());
700 begin() _GLIBCXX_NOEXCEPT
701 {
return iterator(_M_data()); }
708 begin() const _GLIBCXX_NOEXCEPT
709 {
return const_iterator(_M_data()); }
716 end() _GLIBCXX_NOEXCEPT
717 {
return iterator(_M_data() + this->
size()); }
724 end() const _GLIBCXX_NOEXCEPT
725 {
return const_iterator(_M_data() + this->
size()); }
733 rbegin() _GLIBCXX_NOEXCEPT
734 {
return reverse_iterator(this->
end()); }
741 const_reverse_iterator
742 rbegin() const _GLIBCXX_NOEXCEPT
743 {
return const_reverse_iterator(this->
end()); }
751 rend() _GLIBCXX_NOEXCEPT
752 {
return reverse_iterator(this->
begin()); }
759 const_reverse_iterator
760 rend() const _GLIBCXX_NOEXCEPT
761 {
return const_reverse_iterator(this->
begin()); }
763 #if __cplusplus >= 201103L 770 {
return const_iterator(this->_M_data()); }
777 cend() const noexcept
778 {
return const_iterator(this->_M_data() + this->
size()); }
785 const_reverse_iterator
787 {
return const_reverse_iterator(this->
end()); }
794 const_reverse_iterator
795 crend() const noexcept
796 {
return const_reverse_iterator(this->
begin()); }
804 size() const _GLIBCXX_NOEXCEPT
805 {
return _M_string_length; }
810 length() const _GLIBCXX_NOEXCEPT
811 {
return _M_string_length; }
816 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
829 resize(size_type __n, _CharT __c);
843 { this->
resize(__n, _CharT()); }
845 #if __cplusplus >= 201103L 869 return _M_is_local() ? size_type(_S_local_capacity)
870 : _M_allocated_capacity;
891 reserve(size_type __res_arg = 0);
897 clear() _GLIBCXX_NOEXCEPT
898 { _M_set_length(0); }
905 empty() const _GLIBCXX_NOEXCEPT
906 {
return this->
size() == 0; }
920 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
922 __glibcxx_assert(__pos <=
size());
923 return _M_data()[__pos];
941 __glibcxx_assert(__pos <=
size());
943 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
944 return _M_data()[__pos];
958 at(size_type __n)
const 960 if (__n >= this->
size())
961 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 962 "(which is %zu) >= this->size() " 965 return _M_data()[__n];
982 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 983 "(which is %zu) >= this->size() " 986 return _M_data()[__n];
989 #if __cplusplus >= 201103L 997 __glibcxx_assert(!
empty());
1006 front() const noexcept
1008 __glibcxx_assert(!
empty());
1019 __glibcxx_assert(!
empty());
1028 back() const noexcept
1030 __glibcxx_assert(!
empty());
1043 {
return this->
append(__str); }
1052 {
return this->
append(__s); }
1066 #if __cplusplus >= 201103L 1074 {
return this->
append(__l.begin(), __l.size()); }
1083 append(
const basic_string& __str)
1084 {
return _M_append(__str._M_data(), __str.size()); }
1100 append(
const basic_string& __str, size_type __pos, size_type __n)
1101 {
return _M_append(__str._M_data()
1102 + __str._M_check(__pos,
"basic_string::append"),
1103 __str._M_limit(__pos, __n)); }
1112 append(
const _CharT* __s, size_type __n)
1114 __glibcxx_requires_string_len(__s, __n);
1115 _M_check_length(size_type(0), __n,
"basic_string::append");
1116 return _M_append(__s, __n);
1125 append(
const _CharT* __s)
1127 __glibcxx_requires_string(__s);
1128 const size_type __n = traits_type::length(__s);
1129 _M_check_length(size_type(0), __n,
"basic_string::append");
1130 return _M_append(__s, __n);
1142 append(size_type __n, _CharT __c)
1143 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1145 #if __cplusplus >= 201103L 1152 append(initializer_list<_CharT> __l)
1153 {
return this->
append(__l.begin(), __l.size()); }
1164 #if __cplusplus >= 201103L 1165 template<
class _InputIterator,
1166 typename = std::_RequireInputIter<_InputIterator>>
1168 template<
class _InputIterator>
1171 append(_InputIterator __first, _InputIterator __last)
1181 const size_type __size = this->
size();
1183 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1184 traits_type::assign(this->_M_data()[__size], __c);
1185 this->_M_set_length(__size + 1);
1194 assign(
const basic_string& __str)
1196 this->_M_assign(__str);
1200 #if __cplusplus >= 201103L 1210 assign(basic_string&& __str)
1211 noexcept(_Alloc_traits::_S_nothrow_move())
1215 return *
this = std::move(__str);
1233 assign(
const basic_string& __str, size_type __pos, size_type __n)
1234 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1235 + __str._M_check(__pos,
"basic_string::assign"),
1236 __str._M_limit(__pos, __n)); }
1249 assign(
const _CharT* __s, size_type __n)
1251 __glibcxx_requires_string_len(__s, __n);
1252 return _M_replace(size_type(0), this->
size(), __s, __n);
1265 assign(
const _CharT* __s)
1267 __glibcxx_requires_string(__s);
1268 return _M_replace(size_type(0), this->
size(), __s,
1269 traits_type::length(__s));
1282 assign(size_type __n, _CharT __c)
1283 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1293 #if __cplusplus >= 201103L 1294 template<
class _InputIterator,
1295 typename = std::_RequireInputIter<_InputIterator>>
1297 template<
class _InputIterator>
1300 assign(_InputIterator __first, _InputIterator __last)
1303 #if __cplusplus >= 201103L 1310 assign(initializer_list<_CharT> __l)
1311 {
return this->
assign(__l.begin(), __l.size()); }
1314 #if __cplusplus >= 201103L 1331 insert(const_iterator __p, size_type __n, _CharT __c)
1333 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1334 const size_type __pos = __p -
begin();
1335 this->
replace(__p, __p, __n, __c);
1336 return iterator(this->_M_data() + __pos);
1353 insert(iterator __p, size_type __n, _CharT __c)
1354 { this->
replace(__p, __p, __n, __c); }
1357 #if __cplusplus >= 201103L 1372 template<
class _InputIterator,
1373 typename = std::_RequireInputIter<_InputIterator>>
1375 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1377 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1378 const size_type __pos = __p -
begin();
1379 this->
replace(__p, __p, __beg, __end);
1380 return iterator(this->_M_data() + __pos);
1395 template<
class _InputIterator>
1397 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1398 { this->
replace(__p, __p, __beg, __end); }
1401 #if __cplusplus >= 201103L 1409 insert(iterator __p, initializer_list<_CharT> __l)
1411 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1412 this->
insert(__p -
begin(), __l.begin(), __l.size());
1429 insert(size_type __pos1,
const basic_string& __str)
1430 {
return this->
replace(__pos1, size_type(0),
1431 __str._M_data(), __str.size()); }
1452 insert(size_type __pos1,
const basic_string& __str,
1453 size_type __pos2, size_type __n)
1454 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1455 + __str._M_check(__pos2,
"basic_string::insert"),
1456 __str._M_limit(__pos2, __n)); }
1475 insert(size_type __pos,
const _CharT* __s, size_type __n)
1476 {
return this->
replace(__pos, size_type(0), __s, __n); }
1494 insert(size_type __pos,
const _CharT* __s)
1496 __glibcxx_requires_string(__s);
1497 return this->
replace(__pos, size_type(0), __s,
1498 traits_type::length(__s));
1518 insert(size_type __pos, size_type __n, _CharT __c)
1519 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1520 size_type(0), __n, __c); }
1536 insert(__const_iterator __p, _CharT __c)
1538 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1539 const size_type __pos = __p -
begin();
1540 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1541 return iterator(_M_data() + __pos);
1560 erase(size_type __pos = 0, size_type __n = npos)
1562 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1563 _M_limit(__pos, __n));
1576 erase(__const_iterator __position)
1578 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1579 && __position <
end());
1580 const size_type __pos = __position -
begin();
1581 this->_M_erase(__pos, size_type(1));
1582 return iterator(_M_data() + __pos);
1595 erase(__const_iterator __first, __const_iterator __last)
1597 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1598 && __last <=
end());
1599 const size_type __pos = __first -
begin();
1600 this->_M_erase(__pos, __last - __first);
1601 return iterator(this->_M_data() + __pos);
1604 #if __cplusplus >= 201103L 1613 __glibcxx_assert(!
empty());
1614 _M_erase(
size() - 1, 1);
1636 replace(size_type __pos, size_type __n,
const basic_string& __str)
1637 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1658 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1659 size_type __pos2, size_type __n2)
1660 {
return this->
replace(__pos1, __n1, __str._M_data()
1661 + __str._M_check(__pos2,
"basic_string::replace"),
1662 __str._M_limit(__pos2, __n2)); }
1683 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1686 __glibcxx_requires_string_len(__s, __n2);
1687 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1688 _M_limit(__pos, __n1), __s, __n2);
1708 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1710 __glibcxx_requires_string(__s);
1711 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1732 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1733 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1734 _M_limit(__pos, __n1), __n2, __c); }
1750 replace(__const_iterator __i1, __const_iterator __i2,
1751 const basic_string& __str)
1752 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1770 replace(__const_iterator __i1, __const_iterator __i2,
1771 const _CharT* __s, size_type __n)
1773 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1775 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1792 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1794 __glibcxx_requires_string(__s);
1795 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1813 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1816 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1818 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1836 #if __cplusplus >= 201103L 1837 template<
class _InputIterator,
1838 typename = std::_RequireInputIter<_InputIterator>>
1840 replace(const_iterator __i1, const_iterator __i2,
1841 _InputIterator __k1, _InputIterator __k2)
1843 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1845 __glibcxx_requires_valid_range(__k1, __k2);
1846 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1847 std::__false_type());
1850 template<
class _InputIterator>
1851 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1852 typename __enable_if_not_native_iterator<_InputIterator>::__type
1856 replace(iterator __i1, iterator __i2,
1857 _InputIterator __k1, _InputIterator __k2)
1859 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1861 __glibcxx_requires_valid_range(__k1, __k2);
1862 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1863 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1870 replace(__const_iterator __i1, __const_iterator __i2,
1871 _CharT* __k1, _CharT* __k2)
1873 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1875 __glibcxx_requires_valid_range(__k1, __k2);
1881 replace(__const_iterator __i1, __const_iterator __i2,
1882 const _CharT* __k1,
const _CharT* __k2)
1884 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1886 __glibcxx_requires_valid_range(__k1, __k2);
1892 replace(__const_iterator __i1, __const_iterator __i2,
1893 iterator __k1, iterator __k2)
1895 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1897 __glibcxx_requires_valid_range(__k1, __k2);
1899 __k1.base(), __k2 - __k1);
1903 replace(__const_iterator __i1, __const_iterator __i2,
1904 const_iterator __k1, const_iterator __k2)
1906 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1908 __glibcxx_requires_valid_range(__k1, __k2);
1910 __k1.base(), __k2 - __k1);
1913 #if __cplusplus >= 201103L 1928 basic_string&
replace(const_iterator __i1, const_iterator __i2,
1929 initializer_list<_CharT> __l)
1930 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1934 template<
class _Integer>
1936 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1937 _Integer __n, _Integer __val, __true_type)
1938 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1940 template<
class _InputIterator>
1942 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1943 _InputIterator __k1, _InputIterator __k2,
1947 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1951 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1952 const size_type __len2);
1955 _M_append(
const _CharT* __s, size_type __n);
1972 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1982 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
1992 c_str() const _GLIBCXX_NOEXCEPT
1993 {
return _M_data(); }
2002 data() const _GLIBCXX_NOEXCEPT
2003 {
return _M_data(); }
2010 {
return _M_get_allocator(); }
2025 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2038 find(
const basic_string& __str, size_type __pos = 0) const
2040 {
return this->
find(__str.data(), __pos, __str.size()); }
2053 find(
const _CharT* __s, size_type __pos = 0)
const 2055 __glibcxx_requires_string(__s);
2056 return this->
find(__s, __pos, traits_type::length(__s));
2070 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2083 rfind(const basic_string& __str, size_type __pos = npos) const
2085 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2100 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2113 rfind(
const _CharT* __s, size_type __pos = npos)
const 2115 __glibcxx_requires_string(__s);
2116 return this->
rfind(__s, __pos, traits_type::length(__s));
2130 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
2144 find_first_of(
const basic_string& __str, size_type __pos = 0) const
2146 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2161 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2176 __glibcxx_requires_string(__s);
2177 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2193 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2194 {
return this->
find(__c, __pos); }
2208 find_last_of(
const basic_string& __str, size_type __pos = npos)
const 2210 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2225 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2238 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2240 __glibcxx_requires_string(__s);
2241 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2257 find_last_of(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT
2258 {
return this->
rfind(__c, __pos); }
2289 size_type __n)
const;
2304 __glibcxx_requires_string(__s);
2352 size_type __n)
const;
2367 __glibcxx_requires_string(__s);
2398 substr(size_type __pos = 0, size_type __n = npos)
const 2400 _M_check(__pos,
"basic_string::substr"), __n); }
2417 compare(
const basic_string& __str)
const 2419 const size_type __size = this->
size();
2420 const size_type __osize = __str.size();
2421 const size_type __len =
std::min(__size, __osize);
2423 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2425 __r = _S_compare(__size, __osize);
2449 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2475 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2476 size_type __pos2, size_type __n2)
const;
2493 compare(
const _CharT* __s)
const;
2517 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2544 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2545 size_type __n2)
const;
2548 template<
typename,
typename,
typename>
friend class basic_stringbuf;
2550 _GLIBCXX_END_NAMESPACE_CXX11
2551 #else // !_GLIBCXX_USE_CXX11_ABI 2616 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2619 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2623 typedef _Traits traits_type;
2624 typedef typename _Traits::char_type value_type;
2625 typedef _Alloc allocator_type;
2626 typedef typename _CharT_alloc_type::size_type size_type;
2627 typedef typename _CharT_alloc_type::difference_type difference_type;
2628 typedef typename _CharT_alloc_type::reference reference;
2629 typedef typename _CharT_alloc_type::const_reference const_reference;
2630 typedef typename _CharT_alloc_type::pointer pointer;
2631 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2632 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2633 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2655 size_type _M_length;
2656 size_type _M_capacity;
2657 _Atomic_word _M_refcount;
2660 struct _Rep : _Rep_base
2663 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2678 static const size_type _S_max_size;
2679 static const _CharT _S_terminal;
2683 static size_type _S_empty_rep_storage[];
2686 _S_empty_rep() _GLIBCXX_NOEXCEPT
2691 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2692 return *
reinterpret_cast<_Rep*
>(__p);
2696 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2698 #if defined(__GTHREADS) 2703 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
2705 return this->_M_refcount < 0;
2710 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2712 #if defined(__GTHREADS) 2718 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
2720 return this->_M_refcount > 0;
2725 _M_set_leaked() _GLIBCXX_NOEXCEPT
2726 { this->_M_refcount = -1; }
2729 _M_set_sharable() _GLIBCXX_NOEXCEPT
2730 { this->_M_refcount = 0; }
2733 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2735 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2736 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2739 this->_M_set_sharable();
2740 this->_M_length = __n;
2741 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2748 _M_refdata()
throw()
2749 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2752 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2754 return (!_M_is_leaked() && __alloc1 == __alloc2)
2755 ? _M_refcopy() : _M_clone(__alloc1);
2760 _S_create(size_type, size_type,
const _Alloc&);
2763 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2765 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2766 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2770 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2779 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2782 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2789 _M_destroy(
const _Alloc&)
throw();
2792 _M_refcopy()
throw()
2794 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2795 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2797 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2798 return _M_refdata();
2802 _M_clone(
const _Alloc&, size_type __res = 0);
2806 struct _Alloc_hider : _Alloc
2808 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2809 : _Alloc(__a), _M_p(__dat) { }
2819 static const size_type npos =
static_cast<size_type
>(-1);
2823 mutable _Alloc_hider _M_dataplus;
2826 _M_data() const _GLIBCXX_NOEXCEPT
2827 {
return _M_dataplus._M_p; }
2830 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2831 {
return (_M_dataplus._M_p = __p); }
2834 _M_rep()
const _GLIBCXX_NOEXCEPT
2835 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2840 _M_ibegin()
const _GLIBCXX_NOEXCEPT
2841 {
return iterator(_M_data()); }
2844 _M_iend()
const _GLIBCXX_NOEXCEPT
2845 {
return iterator(_M_data() + this->
size()); }
2850 if (!_M_rep()->_M_is_leaked())
2855 _M_check(size_type __pos,
const char* __s)
const 2857 if (__pos > this->
size())
2858 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2859 "this->size() (which is %zu)"),
2860 __s, __pos, this->
size());
2865 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2868 __throw_length_error(__N(__s));
2873 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2875 const bool __testoff = __off < this->
size() - __pos;
2876 return __testoff ? __off : this->
size() - __pos;
2881 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2890 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2893 traits_type::assign(*__d, *__s);
2895 traits_type::copy(__d, __s, __n);
2899 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2902 traits_type::assign(*__d, *__s);
2904 traits_type::move(__d, __s, __n);
2908 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2911 traits_type::assign(*__d, __c);
2913 traits_type::assign(__d, __n, __c);
2918 template<
class _Iterator>
2920 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2922 for (; __k1 != __k2; ++__k1, (void)++__p)
2923 traits_type::assign(*__p, *__k1);
2927 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2928 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2931 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2933 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2936 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2937 { _M_copy(__p, __k1, __k2 - __k1); }
2940 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2942 { _M_copy(__p, __k1, __k2 - __k1); }
2945 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2947 const difference_type __d = difference_type(__n1 - __n2);
2949 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2950 return __gnu_cxx::__numeric_traits<int>::__max;
2951 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2952 return __gnu_cxx::__numeric_traits<int>::__min;
2958 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2964 _S_empty_rep() _GLIBCXX_NOEXCEPT
2965 {
return _Rep::_S_empty_rep(); }
2976 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2977 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2979 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3000 basic_string(
const basic_string& __str, size_type __pos,
3001 size_type __n = npos);
3009 basic_string(
const basic_string& __str, size_type __pos,
3010 size_type __n,
const _Alloc& __a);
3022 const _Alloc& __a = _Alloc());
3028 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3035 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3037 #if __cplusplus >= 201103L 3046 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3049 : _M_dataplus(__str._M_dataplus)
3051 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3052 __str._M_data(_S_empty_rep()._M_refdata());
3054 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3072 template<
class _InputIterator>
3073 basic_string(_InputIterator __beg, _InputIterator __end,
3074 const _Alloc& __a = _Alloc());
3088 {
return this->
assign(__str); }
3096 {
return this->
assign(__s); }
3112 #if __cplusplus >= 201103L 3136 this->
assign(__l.begin(), __l.size());
3150 return iterator(_M_data());
3159 {
return const_iterator(_M_data()); }
3169 return iterator(_M_data() + this->
size());
3178 {
return const_iterator(_M_data() + this->
size()); }
3187 {
return reverse_iterator(this->
end()); }
3194 const_reverse_iterator
3196 {
return const_reverse_iterator(this->
end()); }
3205 {
return reverse_iterator(this->
begin()); }
3212 const_reverse_iterator
3214 {
return const_reverse_iterator(this->
begin()); }
3216 #if __cplusplus >= 201103L 3223 {
return const_iterator(this->_M_data()); }
3231 {
return const_iterator(this->_M_data() + this->
size()); }
3238 const_reverse_iterator
3240 {
return const_reverse_iterator(this->
end()); }
3247 const_reverse_iterator
3249 {
return const_reverse_iterator(this->
begin()); }
3258 {
return _M_rep()->_M_length; }
3264 {
return _M_rep()->_M_length; }
3269 {
return _Rep::_S_max_size; }
3282 resize(size_type __n, _CharT __c);
3296 { this->
resize(__n, _CharT()); }
3298 #if __cplusplus >= 201103L 3303 #if __cpp_exceptions 3321 {
return _M_rep()->_M_capacity; }
3341 reserve(size_type __res_arg = 0);
3349 { _M_mutate(0, this->
size(), 0); }
3357 {
return this->
size() == 0; }
3373 __glibcxx_assert(__pos <=
size());
3374 return _M_data()[__pos];
3392 __glibcxx_assert(__pos <=
size());
3394 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3396 return _M_data()[__pos];
3412 if (__n >= this->
size())
3413 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3414 "(which is %zu) >= this->size() " 3417 return _M_data()[__n];
3435 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3436 "(which is %zu) >= this->size() " 3440 return _M_data()[__n];
3443 #if __cplusplus >= 201103L 3451 __glibcxx_assert(!
empty());
3462 __glibcxx_assert(!
empty());
3473 __glibcxx_assert(!
empty());
3484 __glibcxx_assert(!
empty());
3497 {
return this->
append(__str); }
3506 {
return this->
append(__s); }
3520 #if __cplusplus >= 201103L 3528 {
return this->
append(__l.begin(), __l.size()); }
3537 append(
const basic_string& __str);
3553 append(
const basic_string& __str, size_type __pos, size_type __n);
3562 append(
const _CharT* __s, size_type __n);
3572 __glibcxx_requires_string(__s);
3573 return this->
append(__s, traits_type::length(__s));
3585 append(size_type __n, _CharT __c);
3587 #if __cplusplus >= 201103L 3595 {
return this->
append(__l.begin(), __l.size()); }
3606 template<
class _InputIterator>
3608 append(_InputIterator __first, _InputIterator __last)
3609 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3618 const size_type __len = 1 + this->
size();
3619 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3621 traits_type::assign(_M_data()[this->
size()], __c);
3622 _M_rep()->_M_set_length_and_sharable(__len);
3631 assign(
const basic_string& __str);
3633 #if __cplusplus >= 201103L 3665 assign(
const basic_string& __str, size_type __pos, size_type __n)
3666 {
return this->
assign(__str._M_data()
3667 + __str._M_check(__pos,
"basic_string::assign"),
3668 __str._M_limit(__pos, __n)); }
3681 assign(
const _CharT* __s, size_type __n);
3695 __glibcxx_requires_string(__s);
3696 return this->
assign(__s, traits_type::length(__s));
3710 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3720 template<
class _InputIterator>
3722 assign(_InputIterator __first, _InputIterator __last)
3723 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3725 #if __cplusplus >= 201103L 3733 {
return this->
assign(__l.begin(), __l.size()); }
3750 insert(iterator __p, size_type __n, _CharT __c)
3751 { this->
replace(__p, __p, __n, __c); }
3765 template<
class _InputIterator>
3767 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3768 { this->
replace(__p, __p, __beg, __end); }
3770 #if __cplusplus >= 201103L 3780 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3781 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3798 insert(size_type __pos1,
const basic_string& __str)
3799 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3820 insert(size_type __pos1,
const basic_string& __str,
3821 size_type __pos2, size_type __n)
3822 {
return this->
insert(__pos1, __str._M_data()
3823 + __str._M_check(__pos2,
"basic_string::insert"),
3824 __str._M_limit(__pos2, __n)); }
3843 insert(size_type __pos,
const _CharT* __s, size_type __n);
3863 __glibcxx_requires_string(__s);
3864 return this->
insert(__pos, __s, traits_type::length(__s));
3884 insert(size_type __pos, size_type __n, _CharT __c)
3885 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3886 size_type(0), __n, __c); }
3904 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3905 const size_type __pos = __p - _M_ibegin();
3906 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3907 _M_rep()->_M_set_leaked();
3908 return iterator(_M_data() + __pos);
3927 erase(size_type __pos = 0, size_type __n = npos)
3929 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3930 _M_limit(__pos, __n), size_type(0));
3945 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3946 && __position < _M_iend());
3947 const size_type __pos = __position - _M_ibegin();
3948 _M_mutate(__pos, size_type(1), size_type(0));
3949 _M_rep()->_M_set_leaked();
3950 return iterator(_M_data() + __pos);
3963 erase(iterator __first, iterator __last);
3965 #if __cplusplus >= 201103L 3974 __glibcxx_assert(!
empty());
3997 replace(size_type __pos, size_type __n,
const basic_string& __str)
3998 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4019 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4020 size_type __pos2, size_type __n2)
4021 {
return this->
replace(__pos1, __n1, __str._M_data()
4022 + __str._M_check(__pos2,
"basic_string::replace"),
4023 __str._M_limit(__pos2, __n2)); }
4044 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4064 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4066 __glibcxx_requires_string(__s);
4067 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4088 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4089 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4090 _M_limit(__pos, __n1), __n2, __c); }
4106 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4107 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4125 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4127 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4128 && __i2 <= _M_iend());
4129 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4146 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4148 __glibcxx_requires_string(__s);
4149 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4167 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4169 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4170 && __i2 <= _M_iend());
4171 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4189 template<
class _InputIterator>
4192 _InputIterator __k1, _InputIterator __k2)
4194 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4195 && __i2 <= _M_iend());
4196 __glibcxx_requires_valid_range(__k1, __k2);
4197 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4198 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4204 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4206 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4207 && __i2 <= _M_iend());
4208 __glibcxx_requires_valid_range(__k1, __k2);
4209 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4214 replace(iterator __i1, iterator __i2,
4215 const _CharT* __k1,
const _CharT* __k2)
4217 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4218 && __i2 <= _M_iend());
4219 __glibcxx_requires_valid_range(__k1, __k2);
4220 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4225 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4227 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4228 && __i2 <= _M_iend());
4229 __glibcxx_requires_valid_range(__k1, __k2);
4230 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4231 __k1.base(), __k2 - __k1);
4235 replace(iterator __i1, iterator __i2,
4236 const_iterator __k1, const_iterator __k2)
4238 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4239 && __i2 <= _M_iend());
4240 __glibcxx_requires_valid_range(__k1, __k2);
4241 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4242 __k1.base(), __k2 - __k1);
4245 #if __cplusplus >= 201103L 4260 basic_string&
replace(iterator __i1, iterator __i2,
4262 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4266 template<
class _Integer>
4268 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4269 _Integer __val, __true_type)
4270 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4272 template<
class _InputIterator>
4274 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4275 _InputIterator __k2, __false_type);
4278 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4282 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4287 template<
class _InIterator>
4289 _S_construct_aux(_InIterator __beg, _InIterator __end,
4290 const _Alloc& __a, __false_type)
4292 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4293 return _S_construct(__beg, __end, __a, _Tag());
4298 template<
class _Integer>
4300 _S_construct_aux(_Integer __beg, _Integer __end,
4301 const _Alloc& __a, __true_type)
4302 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4306 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4307 {
return _S_construct(__req, __c, __a); }
4309 template<
class _InIterator>
4311 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4313 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4314 return _S_construct_aux(__beg, __end, __a, _Integral());
4318 template<
class _InIterator>
4320 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4325 template<
class _FwdIterator>
4327 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4331 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4348 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4359 swap(basic_string& __s);
4370 {
return _M_data(); }
4380 {
return _M_data(); }
4387 {
return _M_dataplus; }
4402 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4415 find(
const basic_string& __str, size_type __pos = 0) const
4417 {
return this->
find(__str.data(), __pos, __str.size()); }
4430 find(
const _CharT* __s, size_type __pos = 0)
const 4432 __glibcxx_requires_string(__s);
4433 return this->
find(__s, __pos, traits_type::length(__s));
4447 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4460 rfind(
const basic_string& __str, size_type __pos = npos)
const 4462 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4477 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4490 rfind(
const _CharT* __s, size_type __pos = npos)
const 4492 __glibcxx_requires_string(__s);
4493 return this->
rfind(__s, __pos, traits_type::length(__s));
4507 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4523 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4538 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4553 __glibcxx_requires_string(__s);
4554 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4571 {
return this->
find(__c, __pos); }
4587 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4602 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4617 __glibcxx_requires_string(__s);
4618 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4635 {
return this->
rfind(__c, __pos); }
4666 size_type __n)
const;
4681 __glibcxx_requires_string(__s);
4729 size_type __n)
const;
4744 __glibcxx_requires_string(__s);
4775 substr(size_type __pos = 0, size_type __n = npos)
const 4777 _M_check(__pos,
"basic_string::substr"), __n); }
4796 const size_type __size = this->
size();
4797 const size_type __osize = __str.size();
4798 const size_type __len =
std::min(__size, __osize);
4800 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4802 __r = _S_compare(__size, __osize);
4826 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
4852 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
4853 size_type __pos2, size_type __n2)
const;
4870 compare(
const _CharT* __s)
const;
4894 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4921 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4922 size_type __n2)
const;
4924 # ifdef _GLIBCXX_TM_TS_INTERNAL 4926 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
4929 ::_txnal_cow_string_c_str(
const void *that);
4931 ::_txnal_cow_string_D1(
void *that);
4933 ::_txnal_cow_string_D1_commit(
void *that);
4936 #endif // !_GLIBCXX_USE_CXX11_ABI 4945 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4951 __str.append(__rhs);
4961 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4972 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4985 const _CharT* __rhs)
4988 __str.append(__rhs);
4998 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5003 typedef typename __string_type::size_type __size_type;
5004 __string_type __str(__lhs);
5005 __str.append(__size_type(1), __rhs);
5009 #if __cplusplus >= 201103L 5010 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5014 {
return 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>
5027 const auto __size = __lhs.size() + __rhs.size();
5028 const bool __cond = (__size > __lhs.capacity()
5029 && __size <= __rhs.capacity());
5030 return __cond ? std::move(__rhs.insert(0, __lhs))
5031 : std::move(__lhs.append(__rhs));
5034 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5038 {
return std::move(__rhs.insert(0, __lhs)); }
5040 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5044 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5046 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5049 const _CharT* __rhs)
5050 {
return std::move(__lhs.append(__rhs)); }
5052 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5056 {
return std::move(__lhs.append(1, __rhs)); }
5066 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5071 {
return __lhs.compare(__rhs) == 0; }
5073 template<
typename _CharT>
5075 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5078 {
return (__lhs.
size() == __rhs.
size()
5088 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5090 operator==(
const _CharT* __lhs,
5092 {
return __rhs.compare(__lhs) == 0; }
5100 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5103 const _CharT* __rhs)
5104 {
return __lhs.compare(__rhs) == 0; }
5113 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5118 {
return !(__lhs == __rhs); }
5126 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5128 operator!=(
const _CharT* __lhs,
5130 {
return !(__lhs == __rhs); }
5138 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5141 const _CharT* __rhs)
5142 {
return !(__lhs == __rhs); }
5151 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5153 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5156 {
return __lhs.
compare(__rhs) < 0; }
5164 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5166 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5167 const _CharT* __rhs)
5168 {
return __lhs.
compare(__rhs) < 0; }
5176 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5178 operator<(
const _CharT* __lhs,
5180 {
return __rhs.compare(__lhs) > 0; }
5189 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5194 {
return __lhs.compare(__rhs) > 0; }
5202 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5205 const _CharT* __rhs)
5206 {
return __lhs.compare(__rhs) > 0; }
5214 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5216 operator>(
const _CharT* __lhs,
5218 {
return __rhs.compare(__lhs) < 0; }
5227 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5229 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5232 {
return __lhs.
compare(__rhs) <= 0; }
5240 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5242 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5243 const _CharT* __rhs)
5244 {
return __lhs.
compare(__rhs) <= 0; }
5252 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5254 operator<=(
const _CharT* __lhs,
5256 {
return __rhs.compare(__lhs) >= 0; }
5265 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5270 {
return __lhs.compare(__rhs) >= 0; }
5278 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5281 const _CharT* __rhs)
5282 {
return __lhs.compare(__rhs) >= 0; }
5290 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5292 operator>=(
const _CharT* __lhs,
5294 {
return __rhs.compare(__lhs) <= 0; }
5303 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5307 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5308 { __lhs.swap(__rhs); }
5323 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5341 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5343 operator<<(basic_ostream<_CharT, _Traits>& __os,
5348 return __ostream_insert(__os, __str.
data(), __str.
size());
5364 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5381 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5387 #if __cplusplus >= 201103L 5389 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5396 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5408 #ifdef _GLIBCXX_USE_WCHAR_T 5415 _GLIBCXX_END_NAMESPACE_VERSION
5418 #if __cplusplus >= 201103L 5422 namespace std _GLIBCXX_VISIBILITY(default)
5424 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5425 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5427 #if _GLIBCXX_USE_C99_STDLIB 5430 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5431 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5435 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5436 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5439 inline unsigned long 5440 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5441 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5445 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5446 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5449 inline unsigned long long 5450 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5451 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5456 stof(
const string& __str,
size_t* __idx = 0)
5457 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5460 stod(
const string& __str,
size_t* __idx = 0)
5461 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5464 stold(
const string& __str,
size_t* __idx = 0)
5465 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5466 #endif // _GLIBCXX_USE_C99_STDLIB 5468 #if _GLIBCXX_USE_C99_STDIO 5473 to_string(
int __val)
5474 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5478 to_string(
unsigned __val)
5479 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5480 4 *
sizeof(unsigned),
5484 to_string(
long __val)
5485 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5489 to_string(
unsigned long __val)
5490 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5491 4 *
sizeof(
unsigned long),
5495 to_string(
long long __val)
5496 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5497 4 *
sizeof(
long long),
5501 to_string(
unsigned long long __val)
5502 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5503 4 *
sizeof(
unsigned long long),
5507 to_string(
float __val)
5510 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5511 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5516 to_string(
double __val)
5519 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5520 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5525 to_string(
long double __val)
5528 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5529 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5532 #endif // _GLIBCXX_USE_C99_STDIO 5534 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 5536 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5537 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5541 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5542 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5545 inline unsigned long 5546 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5547 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5551 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5552 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5555 inline unsigned long long 5556 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5557 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5562 stof(
const wstring& __str,
size_t* __idx = 0)
5563 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5566 stod(
const wstring& __str,
size_t* __idx = 0)
5567 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5570 stold(
const wstring& __str,
size_t* __idx = 0)
5571 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5573 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5576 to_wstring(
int __val)
5577 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5581 to_wstring(
unsigned __val)
5582 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5583 4 *
sizeof(unsigned),
5587 to_wstring(
long __val)
5588 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5592 to_wstring(
unsigned long __val)
5593 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5594 4 *
sizeof(
unsigned long),
5598 to_wstring(
long long __val)
5599 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5600 4 *
sizeof(
long long),
5604 to_wstring(
unsigned long long __val)
5605 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5606 4 *
sizeof(
unsigned long long),
5610 to_wstring(
float __val)
5613 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5614 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5619 to_wstring(
double __val)
5622 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5623 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5628 to_wstring(
long double __val)
5631 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5632 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5635 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5636 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 5638 _GLIBCXX_END_NAMESPACE_CXX11
5639 _GLIBCXX_END_NAMESPACE_VERSION
5644 #if __cplusplus >= 201103L 5648 namespace std _GLIBCXX_VISIBILITY(default)
5650 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5654 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5658 :
public __hash_base<size_t, string>
5661 operator()(
const string& __s)
const noexcept
5662 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5669 #ifdef _GLIBCXX_USE_WCHAR_T 5673 :
public __hash_base<size_t, wstring>
5676 operator()(
const wstring& __s)
const noexcept
5677 {
return std::_Hash_impl::hash(__s.
data(),
5678 __s.
length() *
sizeof(wchar_t)); }
5687 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5691 :
public __hash_base<size_t, u16string>
5694 operator()(
const u16string& __s)
const noexcept
5695 {
return std::_Hash_impl::hash(__s.
data(),
5696 __s.
length() *
sizeof(char16_t)); }
5706 :
public __hash_base<size_t, u32string>
5709 operator()(
const u32string& __s)
const noexcept
5710 {
return std::_Hash_impl::hash(__s.
data(),
5711 __s.
length() *
sizeof(char32_t)); }
5719 _GLIBCXX_END_NAMESPACE_VERSION
5721 #if __cplusplus > 201103L 5723 #define __cpp_lib_string_udls 201304 5725 inline namespace literals
5727 inline namespace string_literals
5729 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5731 _GLIBCXX_DEFAULT_ABI_TAG
5733 operator""s(
const char* __str,
size_t __len)
5736 #ifdef _GLIBCXX_USE_WCHAR_T 5737 _GLIBCXX_DEFAULT_ABI_TAG
5739 operator""s(
const wchar_t* __str,
size_t __len)
5743 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5744 _GLIBCXX_DEFAULT_ABI_TAG
5746 operator""s(
const char16_t* __str,
size_t __len)
5749 _GLIBCXX_DEFAULT_ABI_TAG
5751 operator""s(
const char32_t* __str,
size_t __len)
5755 _GLIBCXX_END_NAMESPACE_VERSION
5759 #endif // __cplusplus > 201103L size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
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.
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 & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Template class basic_ostream.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
Uniform interface to C++98 and C++11 allocators.
const_reverse_iterator rbegin() const noexcept
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
bool empty() const noexcept
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
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.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
Managing sequences of characters and character-like objects.
basic_string(basic_string &&__str) noexcept
Move construct string.
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.
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(size_type __n, _CharT __c)
Set value to multiple characters.
const_iterator cend() const noexcept
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
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 cbegin() const noexcept
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
const_reference back() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.
One of the comparison functors.
void pop_back()
Remove the last character.
Forward iterators support a superset of input iterator operations.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
const_iterator end() const noexcept
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
const_reverse_iterator rend() const noexcept
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_iterator begin() const noexcept
const_reference at(size_type __n) const
Provides access to the data contained in the string.
Template class basic_istream.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
reverse_iterator rbegin()
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)
Append a character.
iterator erase(iterator __position)
Remove one character.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
char_type widen(char __c) const
Widens characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
ISO C++ entities toplevel namespace is std.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
void push_back(_CharT __c)
Append a single character.
~basic_string() noexcept
Destroy the string instance.
basic_string()
Default constructor creates an empty string.
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 resize(size_type __n)
Resizes the string to the specified number of characters.
Primary class template hash.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
Uniform interface to all pointer-like types.
basic_string & assign(const _CharT *__s)
Set value to contents of a C 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.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_reference front() const noexcept
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
void swap(basic_string &__s)
Swap contents with another string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & append(const _CharT *__s)
Append a C string.
Basis for explicit traits specializations.
basic_string & operator+=(const _CharT *__s)
Append a C string.