34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 42 #if __cplusplus >= 201103L 46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 #if _GLIBCXX_USE_CXX11_ABI 51 _GLIBCXX_BEGIN_NAMESPACE_CXX11
70 template<
typename _CharT,
typename _Traits,
typename _Alloc>
74 rebind<_CharT>::other _Char_alloc_type;
79 typedef _Traits traits_type;
80 typedef typename _Traits::char_type value_type;
81 typedef _Char_alloc_type allocator_type;
82 typedef typename _Alloc_traits::size_type size_type;
83 typedef typename _Alloc_traits::difference_type difference_type;
84 typedef typename _Alloc_traits::reference reference;
85 typedef typename _Alloc_traits::const_reference const_reference;
86 typedef typename _Alloc_traits::pointer pointer;
87 typedef typename _Alloc_traits::const_pointer const_pointer;
88 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
89 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
95 static const size_type
npos =
static_cast<size_type
>(-1);
99 #if __cplusplus < 201103L 100 typedef iterator __const_iterator;
102 typedef const_iterator __const_iterator;
106 struct _Alloc_hider : allocator_type
108 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
109 : allocator_type(__a), _M_p(__dat) { }
114 _Alloc_hider _M_dataplus;
115 size_type _M_string_length;
117 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
121 _CharT _M_local_buf[_S_local_capacity + 1];
122 size_type _M_allocated_capacity;
127 { _M_dataplus._M_p = __p; }
130 _M_length(size_type __length)
131 { _M_string_length = __length; }
135 {
return _M_dataplus._M_p; }
140 #if __cplusplus >= 201103L 143 return pointer(_M_local_buf);
148 _M_local_data()
const 150 #if __cplusplus >= 201103L 153 return const_pointer(_M_local_buf);
158 _M_capacity(size_type __capacity)
159 { _M_allocated_capacity = __capacity; }
162 _M_set_length(size_type __n)
165 traits_type::assign(_M_data()[__n], _CharT());
170 {
return _M_data() == _M_local_data(); }
174 _M_create(size_type&, size_type);
180 _M_destroy(_M_allocated_capacity);
184 _M_destroy(size_type __size)
throw()
185 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
189 template<
typename _InIterator>
191 _M_construct_aux(_InIterator __beg, _InIterator __end,
194 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
195 _M_construct(__beg, __end, _Tag());
200 template<
typename _Integer>
202 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
203 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
206 _M_construct_aux_2(size_type __req, _CharT __c)
207 { _M_construct(__req, __c); }
209 template<
typename _InIterator>
211 _M_construct(_InIterator __beg, _InIterator __end)
213 typedef typename std::__is_integer<_InIterator>::__type _Integral;
214 _M_construct_aux(__beg, __end, _Integral());
218 template<
typename _InIterator>
220 _M_construct(_InIterator __beg, _InIterator __end,
225 template<
typename _FwdIterator>
227 _M_construct(_FwdIterator __beg, _FwdIterator __end,
231 _M_construct(size_type __req, _CharT __c);
235 {
return _M_dataplus; }
237 const allocator_type&
238 _M_get_allocator()
const 239 {
return _M_dataplus; }
243 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 246 template<
typename _Tp,
bool _Requires =
247 !__are_same<_Tp, _CharT*>::__value
248 && !__are_same<_Tp, const _CharT*>::__value
249 && !__are_same<_Tp, iterator>::__value
250 && !__are_same<_Tp, const_iterator>::__value>
251 struct __enable_if_not_native_iterator
253 template<
typename _Tp>
254 struct __enable_if_not_native_iterator<_Tp, false> { };
258 _M_check(size_type __pos,
const char* __s)
const 260 if (__pos > this->
size())
261 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 262 "this->size() (which is %zu)"),
263 __s, __pos, this->
size());
268 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 271 __throw_length_error(__N(__s));
277 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
279 const bool __testoff = __off < this->
size() - __pos;
280 return __testoff ? __off : this->
size() - __pos;
285 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
287 return (less<const _CharT*>()(__s, _M_data())
288 || less<const _CharT*>()(_M_data() + this->
size(), __s));
294 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
297 traits_type::assign(*__d, *__s);
299 traits_type::copy(__d, __s, __n);
303 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
306 traits_type::assign(*__d, *__s);
308 traits_type::move(__d, __s, __n);
312 _S_assign(_CharT* __d, size_type __n, _CharT __c)
315 traits_type::assign(*__d, __c);
317 traits_type::assign(__d, __n, __c);
322 template<
class _Iterator>
324 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
326 for (; __k1 != __k2; ++__k1, ++__p)
327 traits_type::assign(*__p, *__k1);
331 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
332 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
335 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
337 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
340 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
341 { _S_copy(__p, __k1, __k2 - __k1); }
344 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
346 { _S_copy(__p, __k1, __k2 - __k1); }
349 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
351 const difference_type __d = difference_type(__n1 - __n2);
353 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
354 return __gnu_cxx::__numeric_traits<int>::__max;
355 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
356 return __gnu_cxx::__numeric_traits<int>::__min;
365 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
369 _M_erase(size_type __pos, size_type __n);
380 #if __cplusplus >= 201103L 381 noexcept(is_nothrow_default_constructible<_Alloc>::value)
383 : _M_dataplus(_M_local_data())
384 { _M_set_length(0); }
391 : _M_dataplus(_M_local_data(), __a)
392 { _M_set_length(0); }
399 : _M_dataplus(_M_local_data(),
400 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
401 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
412 size_type __n = npos)
413 : _M_dataplus(_M_local_data())
415 const _CharT* __start = __str._M_data()
416 + __str._M_check(__pos,
"basic_string::basic_string");
417 _M_construct(__start, __start + __str._M_limit(__pos, __n));
427 basic_string(
const basic_string& __str, size_type __pos,
428 size_type __n,
const _Alloc& __a)
429 : _M_dataplus(_M_local_data(), __a)
431 const _CharT* __start
432 = __str._M_data() + __str._M_check(__pos,
"string::string");
433 _M_construct(__start, __start + __str._M_limit(__pos, __n));
446 const _Alloc& __a = _Alloc())
447 : _M_dataplus(_M_local_data(), __a)
448 { _M_construct(__s, __s + __n); }
455 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
456 : _M_dataplus(_M_local_data(), __a)
457 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
465 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
466 : _M_dataplus(_M_local_data(), __a)
467 { _M_construct(__n, __c); }
469 #if __cplusplus >= 201103L 478 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
480 if (__str._M_is_local())
482 traits_type::copy(_M_local_buf, __str._M_local_buf,
483 _S_local_capacity + 1);
487 _M_data(__str._M_data());
488 _M_capacity(__str._M_allocated_capacity);
494 _M_length(__str.length());
495 __str._M_data(__str._M_local_data());
496 __str._M_set_length(0);
504 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
505 : _M_dataplus(_M_local_data(), __a)
506 { _M_construct(__l.begin(), __l.end()); }
508 basic_string(
const basic_string& __str,
const _Alloc& __a)
509 : _M_dataplus(_M_local_data(), __a)
510 { _M_construct(__str.begin(), __str.end()); }
513 noexcept(_Alloc_traits::_S_always_equal())
514 : _M_dataplus(_M_local_data(), __a)
516 if (__str._M_is_local())
518 traits_type::copy(_M_local_buf, __str._M_local_buf,
519 _S_local_capacity + 1);
520 _M_length(__str.length());
521 __str._M_set_length(0);
523 else if (_Alloc_traits::_S_always_equal()
524 || __str.get_allocator() == __a)
526 _M_data(__str._M_data());
527 _M_length(__str.length());
528 _M_capacity(__str._M_allocated_capacity);
529 __str._M_data(__str._M_local_buf);
530 __str._M_set_length(0);
533 _M_construct(__str.begin(), __str.end());
544 #if __cplusplus >= 201103L 545 template<
typename _InputIterator,
546 typename = std::_RequireInputIter<_InputIterator>>
548 template<
typename _InputIterator>
550 basic_string(_InputIterator __beg, _InputIterator __end,
551 const _Alloc& __a = _Alloc())
552 : _M_dataplus(_M_local_data(), __a)
553 { _M_construct(__beg, __end); }
568 #if __cplusplus >= 201103L 569 if (_Alloc_traits::_S_propagate_on_copy_assign())
571 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
572 && _M_get_allocator() != __str._M_get_allocator())
575 _M_destroy(_M_allocated_capacity);
576 _M_data(_M_local_data());
579 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
582 return this->
assign(__str);
591 {
return this->
assign(__s); }
607 #if __cplusplus >= 201103L 620 noexcept(_Alloc_traits::_S_nothrow_move())
622 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
623 && !_Alloc_traits::_S_always_equal()
624 && _M_get_allocator() != __str._M_get_allocator())
627 _M_destroy(_M_allocated_capacity);
628 _M_data(_M_local_data());
632 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
634 if (!__str._M_is_local()
635 && (_Alloc_traits::_S_propagate_on_move_assign()
636 || _Alloc_traits::_S_always_equal()))
638 pointer __data =
nullptr;
639 size_type __capacity;
642 if (_Alloc_traits::_S_always_equal())
645 __capacity = _M_allocated_capacity;
648 _M_destroy(_M_allocated_capacity);
651 _M_data(__str._M_data());
652 _M_length(__str.length());
653 _M_capacity(__str._M_allocated_capacity);
656 __str._M_data(__data);
657 __str._M_capacity(__capacity);
660 __str._M_data(__str._M_local_buf);
675 this->
assign(__l.begin(), __l.size());
686 begin() _GLIBCXX_NOEXCEPT
687 {
return iterator(_M_data()); }
694 begin() const _GLIBCXX_NOEXCEPT
695 {
return const_iterator(_M_data()); }
702 end() _GLIBCXX_NOEXCEPT
703 {
return iterator(_M_data() + this->
size()); }
710 end() const _GLIBCXX_NOEXCEPT
711 {
return const_iterator(_M_data() + this->
size()); }
719 rbegin() _GLIBCXX_NOEXCEPT
720 {
return reverse_iterator(this->
end()); }
727 const_reverse_iterator
728 rbegin() const _GLIBCXX_NOEXCEPT
729 {
return const_reverse_iterator(this->
end()); }
737 rend() _GLIBCXX_NOEXCEPT
738 {
return reverse_iterator(this->
begin()); }
745 const_reverse_iterator
746 rend() const _GLIBCXX_NOEXCEPT
747 {
return const_reverse_iterator(this->
begin()); }
749 #if __cplusplus >= 201103L 756 {
return const_iterator(this->_M_data()); }
763 cend() const noexcept
764 {
return const_iterator(this->_M_data() + this->
size()); }
771 const_reverse_iterator
773 {
return const_reverse_iterator(this->
end()); }
780 const_reverse_iterator
781 crend() const noexcept
782 {
return const_reverse_iterator(this->
begin()); }
790 size() const _GLIBCXX_NOEXCEPT
791 {
return _M_string_length; }
796 length() const _GLIBCXX_NOEXCEPT
797 {
return _M_string_length; }
802 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
815 resize(size_type __n, _CharT __c);
829 { this->
resize(__n, _CharT()); }
831 #if __cplusplus >= 201103L 855 return _M_is_local() ? size_type(_S_local_capacity)
856 : _M_allocated_capacity;
877 reserve(size_type __res_arg = 0);
883 clear() _GLIBCXX_NOEXCEPT
884 { _M_set_length(0); }
891 empty() const _GLIBCXX_NOEXCEPT
892 {
return this->
size() == 0; }
906 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
908 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
909 return _M_data()[__pos];
927 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
929 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
930 return _M_data()[__pos];
944 at(size_type __n)
const 946 if (__n >= this->
size())
947 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 948 "(which is %zu) >= this->size() " 951 return _M_data()[__n];
968 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 969 "(which is %zu) >= this->size() " 972 return _M_data()[__n];
975 #if __cplusplus >= 201103L 989 front() const noexcept
1005 back() const noexcept
1017 {
return this->
append(__str); }
1026 {
return this->
append(__s); }
1040 #if __cplusplus >= 201103L 1048 {
return this->
append(__l.begin(), __l.size()); }
1057 append(
const basic_string& __str)
1058 {
return _M_append(__str._M_data(), __str.size()); }
1074 append(
const basic_string& __str, size_type __pos, size_type __n)
1075 {
return _M_append(__str._M_data()
1076 + __str._M_check(__pos,
"basic_string::append"),
1077 __str._M_limit(__pos, __n)); }
1086 append(
const _CharT* __s, size_type __n)
1088 __glibcxx_requires_string_len(__s, __n);
1089 _M_check_length(size_type(0), __n,
"basic_string::append");
1090 return _M_append(__s, __n);
1099 append(
const _CharT* __s)
1101 __glibcxx_requires_string(__s);
1102 const size_type __n = traits_type::length(__s);
1103 _M_check_length(size_type(0), __n,
"basic_string::append");
1104 return _M_append(__s, __n);
1116 append(size_type __n, _CharT __c)
1117 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1119 #if __cplusplus >= 201103L 1126 append(initializer_list<_CharT> __l)
1127 {
return this->
append(__l.begin(), __l.size()); }
1138 #if __cplusplus >= 201103L 1139 template<
class _InputIterator,
1140 typename = std::_RequireInputIter<_InputIterator>>
1142 template<
class _InputIterator>
1145 append(_InputIterator __first, _InputIterator __last)
1155 const size_type __size = this->
size();
1157 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1158 traits_type::assign(this->_M_data()[__size], __c);
1159 this->_M_set_length(__size + 1);
1168 assign(
const basic_string& __str)
1170 this->_M_assign(__str);
1174 #if __cplusplus >= 201103L 1184 assign(basic_string&& __str)
1185 noexcept(_Alloc_traits::_S_nothrow_move())
1189 return *
this = std::move(__str);
1207 assign(
const basic_string& __str, size_type __pos, size_type __n)
1208 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1209 + __str._M_check(__pos,
"basic_string::assign"),
1210 __str._M_limit(__pos, __n)); }
1223 assign(
const _CharT* __s, size_type __n)
1225 __glibcxx_requires_string_len(__s, __n);
1226 return _M_replace(size_type(0), this->
size(), __s, __n);
1239 assign(
const _CharT* __s)
1241 __glibcxx_requires_string(__s);
1242 return _M_replace(size_type(0), this->
size(), __s,
1243 traits_type::length(__s));
1256 assign(size_type __n, _CharT __c)
1257 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1267 #if __cplusplus >= 201103L 1268 template<
class _InputIterator,
1269 typename = std::_RequireInputIter<_InputIterator>>
1271 template<
class _InputIterator>
1274 assign(_InputIterator __first, _InputIterator __last)
1277 #if __cplusplus >= 201103L 1284 assign(initializer_list<_CharT> __l)
1285 {
return this->
assign(__l.begin(), __l.size()); }
1288 #if __cplusplus >= 201103L 1305 insert(const_iterator __p, size_type __n, _CharT __c)
1307 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1308 const size_type __pos = __p -
begin();
1309 this->
replace(__p, __p, __n, __c);
1310 return iterator(this->_M_data() + __pos);
1327 insert(iterator __p, size_type __n, _CharT __c)
1328 { this->
replace(__p, __p, __n, __c); }
1331 #if __cplusplus >= 201103L 1346 template<
class _InputIterator,
1347 typename = std::_RequireInputIter<_InputIterator>>
1349 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1351 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1352 const size_type __pos = __p -
begin();
1353 this->
replace(__p, __p, __beg, __end);
1354 return iterator(this->_M_data() + __pos);
1369 template<
class _InputIterator>
1371 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1372 { this->
replace(__p, __p, __beg, __end); }
1375 #if __cplusplus >= 201103L 1383 insert(iterator __p, initializer_list<_CharT> __l)
1385 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1386 this->
insert(__p -
begin(), __l.begin(), __l.size());
1403 insert(size_type __pos1,
const basic_string& __str)
1404 {
return this->
replace(__pos1, size_type(0),
1405 __str._M_data(), __str.size()); }
1426 insert(size_type __pos1,
const basic_string& __str,
1427 size_type __pos2, size_type __n)
1428 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1429 + __str._M_check(__pos2,
"basic_string::insert"),
1430 __str._M_limit(__pos2, __n)); }
1449 insert(size_type __pos,
const _CharT* __s, size_type __n)
1450 {
return this->
replace(__pos, size_type(0), __s, __n); }
1468 insert(size_type __pos,
const _CharT* __s)
1470 __glibcxx_requires_string(__s);
1471 return this->
replace(__pos, size_type(0), __s,
1472 traits_type::length(__s));
1492 insert(size_type __pos, size_type __n, _CharT __c)
1493 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1494 size_type(0), __n, __c); }
1510 insert(__const_iterator __p, _CharT __c)
1512 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1513 const size_type __pos = __p -
begin();
1514 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1515 return iterator(_M_data() + __pos);
1534 erase(size_type __pos = 0, size_type __n = npos)
1536 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1537 _M_limit(__pos, __n));
1550 erase(__const_iterator __position)
1552 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1553 && __position <
end());
1554 const size_type __pos = __position -
begin();
1555 this->_M_erase(__pos, size_type(1));
1556 return iterator(_M_data() + __pos);
1569 erase(__const_iterator __first, __const_iterator __last)
1571 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1572 && __last <=
end());
1573 const size_type __pos = __first -
begin();
1574 this->_M_erase(__pos, __last - __first);
1575 return iterator(this->_M_data() + __pos);
1578 #if __cplusplus >= 201103L 1586 { _M_erase(
size()-1, 1); }
1607 replace(size_type __pos, size_type __n,
const basic_string& __str)
1608 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1629 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1630 size_type __pos2, size_type __n2)
1631 {
return this->
replace(__pos1, __n1, __str._M_data()
1632 + __str._M_check(__pos2,
"basic_string::replace"),
1633 __str._M_limit(__pos2, __n2)); }
1654 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1657 __glibcxx_requires_string_len(__s, __n2);
1658 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1659 _M_limit(__pos, __n1), __s, __n2);
1679 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1681 __glibcxx_requires_string(__s);
1682 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1703 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1704 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1705 _M_limit(__pos, __n1), __n2, __c); }
1721 replace(__const_iterator __i1, __const_iterator __i2,
1722 const basic_string& __str)
1723 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1741 replace(__const_iterator __i1, __const_iterator __i2,
1742 const _CharT* __s, size_type __n)
1744 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1746 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1763 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1765 __glibcxx_requires_string(__s);
1766 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1784 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1787 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1789 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1807 #if __cplusplus >= 201103L 1808 template<
class _InputIterator,
1809 typename = std::_RequireInputIter<_InputIterator>>
1811 replace(const_iterator __i1, const_iterator __i2,
1812 _InputIterator __k1, _InputIterator __k2)
1814 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1816 __glibcxx_requires_valid_range(__k1, __k2);
1817 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1818 std::__false_type());
1821 template<
class _InputIterator>
1822 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1823 typename __enable_if_not_native_iterator<_InputIterator>::__type
1827 replace(iterator __i1, iterator __i2,
1828 _InputIterator __k1, _InputIterator __k2)
1830 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1832 __glibcxx_requires_valid_range(__k1, __k2);
1833 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1834 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1841 replace(__const_iterator __i1, __const_iterator __i2,
1842 _CharT* __k1, _CharT* __k2)
1844 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1846 __glibcxx_requires_valid_range(__k1, __k2);
1852 replace(__const_iterator __i1, __const_iterator __i2,
1853 const _CharT* __k1,
const _CharT* __k2)
1855 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1857 __glibcxx_requires_valid_range(__k1, __k2);
1863 replace(__const_iterator __i1, __const_iterator __i2,
1864 iterator __k1, iterator __k2)
1866 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1868 __glibcxx_requires_valid_range(__k1, __k2);
1870 __k1.base(), __k2 - __k1);
1874 replace(__const_iterator __i1, __const_iterator __i2,
1875 const_iterator __k1, const_iterator __k2)
1877 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1879 __glibcxx_requires_valid_range(__k1, __k2);
1881 __k1.base(), __k2 - __k1);
1884 #if __cplusplus >= 201103L 1899 basic_string&
replace(const_iterator __i1, const_iterator __i2,
1900 initializer_list<_CharT> __l)
1901 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1905 template<
class _Integer>
1907 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1908 _Integer __n, _Integer __val, __true_type)
1909 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1911 template<
class _InputIterator>
1913 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1914 _InputIterator __k1, _InputIterator __k2,
1918 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1922 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1923 const size_type __len2);
1926 _M_append(
const _CharT* __s, size_type __n);
1943 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1953 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
1963 c_str() const _GLIBCXX_NOEXCEPT
1964 {
return _M_data(); }
1973 data() const _GLIBCXX_NOEXCEPT
1974 {
return _M_data(); }
1981 {
return _M_get_allocator(); }
1996 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2009 find(
const basic_string& __str, size_type __pos = 0) const
2011 {
return this->
find(__str.data(), __pos, __str.size()); }
2024 find(
const _CharT* __s, size_type __pos = 0)
const 2026 __glibcxx_requires_string(__s);
2027 return this->
find(__s, __pos, traits_type::length(__s));
2041 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2054 rfind(const basic_string& __str, size_type __pos = npos) const
2056 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2071 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2084 rfind(
const _CharT* __s, size_type __pos = npos)
const 2086 __glibcxx_requires_string(__s);
2087 return this->
rfind(__s, __pos, traits_type::length(__s));
2101 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2115 find_first_of(const basic_string& __str, size_type __pos = 0) const
2117 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2132 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2147 __glibcxx_requires_string(__s);
2148 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2164 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2165 {
return this->
find(__c, __pos); }
2179 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2181 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2196 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2209 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2211 __glibcxx_requires_string(__s);
2212 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2228 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2229 {
return this->
rfind(__c, __pos); }
2260 size_type __n)
const;
2275 __glibcxx_requires_string(__s);
2323 size_type __n)
const;
2338 __glibcxx_requires_string(__s);
2369 substr(size_type __pos = 0, size_type __n = npos)
const 2371 _M_check(__pos,
"basic_string::substr"), __n); }
2388 compare(
const basic_string& __str)
const 2390 const size_type __size = this->
size();
2391 const size_type __osize = __str.size();
2392 const size_type __len =
std::min(__size, __osize);
2394 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2396 __r = _S_compare(__size, __osize);
2420 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2446 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2447 size_type __pos2, size_type __n2)
const;
2464 compare(
const _CharT* __s)
const;
2488 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2515 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2516 size_type __n2)
const;
2518 _GLIBCXX_END_NAMESPACE_CXX11
2519 #else // !_GLIBCXX_USE_CXX11_ABI 2584 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2587 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2591 typedef _Traits traits_type;
2592 typedef typename _Traits::char_type value_type;
2593 typedef _Alloc allocator_type;
2594 typedef typename _CharT_alloc_type::size_type size_type;
2595 typedef typename _CharT_alloc_type::difference_type difference_type;
2596 typedef typename _CharT_alloc_type::reference reference;
2597 typedef typename _CharT_alloc_type::const_reference const_reference;
2598 typedef typename _CharT_alloc_type::pointer pointer;
2599 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2600 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2601 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2623 size_type _M_length;
2624 size_type _M_capacity;
2625 _Atomic_word _M_refcount;
2628 struct _Rep : _Rep_base
2631 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2646 static const size_type _S_max_size;
2647 static const _CharT _S_terminal;
2651 static size_type _S_empty_rep_storage[];
2654 _S_empty_rep() _GLIBCXX_NOEXCEPT
2659 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2660 return *
reinterpret_cast<_Rep*
>(__p);
2664 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2665 {
return this->_M_refcount < 0; }
2668 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2669 {
return this->_M_refcount > 0; }
2672 _M_set_leaked() _GLIBCXX_NOEXCEPT
2673 { this->_M_refcount = -1; }
2676 _M_set_sharable() _GLIBCXX_NOEXCEPT
2677 { this->_M_refcount = 0; }
2680 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2682 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2683 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2686 this->_M_set_sharable();
2687 this->_M_length = __n;
2688 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2695 _M_refdata()
throw()
2696 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2699 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2701 return (!_M_is_leaked() && __alloc1 == __alloc2)
2702 ? _M_refcopy() : _M_clone(__alloc1);
2707 _S_create(size_type, size_type,
const _Alloc&);
2710 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2712 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2713 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2717 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2718 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2721 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2728 _M_destroy(
const _Alloc&)
throw();
2731 _M_refcopy()
throw()
2733 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2734 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2736 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2737 return _M_refdata();
2741 _M_clone(
const _Alloc&, size_type __res = 0);
2745 struct _Alloc_hider : _Alloc
2747 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2748 : _Alloc(__a), _M_p(__dat) { }
2758 static const size_type npos =
static_cast<size_type
>(-1);
2762 mutable _Alloc_hider _M_dataplus;
2765 _M_data() const _GLIBCXX_NOEXCEPT
2766 {
return _M_dataplus._M_p; }
2769 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2770 {
return (_M_dataplus._M_p = __p); }
2773 _M_rep()
const _GLIBCXX_NOEXCEPT
2774 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2779 _M_ibegin()
const _GLIBCXX_NOEXCEPT
2780 {
return iterator(_M_data()); }
2783 _M_iend()
const _GLIBCXX_NOEXCEPT
2784 {
return iterator(_M_data() + this->
size()); }
2789 if (!_M_rep()->_M_is_leaked())
2794 _M_check(size_type __pos,
const char* __s)
const 2796 if (__pos > this->
size())
2797 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2798 "this->size() (which is %zu)"),
2799 __s, __pos, this->
size());
2804 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2807 __throw_length_error(__N(__s));
2812 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2814 const bool __testoff = __off < this->
size() - __pos;
2815 return __testoff ? __off : this->
size() - __pos;
2820 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2829 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2832 traits_type::assign(*__d, *__s);
2834 traits_type::copy(__d, __s, __n);
2838 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2841 traits_type::assign(*__d, *__s);
2843 traits_type::move(__d, __s, __n);
2847 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2850 traits_type::assign(*__d, __c);
2852 traits_type::assign(__d, __n, __c);
2857 template<
class _Iterator>
2859 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2861 for (; __k1 != __k2; ++__k1, ++__p)
2862 traits_type::assign(*__p, *__k1);
2866 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2867 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2870 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2872 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2875 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2876 { _M_copy(__p, __k1, __k2 - __k1); }
2879 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2881 { _M_copy(__p, __k1, __k2 - __k1); }
2884 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2886 const difference_type __d = difference_type(__n1 - __n2);
2888 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2889 return __gnu_cxx::__numeric_traits<int>::__max;
2890 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2891 return __gnu_cxx::__numeric_traits<int>::__min;
2897 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2903 _S_empty_rep() _GLIBCXX_NOEXCEPT
2904 {
return _Rep::_S_empty_rep(); }
2915 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2916 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2918 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
2939 basic_string(
const basic_string& __str, size_type __pos,
2940 size_type __n = npos);
2948 basic_string(
const basic_string& __str, size_type __pos,
2949 size_type __n,
const _Alloc& __a);
2961 const _Alloc& __a = _Alloc());
2967 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
2974 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
2976 #if __cplusplus >= 201103L 2985 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2988 : _M_dataplus(__str._M_dataplus)
2990 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2991 __str._M_data(_S_empty_rep()._M_refdata());
2993 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3011 template<
class _InputIterator>
3012 basic_string(_InputIterator __beg, _InputIterator __end,
3013 const _Alloc& __a = _Alloc());
3027 {
return this->
assign(__str); }
3035 {
return this->
assign(__s); }
3051 #if __cplusplus >= 201103L 3075 this->
assign(__l.begin(), __l.size());
3089 return iterator(_M_data());
3098 {
return const_iterator(_M_data()); }
3108 return iterator(_M_data() + this->
size());
3117 {
return const_iterator(_M_data() + this->
size()); }
3126 {
return reverse_iterator(this->
end()); }
3133 const_reverse_iterator
3135 {
return const_reverse_iterator(this->
end()); }
3144 {
return reverse_iterator(this->
begin()); }
3151 const_reverse_iterator
3153 {
return const_reverse_iterator(this->
begin()); }
3155 #if __cplusplus >= 201103L 3162 {
return const_iterator(this->_M_data()); }
3170 {
return const_iterator(this->_M_data() + this->
size()); }
3177 const_reverse_iterator
3179 {
return const_reverse_iterator(this->
end()); }
3186 const_reverse_iterator
3188 {
return const_reverse_iterator(this->
begin()); }
3197 {
return _M_rep()->_M_length; }
3203 {
return _M_rep()->_M_length; }
3208 {
return _Rep::_S_max_size; }
3221 resize(size_type __n, _CharT __c);
3235 { this->
resize(__n, _CharT()); }
3237 #if __cplusplus >= 201103L 3242 #if __cpp_exceptions 3260 {
return _M_rep()->_M_capacity; }
3280 reserve(size_type __res_arg = 0);
3288 { _M_mutate(0, this->
size(), 0); }
3296 {
return this->
size() == 0; }
3312 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3313 return _M_data()[__pos];
3331 _GLIBCXX_DEBUG_ASSERT(__pos <=
size());
3333 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3335 return _M_data()[__pos];
3351 if (__n >= this->
size())
3352 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3353 "(which is %zu) >= this->size() " 3356 return _M_data()[__n];
3374 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3375 "(which is %zu) >= this->size() " 3379 return _M_data()[__n];
3382 #if __cplusplus >= 201103L 3424 {
return this->
append(__str); }
3433 {
return this->
append(__s); }
3447 #if __cplusplus >= 201103L 3455 {
return this->
append(__l.begin(), __l.size()); }
3464 append(
const basic_string& __str);
3480 append(
const basic_string& __str, size_type __pos, size_type __n);
3489 append(
const _CharT* __s, size_type __n);
3499 __glibcxx_requires_string(__s);
3500 return this->
append(__s, traits_type::length(__s));
3512 append(size_type __n, _CharT __c);
3514 #if __cplusplus >= 201103L 3522 {
return this->
append(__l.begin(), __l.size()); }
3533 template<
class _InputIterator>
3535 append(_InputIterator __first, _InputIterator __last)
3536 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3545 const size_type __len = 1 + this->
size();
3546 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3548 traits_type::assign(_M_data()[this->
size()], __c);
3549 _M_rep()->_M_set_length_and_sharable(__len);
3558 assign(
const basic_string& __str);
3560 #if __cplusplus >= 201103L 3592 assign(
const basic_string& __str, size_type __pos, size_type __n)
3593 {
return this->
assign(__str._M_data()
3594 + __str._M_check(__pos,
"basic_string::assign"),
3595 __str._M_limit(__pos, __n)); }
3608 assign(
const _CharT* __s, size_type __n);
3622 __glibcxx_requires_string(__s);
3623 return this->
assign(__s, traits_type::length(__s));
3637 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3647 template<
class _InputIterator>
3649 assign(_InputIterator __first, _InputIterator __last)
3650 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3652 #if __cplusplus >= 201103L 3660 {
return this->
assign(__l.begin(), __l.size()); }
3677 insert(iterator __p, size_type __n, _CharT __c)
3678 { this->
replace(__p, __p, __n, __c); }
3692 template<
class _InputIterator>
3694 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3695 { this->
replace(__p, __p, __beg, __end); }
3697 #if __cplusplus >= 201103L 3707 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3708 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3725 insert(size_type __pos1,
const basic_string& __str)
3726 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3747 insert(size_type __pos1,
const basic_string& __str,
3748 size_type __pos2, size_type __n)
3749 {
return this->
insert(__pos1, __str._M_data()
3750 + __str._M_check(__pos2,
"basic_string::insert"),
3751 __str._M_limit(__pos2, __n)); }
3770 insert(size_type __pos,
const _CharT* __s, size_type __n);
3790 __glibcxx_requires_string(__s);
3791 return this->
insert(__pos, __s, traits_type::length(__s));
3811 insert(size_type __pos, size_type __n, _CharT __c)
3812 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3813 size_type(0), __n, __c); }
3831 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3832 const size_type __pos = __p - _M_ibegin();
3833 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3834 _M_rep()->_M_set_leaked();
3835 return iterator(_M_data() + __pos);
3854 erase(size_type __pos = 0, size_type __n = npos)
3856 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3857 _M_limit(__pos, __n), size_type(0));
3872 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3873 && __position < _M_iend());
3874 const size_type __pos = __position - _M_ibegin();
3875 _M_mutate(__pos, size_type(1), size_type(0));
3876 _M_rep()->_M_set_leaked();
3877 return iterator(_M_data() + __pos);
3890 erase(iterator __first, iterator __last);
3892 #if __cplusplus >= 201103L 3921 replace(size_type __pos, size_type __n,
const basic_string& __str)
3922 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
3943 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
3944 size_type __pos2, size_type __n2)
3945 {
return this->
replace(__pos1, __n1, __str._M_data()
3946 + __str._M_check(__pos2,
"basic_string::replace"),
3947 __str._M_limit(__pos2, __n2)); }
3968 replace(size_type __pos, size_type __n1,
const _CharT* __s,
3988 replace(size_type __pos, size_type __n1,
const _CharT* __s)
3990 __glibcxx_requires_string(__s);
3991 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4012 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4013 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4014 _M_limit(__pos, __n1), __n2, __c); }
4030 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4031 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4049 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4051 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4052 && __i2 <= _M_iend());
4053 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4070 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4072 __glibcxx_requires_string(__s);
4073 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4091 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4093 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4094 && __i2 <= _M_iend());
4095 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4113 template<
class _InputIterator>
4116 _InputIterator __k1, _InputIterator __k2)
4118 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4119 && __i2 <= _M_iend());
4120 __glibcxx_requires_valid_range(__k1, __k2);
4121 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4122 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4128 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4130 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4131 && __i2 <= _M_iend());
4132 __glibcxx_requires_valid_range(__k1, __k2);
4133 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4138 replace(iterator __i1, iterator __i2,
4139 const _CharT* __k1,
const _CharT* __k2)
4141 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4142 && __i2 <= _M_iend());
4143 __glibcxx_requires_valid_range(__k1, __k2);
4144 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4149 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4151 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4152 && __i2 <= _M_iend());
4153 __glibcxx_requires_valid_range(__k1, __k2);
4154 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4155 __k1.base(), __k2 - __k1);
4159 replace(iterator __i1, iterator __i2,
4160 const_iterator __k1, const_iterator __k2)
4162 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4163 && __i2 <= _M_iend());
4164 __glibcxx_requires_valid_range(__k1, __k2);
4165 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4166 __k1.base(), __k2 - __k1);
4169 #if __cplusplus >= 201103L 4184 basic_string&
replace(iterator __i1, iterator __i2,
4186 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4190 template<
class _Integer>
4192 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4193 _Integer __val, __true_type)
4194 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4196 template<
class _InputIterator>
4198 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4199 _InputIterator __k2, __false_type);
4202 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4206 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4211 template<
class _InIterator>
4213 _S_construct_aux(_InIterator __beg, _InIterator __end,
4214 const _Alloc& __a, __false_type)
4216 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4217 return _S_construct(__beg, __end, __a, _Tag());
4222 template<
class _Integer>
4224 _S_construct_aux(_Integer __beg, _Integer __end,
4225 const _Alloc& __a, __true_type)
4226 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4230 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4231 {
return _S_construct(__req, __c, __a); }
4233 template<
class _InIterator>
4235 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4237 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4238 return _S_construct_aux(__beg, __end, __a, _Integral());
4242 template<
class _InIterator>
4244 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4249 template<
class _FwdIterator>
4251 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4255 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4272 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4283 swap(basic_string& __s);
4294 {
return _M_data(); }
4304 {
return _M_data(); }
4311 {
return _M_dataplus; }
4326 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4339 find(
const basic_string& __str, size_type __pos = 0) const
4341 {
return this->
find(__str.data(), __pos, __str.size()); }
4354 find(
const _CharT* __s, size_type __pos = 0)
const 4356 __glibcxx_requires_string(__s);
4357 return this->
find(__s, __pos, traits_type::length(__s));
4371 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4384 rfind(
const basic_string& __str, size_type __pos = npos) const
4386 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4401 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4414 rfind(
const _CharT* __s, size_type __pos = npos)
const 4416 __glibcxx_requires_string(__s);
4417 return this->
rfind(__s, __pos, traits_type::length(__s));
4431 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4447 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4462 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4477 __glibcxx_requires_string(__s);
4478 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4495 {
return this->
find(__c, __pos); }
4511 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4526 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4541 __glibcxx_requires_string(__s);
4542 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4559 {
return this->
rfind(__c, __pos); }
4590 size_type __n)
const;
4605 __glibcxx_requires_string(__s);
4653 size_type __n)
const;
4668 __glibcxx_requires_string(__s);
4699 substr(size_type __pos = 0, size_type __n = npos)
const 4701 _M_check(__pos,
"basic_string::substr"), __n); }
4720 const size_type __size = this->
size();
4721 const size_type __osize = __str.size();
4722 const size_type __len =
std::min(__size, __osize);
4724 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4726 __r = _S_compare(__size, __osize);
4750 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
4776 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
4777 size_type __pos2, size_type __n2)
const;
4794 compare(
const _CharT* __s)
const;
4818 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4845 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4846 size_type __n2)
const;
4848 #endif // !_GLIBCXX_USE_CXX11_ABI 4857 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4863 __str.append(__rhs);
4873 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4884 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4894 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4897 const _CharT* __rhs)
4900 __str.append(__rhs);
4910 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4915 typedef typename __string_type::size_type __size_type;
4916 __string_type __str(__lhs);
4917 __str.append(__size_type(1), __rhs);
4921 #if __cplusplus >= 201103L 4922 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4926 {
return std::move(__lhs.append(__rhs)); }
4928 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4932 {
return std::move(__rhs.insert(0, __lhs)); }
4934 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4939 const auto __size = __lhs.size() + __rhs.size();
4940 const bool __cond = (__size > __lhs.capacity()
4941 && __size <= __rhs.capacity());
4942 return __cond ? std::move(__rhs.insert(0, __lhs))
4943 : std::move(__lhs.append(__rhs));
4946 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4950 {
return std::move(__rhs.insert(0, __lhs)); }
4952 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4956 {
return std::move(__rhs.insert(0, 1, __lhs)); }
4958 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4961 const _CharT* __rhs)
4962 {
return std::move(__lhs.append(__rhs)); }
4964 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4968 {
return std::move(__lhs.append(1, __rhs)); }
4978 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4983 {
return __lhs.compare(__rhs) == 0; }
4985 template<
typename _CharT>
4987 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
4990 {
return (__lhs.
size() == __rhs.
size()
5000 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5002 operator==(
const _CharT* __lhs,
5004 {
return __rhs.compare(__lhs) == 0; }
5012 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5015 const _CharT* __rhs)
5016 {
return __lhs.compare(__rhs) == 0; }
5025 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5030 {
return !(__lhs == __rhs); }
5038 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5040 operator!=(
const _CharT* __lhs,
5042 {
return !(__lhs == __rhs); }
5050 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5053 const _CharT* __rhs)
5054 {
return !(__lhs == __rhs); }
5063 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5065 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5068 {
return __lhs.
compare(__rhs) < 0; }
5076 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5078 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5079 const _CharT* __rhs)
5080 {
return __lhs.
compare(__rhs) < 0; }
5088 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5090 operator<(
const _CharT* __lhs,
5092 {
return __rhs.compare(__lhs) > 0; }
5101 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5106 {
return __lhs.compare(__rhs) > 0; }
5114 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5117 const _CharT* __rhs)
5118 {
return __lhs.compare(__rhs) > 0; }
5126 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5128 operator>(
const _CharT* __lhs,
5130 {
return __rhs.compare(__lhs) < 0; }
5139 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5141 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5144 {
return __lhs.
compare(__rhs) <= 0; }
5152 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5154 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5155 const _CharT* __rhs)
5156 {
return __lhs.
compare(__rhs) <= 0; }
5164 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5166 operator<=(
const _CharT* __lhs,
5168 {
return __rhs.compare(__lhs) >= 0; }
5177 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5182 {
return __lhs.compare(__rhs) >= 0; }
5190 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5193 const _CharT* __rhs)
5194 {
return __lhs.compare(__rhs) >= 0; }
5202 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5204 operator>=(
const _CharT* __lhs,
5206 {
return __rhs.compare(__lhs) <= 0; }
5215 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5219 #if __cplusplus >= 201103L 5220 noexcept(noexcept(__lhs.swap(__rhs)))
5222 { __lhs.swap(__rhs); }
5237 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5255 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5257 operator<<(basic_ostream<_CharT, _Traits>& __os,
5262 return __ostream_insert(__os, __str.
data(), __str.
size());
5278 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5295 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5301 #if __cplusplus >= 201103L 5303 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5310 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5322 #ifdef _GLIBCXX_USE_WCHAR_T 5329 _GLIBCXX_END_NAMESPACE_VERSION
5332 #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99) 5336 namespace std _GLIBCXX_VISIBILITY(default)
5338 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5339 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5343 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5344 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5348 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5349 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5352 inline unsigned long 5353 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5354 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5358 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5359 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5362 inline unsigned long long 5363 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5364 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5369 stof(
const string& __str,
size_t* __idx = 0)
5370 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5373 stod(
const string& __str,
size_t* __idx = 0)
5374 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5377 stold(
const string& __str,
size_t* __idx = 0)
5378 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5384 to_string(
int __val)
5385 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5389 to_string(
unsigned __val)
5390 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5391 4 *
sizeof(unsigned),
5395 to_string(
long __val)
5396 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5400 to_string(
unsigned long __val)
5401 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5402 4 *
sizeof(
unsigned long),
5406 to_string(
long long __val)
5407 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5408 4 *
sizeof(
long long),
5412 to_string(
unsigned long long __val)
5413 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5414 4 *
sizeof(
unsigned long long),
5418 to_string(
float __val)
5421 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5422 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5427 to_string(
double __val)
5430 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5431 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5436 to_string(
long double __val)
5439 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5440 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5444 #ifdef _GLIBCXX_USE_WCHAR_T 5446 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5447 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5451 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5452 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5455 inline unsigned long 5456 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5457 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5461 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5462 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5465 inline unsigned long long 5466 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5467 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5472 stof(
const wstring& __str,
size_t* __idx = 0)
5473 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5476 stod(
const wstring& __str,
size_t* __idx = 0)
5477 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5480 stold(
const wstring& __str,
size_t* __idx = 0)
5481 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5483 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5486 to_wstring(
int __val)
5487 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5491 to_wstring(
unsigned __val)
5492 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5493 4 *
sizeof(unsigned),
5497 to_wstring(
long __val)
5498 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5502 to_wstring(
unsigned long __val)
5503 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5504 4 *
sizeof(
unsigned long),
5508 to_wstring(
long long __val)
5509 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5510 4 *
sizeof(
long long),
5514 to_wstring(
unsigned long long __val)
5515 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5516 4 *
sizeof(
unsigned long long),
5520 to_wstring(
float __val)
5523 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5524 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5529 to_wstring(
double __val)
5532 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5533 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5538 to_wstring(
long double __val)
5541 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5542 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5545 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5548 _GLIBCXX_END_NAMESPACE_CXX11
5549 _GLIBCXX_END_NAMESPACE_VERSION
5554 #if __cplusplus >= 201103L 5558 namespace std _GLIBCXX_VISIBILITY(default)
5560 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5564 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5568 :
public __hash_base<size_t, string>
5571 operator()(
const string& __s)
const noexcept
5572 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5579 #ifdef _GLIBCXX_USE_WCHAR_T 5583 :
public __hash_base<size_t, wstring>
5586 operator()(
const wstring& __s)
const noexcept
5587 {
return std::_Hash_impl::hash(__s.
data(),
5588 __s.
length() *
sizeof(wchar_t)); }
5597 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5601 :
public __hash_base<size_t, u16string>
5604 operator()(
const u16string& __s)
const noexcept
5605 {
return std::_Hash_impl::hash(__s.
data(),
5606 __s.
length() *
sizeof(char16_t)); }
5616 :
public __hash_base<size_t, u32string>
5619 operator()(
const u32string& __s)
const noexcept
5620 {
return std::_Hash_impl::hash(__s.
data(),
5621 __s.
length() *
sizeof(char32_t)); }
5629 #if __cplusplus > 201103L 5631 #define __cpp_lib_string_udls 201304 5633 inline namespace literals
5635 inline namespace string_literals
5638 _GLIBCXX_DEFAULT_ABI_TAG
5640 operator""s(
const char* __str,
size_t __len)
5643 #ifdef _GLIBCXX_USE_WCHAR_T 5644 _GLIBCXX_DEFAULT_ABI_TAG
5646 operator""s(
const wchar_t* __str,
size_t __len)
5650 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5651 _GLIBCXX_DEFAULT_ABI_TAG
5653 operator""s(
const char16_t* __str,
size_t __len)
5656 _GLIBCXX_DEFAULT_ABI_TAG
5658 operator""s(
const char32_t* __str,
size_t __len)
5665 #endif // __cplusplus > 201103L 5667 _GLIBCXX_END_NAMESPACE_VERSION
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string()
Default constructor creates an empty string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
Basis for explicit traits specializations.
basic_string & append(const _CharT *__s)
Append a C string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_reference front() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & assign(basic_string &&__str)
Set value to contents of another 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(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
~basic_string() noexcept
Destroy the string instance.
const_iterator cend() const noexcept
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a 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=(basic_string &&__str)
Move assign the value of str to this string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
int compare(const basic_string &__str) const
Compare to a string.
const_reverse_iterator crend() const noexcept
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_reference back() const noexcept
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
const_reverse_iterator crbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
Managing sequences of characters and character-like objects.
basic_string & append(const basic_string &__str)
Append a string to this string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
Template class basic_ostream.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_iterator end() const noexcept
size_type max_size() const noexcept
Returns the size() of the largest possible string.
One of the comparison functors.
Primary class template hash.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
size_type capacity() const noexcept
char_type widen(char __c) const
Widens characters.
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 __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2)
Replace characters with value from another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Uniform interface to all pointer-like types.
iterator erase(iterator __position)
Remove one character.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a 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.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
const_reverse_iterator rend() const noexcept
const_iterator begin() const noexcept
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Template class basic_istream.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
void push_back(_CharT __c)
Append a single character.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
void swap(basic_string &__s)
Swap contents with another string.
static const size_type npos
Value returned by various member functions when they fail.
bool empty() const noexcept
reverse_iterator rbegin()
reference at(size_type __n)
Provides access to the data contained in the string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
Forward iterators support a superset of input iterator operations.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & operator+=(_CharT __c)
Append a character.
ISO C++ entities toplevel namespace is std.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
Uniform interface to C++98 and C++0x allocators.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
const_iterator cbegin() const noexcept
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(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.