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())
652 this->_S_copy(_M_data(), __str._M_data(), __str.size());
653 _M_set_length(__str.size());
655 else if (_Alloc_traits::_S_propagate_on_move_assign()
656 || _Alloc_traits::_S_always_equal()
657 || _M_get_allocator() == __str._M_get_allocator())
660 pointer __data =
nullptr;
661 size_type __capacity;
664 if (_Alloc_traits::_S_always_equal())
668 __capacity = _M_allocated_capacity;
671 _M_destroy(_M_allocated_capacity);
674 _M_data(__str._M_data());
675 _M_length(__str.length());
676 _M_capacity(__str._M_allocated_capacity);
679 __str._M_data(__data);
680 __str._M_capacity(__capacity);
683 __str._M_data(__str._M_local_buf);
698 this->
assign(__l.begin(), __l.size());
709 begin() _GLIBCXX_NOEXCEPT
710 {
return iterator(_M_data()); }
717 begin() const _GLIBCXX_NOEXCEPT
718 {
return const_iterator(_M_data()); }
725 end() _GLIBCXX_NOEXCEPT
726 {
return iterator(_M_data() + this->
size()); }
733 end() const _GLIBCXX_NOEXCEPT
734 {
return const_iterator(_M_data() + this->
size()); }
742 rbegin() _GLIBCXX_NOEXCEPT
743 {
return reverse_iterator(this->
end()); }
750 const_reverse_iterator
751 rbegin() const _GLIBCXX_NOEXCEPT
752 {
return const_reverse_iterator(this->
end()); }
760 rend() _GLIBCXX_NOEXCEPT
761 {
return reverse_iterator(this->
begin()); }
768 const_reverse_iterator
769 rend() const _GLIBCXX_NOEXCEPT
770 {
return const_reverse_iterator(this->
begin()); }
772 #if __cplusplus >= 201103L 779 {
return const_iterator(this->_M_data()); }
786 cend() const noexcept
787 {
return const_iterator(this->_M_data() + this->
size()); }
794 const_reverse_iterator
796 {
return const_reverse_iterator(this->
end()); }
803 const_reverse_iterator
804 crend() const noexcept
805 {
return const_reverse_iterator(this->
begin()); }
813 size() const _GLIBCXX_NOEXCEPT
814 {
return _M_string_length; }
819 length() const _GLIBCXX_NOEXCEPT
820 {
return _M_string_length; }
825 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
838 resize(size_type __n, _CharT __c);
852 { this->
resize(__n, _CharT()); }
854 #if __cplusplus >= 201103L 878 return _M_is_local() ? size_type(_S_local_capacity)
879 : _M_allocated_capacity;
900 reserve(size_type __res_arg = 0);
906 clear() _GLIBCXX_NOEXCEPT
907 { _M_set_length(0); }
914 empty() const _GLIBCXX_NOEXCEPT
915 {
return this->
size() == 0; }
929 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
931 __glibcxx_assert(__pos <=
size());
932 return _M_data()[__pos];
950 __glibcxx_assert(__pos <=
size());
952 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
953 return _M_data()[__pos];
967 at(size_type __n)
const 969 if (__n >= this->
size())
970 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 971 "(which is %zu) >= this->size() " 974 return _M_data()[__n];
991 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 992 "(which is %zu) >= this->size() " 995 return _M_data()[__n];
998 #if __cplusplus >= 201103L 1006 __glibcxx_assert(!
empty());
1015 front() const noexcept
1017 __glibcxx_assert(!
empty());
1028 __glibcxx_assert(!
empty());
1037 back() const noexcept
1039 __glibcxx_assert(!
empty());
1052 {
return this->
append(__str); }
1061 {
return this->
append(__s); }
1075 #if __cplusplus >= 201103L 1083 {
return this->
append(__l.begin(), __l.size()); }
1092 append(
const basic_string& __str)
1093 {
return _M_append(__str._M_data(), __str.size()); }
1109 append(
const basic_string& __str, size_type __pos, size_type __n)
1110 {
return _M_append(__str._M_data()
1111 + __str._M_check(__pos,
"basic_string::append"),
1112 __str._M_limit(__pos, __n)); }
1121 append(
const _CharT* __s, size_type __n)
1123 __glibcxx_requires_string_len(__s, __n);
1124 _M_check_length(size_type(0), __n,
"basic_string::append");
1125 return _M_append(__s, __n);
1134 append(
const _CharT* __s)
1136 __glibcxx_requires_string(__s);
1137 const size_type __n = traits_type::length(__s);
1138 _M_check_length(size_type(0), __n,
"basic_string::append");
1139 return _M_append(__s, __n);
1151 append(size_type __n, _CharT __c)
1152 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1154 #if __cplusplus >= 201103L 1161 append(initializer_list<_CharT> __l)
1162 {
return this->
append(__l.begin(), __l.size()); }
1173 #if __cplusplus >= 201103L 1174 template<
class _InputIterator,
1175 typename = std::_RequireInputIter<_InputIterator>>
1177 template<
class _InputIterator>
1180 append(_InputIterator __first, _InputIterator __last)
1190 const size_type __size = this->
size();
1192 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1193 traits_type::assign(this->_M_data()[__size], __c);
1194 this->_M_set_length(__size + 1);
1203 assign(
const basic_string& __str)
1205 this->_M_assign(__str);
1209 #if __cplusplus >= 201103L 1219 assign(basic_string&& __str)
1220 noexcept(_Alloc_traits::_S_nothrow_move())
1224 return *
this = std::move(__str);
1242 assign(
const basic_string& __str, size_type __pos, size_type __n)
1243 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1244 + __str._M_check(__pos,
"basic_string::assign"),
1245 __str._M_limit(__pos, __n)); }
1258 assign(
const _CharT* __s, size_type __n)
1260 __glibcxx_requires_string_len(__s, __n);
1261 return _M_replace(size_type(0), this->
size(), __s, __n);
1274 assign(
const _CharT* __s)
1276 __glibcxx_requires_string(__s);
1277 return _M_replace(size_type(0), this->
size(), __s,
1278 traits_type::length(__s));
1291 assign(size_type __n, _CharT __c)
1292 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1302 #if __cplusplus >= 201103L 1303 template<
class _InputIterator,
1304 typename = std::_RequireInputIter<_InputIterator>>
1306 template<
class _InputIterator>
1309 assign(_InputIterator __first, _InputIterator __last)
1312 #if __cplusplus >= 201103L 1319 assign(initializer_list<_CharT> __l)
1320 {
return this->
assign(__l.begin(), __l.size()); }
1323 #if __cplusplus >= 201103L 1340 insert(const_iterator __p, size_type __n, _CharT __c)
1342 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1343 const size_type __pos = __p -
begin();
1344 this->
replace(__p, __p, __n, __c);
1345 return iterator(this->_M_data() + __pos);
1362 insert(iterator __p, size_type __n, _CharT __c)
1363 { this->
replace(__p, __p, __n, __c); }
1366 #if __cplusplus >= 201103L 1381 template<
class _InputIterator,
1382 typename = std::_RequireInputIter<_InputIterator>>
1384 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1386 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1387 const size_type __pos = __p -
begin();
1388 this->
replace(__p, __p, __beg, __end);
1389 return iterator(this->_M_data() + __pos);
1404 template<
class _InputIterator>
1406 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1407 { this->
replace(__p, __p, __beg, __end); }
1410 #if __cplusplus >= 201103L 1418 insert(iterator __p, initializer_list<_CharT> __l)
1420 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1421 this->
insert(__p -
begin(), __l.begin(), __l.size());
1438 insert(size_type __pos1,
const basic_string& __str)
1439 {
return this->
replace(__pos1, size_type(0),
1440 __str._M_data(), __str.size()); }
1461 insert(size_type __pos1,
const basic_string& __str,
1462 size_type __pos2, size_type __n)
1463 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1464 + __str._M_check(__pos2,
"basic_string::insert"),
1465 __str._M_limit(__pos2, __n)); }
1484 insert(size_type __pos,
const _CharT* __s, size_type __n)
1485 {
return this->
replace(__pos, size_type(0), __s, __n); }
1503 insert(size_type __pos,
const _CharT* __s)
1505 __glibcxx_requires_string(__s);
1506 return this->
replace(__pos, size_type(0), __s,
1507 traits_type::length(__s));
1527 insert(size_type __pos, size_type __n, _CharT __c)
1528 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1529 size_type(0), __n, __c); }
1545 insert(__const_iterator __p, _CharT __c)
1547 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1548 const size_type __pos = __p -
begin();
1549 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1550 return iterator(_M_data() + __pos);
1569 erase(size_type __pos = 0, size_type __n = npos)
1571 this->_M_erase(_M_check(__pos,
"basic_string::erase"),
1572 _M_limit(__pos, __n));
1585 erase(__const_iterator __position)
1587 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1588 && __position <
end());
1589 const size_type __pos = __position -
begin();
1590 this->_M_erase(__pos, size_type(1));
1591 return iterator(_M_data() + __pos);
1604 erase(__const_iterator __first, __const_iterator __last)
1606 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1607 && __last <=
end());
1608 const size_type __pos = __first -
begin();
1609 this->_M_erase(__pos, __last - __first);
1610 return iterator(this->_M_data() + __pos);
1613 #if __cplusplus >= 201103L 1622 __glibcxx_assert(!
empty());
1623 _M_erase(
size() - 1, 1);
1645 replace(size_type __pos, size_type __n,
const basic_string& __str)
1646 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1667 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1668 size_type __pos2, size_type __n2)
1669 {
return this->
replace(__pos1, __n1, __str._M_data()
1670 + __str._M_check(__pos2,
"basic_string::replace"),
1671 __str._M_limit(__pos2, __n2)); }
1692 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1695 __glibcxx_requires_string_len(__s, __n2);
1696 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1697 _M_limit(__pos, __n1), __s, __n2);
1717 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1719 __glibcxx_requires_string(__s);
1720 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1741 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1742 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1743 _M_limit(__pos, __n1), __n2, __c); }
1759 replace(__const_iterator __i1, __const_iterator __i2,
1760 const basic_string& __str)
1761 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1779 replace(__const_iterator __i1, __const_iterator __i2,
1780 const _CharT* __s, size_type __n)
1782 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1784 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1801 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1803 __glibcxx_requires_string(__s);
1804 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1822 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1825 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1827 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
1845 #if __cplusplus >= 201103L 1846 template<
class _InputIterator,
1847 typename = std::_RequireInputIter<_InputIterator>>
1849 replace(const_iterator __i1, const_iterator __i2,
1850 _InputIterator __k1, _InputIterator __k2)
1852 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1854 __glibcxx_requires_valid_range(__k1, __k2);
1855 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
1856 std::__false_type());
1859 template<
class _InputIterator>
1860 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 1861 typename __enable_if_not_native_iterator<_InputIterator>::__type
1865 replace(iterator __i1, iterator __i2,
1866 _InputIterator __k1, _InputIterator __k2)
1868 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1870 __glibcxx_requires_valid_range(__k1, __k2);
1871 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1872 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
1879 replace(__const_iterator __i1, __const_iterator __i2,
1880 _CharT* __k1, _CharT* __k2)
1882 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1884 __glibcxx_requires_valid_range(__k1, __k2);
1890 replace(__const_iterator __i1, __const_iterator __i2,
1891 const _CharT* __k1,
const _CharT* __k2)
1893 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1895 __glibcxx_requires_valid_range(__k1, __k2);
1901 replace(__const_iterator __i1, __const_iterator __i2,
1902 iterator __k1, iterator __k2)
1904 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1906 __glibcxx_requires_valid_range(__k1, __k2);
1908 __k1.base(), __k2 - __k1);
1912 replace(__const_iterator __i1, __const_iterator __i2,
1913 const_iterator __k1, const_iterator __k2)
1915 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1917 __glibcxx_requires_valid_range(__k1, __k2);
1919 __k1.base(), __k2 - __k1);
1922 #if __cplusplus >= 201103L 1937 basic_string&
replace(const_iterator __i1, const_iterator __i2,
1938 initializer_list<_CharT> __l)
1939 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
1943 template<
class _Integer>
1945 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1946 _Integer __n, _Integer __val, __true_type)
1947 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
1949 template<
class _InputIterator>
1951 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
1952 _InputIterator __k1, _InputIterator __k2,
1956 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
1960 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
1961 const size_type __len2);
1964 _M_append(
const _CharT* __s, size_type __n);
1981 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
1991 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2001 c_str() const _GLIBCXX_NOEXCEPT
2002 {
return _M_data(); }
2011 data() const _GLIBCXX_NOEXCEPT
2012 {
return _M_data(); }
2019 {
return _M_get_allocator(); }
2034 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
2047 find(
const basic_string& __str, size_type __pos = 0) const
2049 {
return this->
find(__str.data(), __pos, __str.size()); }
2062 find(
const _CharT* __s, size_type __pos = 0)
const 2064 __glibcxx_requires_string(__s);
2065 return this->
find(__s, __pos, traits_type::length(__s));
2079 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2092 rfind(const basic_string& __str, size_type __pos = npos) const
2094 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2109 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2122 rfind(
const _CharT* __s, size_type __pos = npos)
const 2124 __glibcxx_requires_string(__s);
2125 return this->
rfind(__s, __pos, traits_type::length(__s));
2139 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2153 find_first_of(const basic_string& __str, size_type __pos = 0) const
2155 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2170 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2185 __glibcxx_requires_string(__s);
2186 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2202 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2203 {
return this->
find(__c, __pos); }
2217 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2219 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2234 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2247 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2249 __glibcxx_requires_string(__s);
2250 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2266 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2267 {
return this->
rfind(__c, __pos); }
2298 size_type __n)
const;
2313 __glibcxx_requires_string(__s);
2361 size_type __n)
const;
2376 __glibcxx_requires_string(__s);
2407 substr(size_type __pos = 0, size_type __n = npos)
const 2409 _M_check(__pos,
"basic_string::substr"), __n); }
2426 compare(
const basic_string& __str)
const 2428 const size_type __size = this->
size();
2429 const size_type __osize = __str.size();
2430 const size_type __len =
std::min(__size, __osize);
2432 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2434 __r = _S_compare(__size, __osize);
2458 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2484 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2485 size_type __pos2, size_type __n2)
const;
2502 compare(
const _CharT* __s)
const;
2526 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2553 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2554 size_type __n2)
const;
2557 template<
typename,
typename,
typename>
friend class basic_stringbuf;
2559 _GLIBCXX_END_NAMESPACE_CXX11
2560 #else // !_GLIBCXX_USE_CXX11_ABI 2625 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2628 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2632 typedef _Traits traits_type;
2633 typedef typename _Traits::char_type value_type;
2634 typedef _Alloc allocator_type;
2635 typedef typename _CharT_alloc_type::size_type size_type;
2636 typedef typename _CharT_alloc_type::difference_type difference_type;
2637 typedef typename _CharT_alloc_type::reference reference;
2638 typedef typename _CharT_alloc_type::const_reference const_reference;
2639 typedef typename _CharT_alloc_type::pointer pointer;
2640 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2641 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2642 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
2664 size_type _M_length;
2665 size_type _M_capacity;
2666 _Atomic_word _M_refcount;
2669 struct _Rep : _Rep_base
2672 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
2687 static const size_type _S_max_size;
2688 static const _CharT _S_terminal;
2692 static size_type _S_empty_rep_storage[];
2695 _S_empty_rep() _GLIBCXX_NOEXCEPT
2700 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
2701 return *
reinterpret_cast<_Rep*
>(__p);
2705 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
2707 #if defined(__GTHREADS) 2712 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
2714 return this->_M_refcount < 0;
2719 _M_is_shared()
const _GLIBCXX_NOEXCEPT
2721 #if defined(__GTHREADS) 2727 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
2729 return this->_M_refcount > 0;
2734 _M_set_leaked() _GLIBCXX_NOEXCEPT
2735 { this->_M_refcount = -1; }
2738 _M_set_sharable() _GLIBCXX_NOEXCEPT
2739 { this->_M_refcount = 0; }
2742 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
2744 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2745 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2748 this->_M_set_sharable();
2749 this->_M_length = __n;
2750 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
2757 _M_refdata()
throw()
2758 {
return reinterpret_cast<_CharT*
>(
this + 1); }
2761 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
2763 return (!_M_is_leaked() && __alloc1 == __alloc2)
2764 ? _M_refcopy() : _M_clone(__alloc1);
2769 _S_create(size_type, size_type,
const _Alloc&);
2772 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2774 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2775 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2779 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
2788 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
2791 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
2798 _M_destroy(
const _Alloc&)
throw();
2801 _M_refcopy()
throw()
2803 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2804 if (__builtin_expect(
this != &_S_empty_rep(),
false))
2806 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
2807 return _M_refdata();
2811 _M_clone(
const _Alloc&, size_type __res = 0);
2815 struct _Alloc_hider : _Alloc
2817 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
2818 : _Alloc(__a), _M_p(__dat) { }
2828 static const size_type npos =
static_cast<size_type
>(-1);
2832 mutable _Alloc_hider _M_dataplus;
2835 _M_data() const _GLIBCXX_NOEXCEPT
2836 {
return _M_dataplus._M_p; }
2839 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
2840 {
return (_M_dataplus._M_p = __p); }
2843 _M_rep()
const _GLIBCXX_NOEXCEPT
2844 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
2849 _M_ibegin()
const _GLIBCXX_NOEXCEPT
2850 {
return iterator(_M_data()); }
2853 _M_iend()
const _GLIBCXX_NOEXCEPT
2854 {
return iterator(_M_data() + this->
size()); }
2859 if (!_M_rep()->_M_is_leaked())
2864 _M_check(size_type __pos,
const char* __s)
const 2866 if (__pos > this->
size())
2867 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 2868 "this->size() (which is %zu)"),
2869 __s, __pos, this->
size());
2874 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 2877 __throw_length_error(__N(__s));
2882 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
2884 const bool __testoff = __off < this->
size() - __pos;
2885 return __testoff ? __off : this->
size() - __pos;
2890 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
2899 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2902 traits_type::assign(*__d, *__s);
2904 traits_type::copy(__d, __s, __n);
2908 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
2911 traits_type::assign(*__d, *__s);
2913 traits_type::move(__d, __s, __n);
2917 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
2920 traits_type::assign(*__d, __c);
2922 traits_type::assign(__d, __n, __c);
2927 template<
class _Iterator>
2929 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
2931 for (; __k1 != __k2; ++__k1, (void)++__p)
2932 traits_type::assign(*__p, *__k1);
2936 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
2937 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2940 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
2942 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
2945 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
2946 { _M_copy(__p, __k1, __k2 - __k1); }
2949 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
2951 { _M_copy(__p, __k1, __k2 - __k1); }
2954 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
2956 const difference_type __d = difference_type(__n1 - __n2);
2958 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
2959 return __gnu_cxx::__numeric_traits<int>::__max;
2960 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
2961 return __gnu_cxx::__numeric_traits<int>::__min;
2967 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
2973 _S_empty_rep() _GLIBCXX_NOEXCEPT
2974 {
return _Rep::_S_empty_rep(); }
2985 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 2986 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
2988 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3009 basic_string(
const basic_string& __str, size_type __pos,
3010 size_type __n = npos);
3018 basic_string(
const basic_string& __str, size_type __pos,
3019 size_type __n,
const _Alloc& __a);
3031 const _Alloc& __a = _Alloc());
3037 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3044 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3046 #if __cplusplus >= 201103L 3055 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3058 : _M_dataplus(__str._M_dataplus)
3060 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3061 __str._M_data(_S_empty_rep()._M_refdata());
3063 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3081 template<
class _InputIterator>
3082 basic_string(_InputIterator __beg, _InputIterator __end,
3083 const _Alloc& __a = _Alloc());
3097 {
return this->
assign(__str); }
3105 {
return this->
assign(__s); }
3121 #if __cplusplus >= 201103L 3145 this->
assign(__l.begin(), __l.size());
3159 return iterator(_M_data());
3168 {
return const_iterator(_M_data()); }
3178 return iterator(_M_data() + this->
size());
3187 {
return const_iterator(_M_data() + this->
size()); }
3196 {
return reverse_iterator(this->
end()); }
3203 const_reverse_iterator
3205 {
return const_reverse_iterator(this->
end()); }
3214 {
return reverse_iterator(this->
begin()); }
3221 const_reverse_iterator
3223 {
return const_reverse_iterator(this->
begin()); }
3225 #if __cplusplus >= 201103L 3232 {
return const_iterator(this->_M_data()); }
3240 {
return const_iterator(this->_M_data() + this->
size()); }
3247 const_reverse_iterator
3249 {
return const_reverse_iterator(this->
end()); }
3256 const_reverse_iterator
3258 {
return const_reverse_iterator(this->
begin()); }
3267 {
return _M_rep()->_M_length; }
3273 {
return _M_rep()->_M_length; }
3278 {
return _Rep::_S_max_size; }
3291 resize(size_type __n, _CharT __c);
3305 { this->
resize(__n, _CharT()); }
3307 #if __cplusplus >= 201103L 3312 #if __cpp_exceptions 3330 {
return _M_rep()->_M_capacity; }
3350 reserve(size_type __res_arg = 0);
3358 { _M_mutate(0, this->
size(), 0); }
3366 {
return this->
size() == 0; }
3382 __glibcxx_assert(__pos <=
size());
3383 return _M_data()[__pos];
3401 __glibcxx_assert(__pos <=
size());
3403 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3405 return _M_data()[__pos];
3421 if (__n >= this->
size())
3422 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3423 "(which is %zu) >= this->size() " 3426 return _M_data()[__n];
3444 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3445 "(which is %zu) >= this->size() " 3449 return _M_data()[__n];
3452 #if __cplusplus >= 201103L 3460 __glibcxx_assert(!
empty());
3471 __glibcxx_assert(!
empty());
3482 __glibcxx_assert(!
empty());
3493 __glibcxx_assert(!
empty());
3506 {
return this->
append(__str); }
3515 {
return this->
append(__s); }
3529 #if __cplusplus >= 201103L 3537 {
return this->
append(__l.begin(), __l.size()); }
3546 append(
const basic_string& __str);
3562 append(
const basic_string& __str, size_type __pos, size_type __n);
3571 append(
const _CharT* __s, size_type __n);
3581 __glibcxx_requires_string(__s);
3582 return this->
append(__s, traits_type::length(__s));
3594 append(size_type __n, _CharT __c);
3596 #if __cplusplus >= 201103L 3604 {
return this->
append(__l.begin(), __l.size()); }
3615 template<
class _InputIterator>
3617 append(_InputIterator __first, _InputIterator __last)
3618 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3627 const size_type __len = 1 + this->
size();
3628 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3630 traits_type::assign(_M_data()[this->
size()], __c);
3631 _M_rep()->_M_set_length_and_sharable(__len);
3640 assign(
const basic_string& __str);
3642 #if __cplusplus >= 201103L 3674 assign(
const basic_string& __str, size_type __pos, size_type __n)
3675 {
return this->
assign(__str._M_data()
3676 + __str._M_check(__pos,
"basic_string::assign"),
3677 __str._M_limit(__pos, __n)); }
3690 assign(
const _CharT* __s, size_type __n);
3704 __glibcxx_requires_string(__s);
3705 return this->
assign(__s, traits_type::length(__s));
3719 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
3729 template<
class _InputIterator>
3731 assign(_InputIterator __first, _InputIterator __last)
3732 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
3734 #if __cplusplus >= 201103L 3742 {
return this->
assign(__l.begin(), __l.size()); }
3759 insert(iterator __p, size_type __n, _CharT __c)
3760 { this->
replace(__p, __p, __n, __c); }
3774 template<
class _InputIterator>
3776 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
3777 { this->
replace(__p, __p, __beg, __end); }
3779 #if __cplusplus >= 201103L 3789 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3790 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
3807 insert(size_type __pos1,
const basic_string& __str)
3808 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
3829 insert(size_type __pos1,
const basic_string& __str,
3830 size_type __pos2, size_type __n)
3831 {
return this->
insert(__pos1, __str._M_data()
3832 + __str._M_check(__pos2,
"basic_string::insert"),
3833 __str._M_limit(__pos2, __n)); }
3852 insert(size_type __pos,
const _CharT* __s, size_type __n);
3872 __glibcxx_requires_string(__s);
3873 return this->
insert(__pos, __s, traits_type::length(__s));
3893 insert(size_type __pos, size_type __n, _CharT __c)
3894 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
3895 size_type(0), __n, __c); }
3913 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
3914 const size_type __pos = __p - _M_ibegin();
3915 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
3916 _M_rep()->_M_set_leaked();
3917 return iterator(_M_data() + __pos);
3936 erase(size_type __pos = 0, size_type __n = npos)
3938 _M_mutate(_M_check(__pos,
"basic_string::erase"),
3939 _M_limit(__pos, __n), size_type(0));
3954 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
3955 && __position < _M_iend());
3956 const size_type __pos = __position - _M_ibegin();
3957 _M_mutate(__pos, size_type(1), size_type(0));
3958 _M_rep()->_M_set_leaked();
3959 return iterator(_M_data() + __pos);
3972 erase(iterator __first, iterator __last);
3974 #if __cplusplus >= 201103L 3983 __glibcxx_assert(!
empty());
4006 replace(size_type __pos, size_type __n,
const basic_string& __str)
4007 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4028 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4029 size_type __pos2, size_type __n2)
4030 {
return this->
replace(__pos1, __n1, __str._M_data()
4031 + __str._M_check(__pos2,
"basic_string::replace"),
4032 __str._M_limit(__pos2, __n2)); }
4053 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4073 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4075 __glibcxx_requires_string(__s);
4076 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4097 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4098 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4099 _M_limit(__pos, __n1), __n2, __c); }
4115 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4116 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4134 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4136 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4137 && __i2 <= _M_iend());
4138 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4155 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4157 __glibcxx_requires_string(__s);
4158 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4176 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4178 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4179 && __i2 <= _M_iend());
4180 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4198 template<
class _InputIterator>
4201 _InputIterator __k1, _InputIterator __k2)
4203 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4204 && __i2 <= _M_iend());
4205 __glibcxx_requires_valid_range(__k1, __k2);
4206 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4207 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4213 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4215 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4216 && __i2 <= _M_iend());
4217 __glibcxx_requires_valid_range(__k1, __k2);
4218 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4223 replace(iterator __i1, iterator __i2,
4224 const _CharT* __k1,
const _CharT* __k2)
4226 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4227 && __i2 <= _M_iend());
4228 __glibcxx_requires_valid_range(__k1, __k2);
4229 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4234 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4236 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4237 && __i2 <= _M_iend());
4238 __glibcxx_requires_valid_range(__k1, __k2);
4239 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4240 __k1.base(), __k2 - __k1);
4244 replace(iterator __i1, iterator __i2,
4245 const_iterator __k1, const_iterator __k2)
4247 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4248 && __i2 <= _M_iend());
4249 __glibcxx_requires_valid_range(__k1, __k2);
4250 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4251 __k1.base(), __k2 - __k1);
4254 #if __cplusplus >= 201103L 4269 basic_string&
replace(iterator __i1, iterator __i2,
4271 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4275 template<
class _Integer>
4277 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4278 _Integer __val, __true_type)
4279 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4281 template<
class _InputIterator>
4283 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4284 _InputIterator __k2, __false_type);
4287 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4291 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4296 template<
class _InIterator>
4298 _S_construct_aux(_InIterator __beg, _InIterator __end,
4299 const _Alloc& __a, __false_type)
4301 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4302 return _S_construct(__beg, __end, __a, _Tag());
4307 template<
class _Integer>
4309 _S_construct_aux(_Integer __beg, _Integer __end,
4310 const _Alloc& __a, __true_type)
4311 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4315 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4316 {
return _S_construct(__req, __c, __a); }
4318 template<
class _InIterator>
4320 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4322 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4323 return _S_construct_aux(__beg, __end, __a, _Integral());
4327 template<
class _InIterator>
4329 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4334 template<
class _FwdIterator>
4336 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4340 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4357 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4368 swap(basic_string& __s);
4379 {
return _M_data(); }
4389 {
return _M_data(); }
4396 {
return _M_dataplus; }
4411 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4424 find(
const basic_string& __str, size_type __pos = 0) const
4426 {
return this->
find(__str.data(), __pos, __str.size()); }
4439 find(
const _CharT* __s, size_type __pos = 0)
const 4441 __glibcxx_requires_string(__s);
4442 return this->
find(__s, __pos, traits_type::length(__s));
4456 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4469 rfind(
const basic_string& __str, size_type __pos = npos) const
4471 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4486 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4499 rfind(
const _CharT* __s, size_type __pos = npos)
const 4501 __glibcxx_requires_string(__s);
4502 return this->
rfind(__s, __pos, traits_type::length(__s));
4516 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4532 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4547 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4562 __glibcxx_requires_string(__s);
4563 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4580 {
return this->
find(__c, __pos); }
4596 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4611 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4626 __glibcxx_requires_string(__s);
4627 return this->
find_last_of(__s, __pos, traits_type::length(__s));
4644 {
return this->
rfind(__c, __pos); }
4675 size_type __n)
const;
4690 __glibcxx_requires_string(__s);
4738 size_type __n)
const;
4753 __glibcxx_requires_string(__s);
4784 substr(size_type __pos = 0, size_type __n = npos)
const 4786 _M_check(__pos,
"basic_string::substr"), __n); }
4805 const size_type __size = this->
size();
4806 const size_type __osize = __str.size();
4807 const size_type __len =
std::min(__size, __osize);
4809 int __r = traits_type::compare(_M_data(), __str.data(), __len);
4811 __r = _S_compare(__size, __osize);
4835 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
4861 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
4862 size_type __pos2, size_type __n2)
const;
4879 compare(
const _CharT* __s)
const;
4903 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
4930 compare(size_type __pos, size_type __n1,
const _CharT* __s,
4931 size_type __n2)
const;
4933 # ifdef _GLIBCXX_TM_TS_INTERNAL 4935 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
4938 ::_txnal_cow_string_c_str(
const void *that);
4940 ::_txnal_cow_string_D1(
void *that);
4942 ::_txnal_cow_string_D1_commit(
void *that);
4945 #endif // !_GLIBCXX_USE_CXX11_ABI 4954 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4960 __str.append(__rhs);
4970 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4981 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4991 template<
typename _CharT,
typename _Traits,
typename _Alloc>
4994 const _CharT* __rhs)
4997 __str.append(__rhs);
5007 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5012 typedef typename __string_type::size_type __size_type;
5013 __string_type __str(__lhs);
5014 __str.append(__size_type(1), __rhs);
5018 #if __cplusplus >= 201103L 5019 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5023 {
return std::move(__lhs.append(__rhs)); }
5025 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5029 {
return std::move(__rhs.insert(0, __lhs)); }
5031 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5036 const auto __size = __lhs.size() + __rhs.size();
5037 const bool __cond = (__size > __lhs.capacity()
5038 && __size <= __rhs.capacity());
5039 return __cond ? std::move(__rhs.insert(0, __lhs))
5040 : std::move(__lhs.append(__rhs));
5043 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5047 {
return std::move(__rhs.insert(0, __lhs)); }
5049 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5053 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5055 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5058 const _CharT* __rhs)
5059 {
return std::move(__lhs.append(__rhs)); }
5061 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5065 {
return std::move(__lhs.append(1, __rhs)); }
5075 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5080 {
return __lhs.compare(__rhs) == 0; }
5082 template<
typename _CharT>
5084 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5087 {
return (__lhs.
size() == __rhs.
size()
5097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5099 operator==(
const _CharT* __lhs,
5101 {
return __rhs.compare(__lhs) == 0; }
5109 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5112 const _CharT* __rhs)
5113 {
return __lhs.compare(__rhs) == 0; }
5122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5127 {
return !(__lhs == __rhs); }
5135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5137 operator!=(
const _CharT* __lhs,
5139 {
return !(__lhs == __rhs); }
5147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5150 const _CharT* __rhs)
5151 {
return !(__lhs == __rhs); }
5160 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5162 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5165 {
return __lhs.
compare(__rhs) < 0; }
5173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5175 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5176 const _CharT* __rhs)
5177 {
return __lhs.
compare(__rhs) < 0; }
5185 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5187 operator<(
const _CharT* __lhs,
5189 {
return __rhs.compare(__lhs) > 0; }
5198 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5203 {
return __lhs.compare(__rhs) > 0; }
5211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5214 const _CharT* __rhs)
5215 {
return __lhs.compare(__rhs) > 0; }
5223 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5225 operator>(
const _CharT* __lhs,
5227 {
return __rhs.compare(__lhs) < 0; }
5236 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5238 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5241 {
return __lhs.
compare(__rhs) <= 0; }
5249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5251 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5252 const _CharT* __rhs)
5253 {
return __lhs.
compare(__rhs) <= 0; }
5261 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5263 operator<=(
const _CharT* __lhs,
5265 {
return __rhs.compare(__lhs) >= 0; }
5274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5279 {
return __lhs.compare(__rhs) >= 0; }
5287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5290 const _CharT* __rhs)
5291 {
return __lhs.compare(__rhs) >= 0; }
5299 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5301 operator>=(
const _CharT* __lhs,
5303 {
return __rhs.compare(__lhs) <= 0; }
5312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5316 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5317 { __lhs.swap(__rhs); }
5332 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5350 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5352 operator<<(basic_ostream<_CharT, _Traits>& __os,
5357 return __ostream_insert(__os, __str.
data(), __str.
size());
5373 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5390 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5396 #if __cplusplus >= 201103L 5398 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5405 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5417 #ifdef _GLIBCXX_USE_WCHAR_T 5424 _GLIBCXX_END_NAMESPACE_VERSION
5427 #if __cplusplus >= 201103L 5431 namespace std _GLIBCXX_VISIBILITY(default)
5433 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5434 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5436 #if _GLIBCXX_USE_C99_STDLIB 5439 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5440 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5444 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5445 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5448 inline unsigned long 5449 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5450 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5454 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5455 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5458 inline unsigned long long 5459 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5460 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5465 stof(
const string& __str,
size_t* __idx = 0)
5466 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5469 stod(
const string& __str,
size_t* __idx = 0)
5470 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5473 stold(
const string& __str,
size_t* __idx = 0)
5474 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5475 #endif // _GLIBCXX_USE_C99_STDLIB 5477 #if _GLIBCXX_USE_C99_STDIO 5482 to_string(
int __val)
5483 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5487 to_string(
unsigned __val)
5488 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5489 4 *
sizeof(unsigned),
5493 to_string(
long __val)
5494 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5498 to_string(
unsigned long __val)
5499 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5500 4 *
sizeof(
unsigned long),
5504 to_string(
long long __val)
5505 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5506 4 *
sizeof(
long long),
5510 to_string(
unsigned long long __val)
5511 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5512 4 *
sizeof(
unsigned long long),
5516 to_string(
float __val)
5519 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5520 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5525 to_string(
double __val)
5528 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5529 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5534 to_string(
long double __val)
5537 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5538 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5541 #endif // _GLIBCXX_USE_C99_STDIO 5543 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 5545 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5546 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5550 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5551 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5554 inline unsigned long 5555 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5556 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5560 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5561 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5564 inline unsigned long long 5565 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5566 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5571 stof(
const wstring& __str,
size_t* __idx = 0)
5572 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5575 stod(
const wstring& __str,
size_t* __idx = 0)
5576 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5579 stold(
const wstring& __str,
size_t* __idx = 0)
5580 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5582 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5585 to_wstring(
int __val)
5586 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5590 to_wstring(
unsigned __val)
5591 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5592 4 *
sizeof(unsigned),
5596 to_wstring(
long __val)
5597 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5601 to_wstring(
unsigned long __val)
5602 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5603 4 *
sizeof(
unsigned long),
5607 to_wstring(
long long __val)
5608 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5609 4 *
sizeof(
long long),
5613 to_wstring(
unsigned long long __val)
5614 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5615 4 *
sizeof(
unsigned long long),
5619 to_wstring(
float __val)
5622 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5623 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5628 to_wstring(
double __val)
5631 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5632 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5637 to_wstring(
long double __val)
5640 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5641 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
5644 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5645 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 5647 _GLIBCXX_END_NAMESPACE_CXX11
5648 _GLIBCXX_END_NAMESPACE_VERSION
5653 #if __cplusplus >= 201103L 5657 namespace std _GLIBCXX_VISIBILITY(default)
5659 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5663 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 5667 :
public __hash_base<size_t, string>
5670 operator()(
const string& __s)
const noexcept
5671 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
5678 #ifdef _GLIBCXX_USE_WCHAR_T 5682 :
public __hash_base<size_t, wstring>
5685 operator()(
const wstring& __s)
const noexcept
5686 {
return std::_Hash_impl::hash(__s.
data(),
5687 __s.
length() *
sizeof(wchar_t)); }
5696 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5700 :
public __hash_base<size_t, u16string>
5703 operator()(
const u16string& __s)
const noexcept
5704 {
return std::_Hash_impl::hash(__s.
data(),
5705 __s.
length() *
sizeof(char16_t)); }
5715 :
public __hash_base<size_t, u32string>
5718 operator()(
const u32string& __s)
const noexcept
5719 {
return std::_Hash_impl::hash(__s.
data(),
5720 __s.
length() *
sizeof(char32_t)); }
5728 _GLIBCXX_END_NAMESPACE_VERSION
5730 #if __cplusplus > 201103L 5732 #define __cpp_lib_string_udls 201304 5734 inline namespace literals
5736 inline namespace string_literals
5738 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5740 _GLIBCXX_DEFAULT_ABI_TAG
5742 operator""s(
const char* __str,
size_t __len)
5745 #ifdef _GLIBCXX_USE_WCHAR_T 5746 _GLIBCXX_DEFAULT_ABI_TAG
5748 operator""s(
const wchar_t* __str,
size_t __len)
5752 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 5753 _GLIBCXX_DEFAULT_ABI_TAG
5755 operator""s(
const char16_t* __str,
size_t __len)
5758 _GLIBCXX_DEFAULT_ABI_TAG
5760 operator""s(
const char32_t* __str,
size_t __len)
5764 _GLIBCXX_END_NAMESPACE_VERSION
5768 #endif // __cplusplus > 201103L
static const size_type npos
Value returned by various member functions when they fail.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_reverse_iterator rbegin() const noexcept
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string()
Default constructor creates an empty string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
Uniform interface to C++98 and C++11 allocators.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
const_reverse_iterator crend() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
Managing sequences of characters and character-like objects.
const_reference back() const noexcept
Template class basic_ostream.
const_iterator end() const noexcept
int compare(const basic_string &__str) const
Compare to a string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
const_reference front() const noexcept
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
reverse_iterator rbegin()
Uniform interface to all pointer-like types.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position 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.
const_iterator begin() const noexcept
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
void push_back(_CharT __c)
Append a single character.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
iterator erase(iterator __position)
Remove one character.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character of C string.
const_iterator cend() const noexcept
Template class basic_istream.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
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.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a 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.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
char_type widen(char __c) const
Widens characters.
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
reference at(size_type __n)
Provides access to the data contained in the string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
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.
One of the comparison functors.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
size_type capacity() const noexcept
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
Basis for explicit traits specializations.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_iterator cbegin() const noexcept
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
Forward iterators support a superset of input iterator operations.
void pop_back()
Remove the last character.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
iterator insert(iterator __p, _CharT __c)
Insert one character.
const_reverse_iterator rend() const noexcept
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
basic_string & operator+=(const _CharT *__s)
Append a C string.
Primary class template hash.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
bool empty() const noexcept
~basic_string() noexcept
Destroy the string instance.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.