34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 #if __cplusplus > 201402L 52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 #if _GLIBCXX_USE_CXX11_ABI 57 _GLIBCXX_BEGIN_NAMESPACE_CXX11
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
80 rebind<_CharT>::other _Char_alloc_type;
85 typedef _Traits traits_type;
86 typedef typename _Traits::char_type value_type;
87 typedef _Char_alloc_type allocator_type;
88 typedef typename _Alloc_traits::size_type size_type;
89 typedef typename _Alloc_traits::difference_type difference_type;
90 typedef typename _Alloc_traits::reference reference;
91 typedef typename _Alloc_traits::const_reference const_reference;
92 typedef typename _Alloc_traits::pointer pointer;
93 typedef typename _Alloc_traits::const_pointer const_pointer;
94 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
95 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
101 static const size_type
npos =
static_cast<size_type
>(-1);
105 #if __cplusplus < 201103L 106 typedef iterator __const_iterator;
108 typedef const_iterator __const_iterator;
111 #if __cplusplus > 201402L 113 typedef basic_string_view<_CharT, _Traits> __sv_type;
117 struct _Alloc_hider : allocator_type
119 #if __cplusplus < 201103L 120 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
121 : allocator_type(__a), _M_p(__dat) { }
123 _Alloc_hider(pointer __dat,
const _Alloc& __a)
124 : allocator_type(__a), _M_p(__dat) { }
126 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
127 : allocator_type(
std::move(__a)), _M_p(__dat) { }
133 _Alloc_hider _M_dataplus;
134 size_type _M_string_length;
136 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
140 _CharT _M_local_buf[_S_local_capacity + 1];
141 size_type _M_allocated_capacity;
146 { _M_dataplus._M_p = __p; }
149 _M_length(size_type __length)
150 { _M_string_length = __length; }
154 {
return _M_dataplus._M_p; }
159 #if __cplusplus >= 201103L 162 return pointer(_M_local_buf);
167 _M_local_data()
const 169 #if __cplusplus >= 201103L 172 return const_pointer(_M_local_buf);
177 _M_capacity(size_type __capacity)
178 { _M_allocated_capacity = __capacity; }
181 _M_set_length(size_type __n)
184 traits_type::assign(_M_data()[__n], _CharT());
189 {
return _M_data() == _M_local_data(); }
193 _M_create(size_type&, size_type);
199 _M_destroy(_M_allocated_capacity);
203 _M_destroy(size_type __size)
throw()
204 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
208 template<
typename _InIterator>
210 _M_construct_aux(_InIterator __beg, _InIterator __end,
213 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
214 _M_construct(__beg, __end, _Tag());
219 template<
typename _Integer>
221 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
222 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
225 _M_construct_aux_2(size_type __req, _CharT __c)
226 { _M_construct(__req, __c); }
228 template<
typename _InIterator>
230 _M_construct(_InIterator __beg, _InIterator __end)
232 typedef typename std::__is_integer<_InIterator>::__type _Integral;
233 _M_construct_aux(__beg, __end, _Integral());
237 template<
typename _InIterator>
239 _M_construct(_InIterator __beg, _InIterator __end,
244 template<
typename _FwdIterator>
246 _M_construct(_FwdIterator __beg, _FwdIterator __end,
250 _M_construct(size_type __req, _CharT __c);
254 {
return _M_dataplus; }
256 const allocator_type&
257 _M_get_allocator()
const 258 {
return _M_dataplus; }
262 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 265 template<
typename _Tp,
bool _Requires =
266 !__are_same<_Tp, _CharT*>::__value
267 && !__are_same<_Tp, const _CharT*>::__value
268 && !__are_same<_Tp, iterator>::__value
269 && !__are_same<_Tp, const_iterator>::__value>
270 struct __enable_if_not_native_iterator
272 template<
typename _Tp>
273 struct __enable_if_not_native_iterator<_Tp, false> { };
277 _M_check(size_type __pos,
const char* __s)
const 279 if (__pos > this->
size())
280 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 281 "this->size() (which is %zu)"),
282 __s, __pos, this->
size());
287 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 290 __throw_length_error(__N(__s));
296 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
298 const bool __testoff = __off < this->
size() - __pos;
299 return __testoff ? __off : this->
size() - __pos;
304 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
306 return (less<const _CharT*>()(__s, _M_data())
307 || less<const _CharT*>()(_M_data() + this->
size(), __s));
313 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
316 traits_type::assign(*__d, *__s);
318 traits_type::copy(__d, __s, __n);
322 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
325 traits_type::assign(*__d, *__s);
327 traits_type::move(__d, __s, __n);
331 _S_assign(_CharT* __d, size_type __n, _CharT __c)
334 traits_type::assign(*__d, __c);
336 traits_type::assign(__d, __n, __c);
341 template<
class _Iterator>
343 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
345 for (; __k1 != __k2; ++__k1, (void)++__p)
346 traits_type::assign(*__p, *__k1);
350 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
351 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
354 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
356 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
359 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
360 { _S_copy(__p, __k1, __k2 - __k1); }
363 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
365 { _S_copy(__p, __k1, __k2 - __k1); }
368 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
370 const difference_type __d = difference_type(__n1 - __n2);
372 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
373 return __gnu_cxx::__numeric_traits<int>::__max;
374 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
375 return __gnu_cxx::__numeric_traits<int>::__min;
384 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
388 _M_erase(size_type __pos, size_type __n);
399 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
400 : _M_dataplus(_M_local_data())
401 { _M_set_length(0); }
408 : _M_dataplus(_M_local_data(), __a)
409 { _M_set_length(0); }
416 : _M_dataplus(_M_local_data(),
417 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
418 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
429 const _Alloc& __a = _Alloc())
430 : _M_dataplus(_M_local_data(), __a)
432 const _CharT* __start = __str._M_data()
433 + __str._M_check(__pos,
"basic_string::basic_string");
434 _M_construct(__start, __start + __str._M_limit(__pos, npos));
443 basic_string(
const basic_string& __str, size_type __pos,
445 : _M_dataplus(_M_local_data())
447 const _CharT* __start = __str._M_data()
448 + __str._M_check(__pos,
"basic_string::basic_string");
449 _M_construct(__start, __start + __str._M_limit(__pos, __n));
459 basic_string(
const basic_string& __str, size_type __pos,
460 size_type __n,
const _Alloc& __a)
461 : _M_dataplus(_M_local_data(), __a)
463 const _CharT* __start
464 = __str._M_data() + __str._M_check(__pos,
"string::string");
465 _M_construct(__start, __start + __str._M_limit(__pos, __n));
478 const _Alloc& __a = _Alloc())
479 : _M_dataplus(_M_local_data(), __a)
480 { _M_construct(__s, __s + __n); }
487 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
488 : _M_dataplus(_M_local_data(), __a)
489 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
497 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
498 : _M_dataplus(_M_local_data(), __a)
499 { _M_construct(__n, __c); }
501 #if __cplusplus >= 201103L 510 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
512 if (__str._M_is_local())
514 traits_type::copy(_M_local_buf, __str._M_local_buf,
515 _S_local_capacity + 1);
519 _M_data(__str._M_data());
520 _M_capacity(__str._M_allocated_capacity);
526 _M_length(__str.length());
527 __str._M_data(__str._M_local_data());
528 __str._M_set_length(0);
536 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
537 : _M_dataplus(_M_local_data(), __a)
538 { _M_construct(__l.begin(), __l.end()); }
540 basic_string(
const basic_string& __str,
const _Alloc& __a)
541 : _M_dataplus(_M_local_data(), __a)
542 { _M_construct(__str.begin(), __str.end()); }
545 noexcept(_Alloc_traits::_S_always_equal())
546 : _M_dataplus(_M_local_data(), __a)
548 if (__str._M_is_local())
550 traits_type::copy(_M_local_buf, __str._M_local_buf,
551 _S_local_capacity + 1);
552 _M_length(__str.length());
553 __str._M_set_length(0);
555 else if (_Alloc_traits::_S_always_equal()
556 || __str.get_allocator() == __a)
558 _M_data(__str._M_data());
559 _M_length(__str.length());
560 _M_capacity(__str._M_allocated_capacity);
561 __str._M_data(__str._M_local_buf);
562 __str._M_set_length(0);
565 _M_construct(__str.begin(), __str.end());
576 #if __cplusplus >= 201103L 577 template<
typename _InputIterator,
578 typename = std::_RequireInputIter<_InputIterator>>
580 template<
typename _InputIterator>
582 basic_string(_InputIterator __beg, _InputIterator __end,
583 const _Alloc& __a = _Alloc())
584 : _M_dataplus(_M_local_data(), __a)
585 { _M_construct(__beg, __end); }
587 #if __cplusplus > 201402L 588 template<
typename _Tp,
typename _Res>
589 using _If_sv = enable_if_t<
590 __and_<is_convertible<const _Tp&, __sv_type>,
591 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
601 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
602 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
603 const _Alloc& __a = _Alloc())
604 : basic_string(__sv_type(__t).
substr(__pos, __n), __a) { }
612 basic_string(__sv_type __sv,
const _Alloc& __a = _Alloc())
613 : basic_string(__sv.
data(), __sv.
size(), __a) { }
629 #if __cplusplus >= 201103L 630 if (_Alloc_traits::_S_propagate_on_copy_assign())
632 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
633 && _M_get_allocator() != __str._M_get_allocator())
636 _M_destroy(_M_allocated_capacity);
637 _M_data(_M_local_data());
640 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
643 return this->
assign(__str);
652 {
return this->
assign(__s); }
668 #if __cplusplus >= 201103L 681 noexcept(_Alloc_traits::_S_nothrow_move())
683 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
684 && !_Alloc_traits::_S_always_equal()
685 && _M_get_allocator() != __str._M_get_allocator())
688 _M_destroy(_M_allocated_capacity);
689 _M_data(_M_local_data());
693 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
695 if (!__str._M_is_local()
696 && (_Alloc_traits::_S_propagate_on_move_assign()
697 || _Alloc_traits::_S_always_equal()))
699 pointer __data =
nullptr;
700 size_type __capacity;
703 if (_Alloc_traits::_S_always_equal())
706 __capacity = _M_allocated_capacity;
709 _M_destroy(_M_allocated_capacity);
712 _M_data(__str._M_data());
713 _M_length(__str.length());
714 _M_capacity(__str._M_allocated_capacity);
717 __str._M_data(__data);
718 __str._M_capacity(__capacity);
721 __str._M_data(__str._M_local_buf);
736 this->
assign(__l.begin(), __l.size());
741 #if __cplusplus > 201402L 748 {
return this->
assign(__sv); }
754 operator __sv_type() const noexcept
755 {
return __sv_type(
data(),
size()); }
764 begin() _GLIBCXX_NOEXCEPT
765 {
return iterator(_M_data()); }
772 begin() const _GLIBCXX_NOEXCEPT
773 {
return const_iterator(_M_data()); }
780 end() _GLIBCXX_NOEXCEPT
781 {
return iterator(_M_data() + this->
size()); }
788 end() const _GLIBCXX_NOEXCEPT
789 {
return const_iterator(_M_data() + this->
size()); }
797 rbegin() _GLIBCXX_NOEXCEPT
798 {
return reverse_iterator(this->
end()); }
805 const_reverse_iterator
806 rbegin() const _GLIBCXX_NOEXCEPT
807 {
return const_reverse_iterator(this->
end()); }
815 rend() _GLIBCXX_NOEXCEPT
816 {
return reverse_iterator(this->
begin()); }
823 const_reverse_iterator
824 rend() const _GLIBCXX_NOEXCEPT
825 {
return const_reverse_iterator(this->
begin()); }
827 #if __cplusplus >= 201103L 834 {
return const_iterator(this->_M_data()); }
841 cend() const noexcept
842 {
return const_iterator(this->_M_data() + this->
size()); }
849 const_reverse_iterator
851 {
return const_reverse_iterator(this->
end()); }
858 const_reverse_iterator
859 crend() const noexcept
860 {
return const_reverse_iterator(this->
begin()); }
868 size() const _GLIBCXX_NOEXCEPT
869 {
return _M_string_length; }
874 length() const _GLIBCXX_NOEXCEPT
875 {
return _M_string_length; }
880 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
893 resize(size_type __n, _CharT __c);
907 { this->
resize(__n, _CharT()); }
909 #if __cplusplus >= 201103L 933 return _M_is_local() ? size_type(_S_local_capacity)
934 : _M_allocated_capacity;
955 reserve(size_type __res_arg = 0);
961 clear() _GLIBCXX_NOEXCEPT
962 { _M_set_length(0); }
969 empty() const _GLIBCXX_NOEXCEPT
970 {
return this->
size() == 0; }
984 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
986 __glibcxx_assert(__pos <=
size());
987 return _M_data()[__pos];
1005 __glibcxx_assert(__pos <=
size());
1007 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1008 return _M_data()[__pos];
1022 at(size_type __n)
const 1024 if (__n >= this->
size())
1025 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1026 "(which is %zu) >= this->size() " 1029 return _M_data()[__n];
1046 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1047 "(which is %zu) >= this->size() " 1050 return _M_data()[__n];
1053 #if __cplusplus >= 201103L 1061 __glibcxx_assert(!
empty());
1070 front() const noexcept
1072 __glibcxx_assert(!
empty());
1083 __glibcxx_assert(!
empty());
1092 back() const noexcept
1094 __glibcxx_assert(!
empty());
1107 {
return this->
append(__str); }
1116 {
return this->
append(__s); }
1130 #if __cplusplus >= 201103L 1138 {
return this->
append(__l.begin(), __l.size()); }
1141 #if __cplusplus > 201402L 1149 {
return this->
append(__sv); }
1158 append(
const basic_string& __str)
1159 {
return _M_append(__str._M_data(), __str.size()); }
1175 append(
const basic_string& __str, size_type __pos, size_type __n)
1176 {
return _M_append(__str._M_data()
1177 + __str._M_check(__pos,
"basic_string::append"),
1178 __str._M_limit(__pos, __n)); }
1187 append(
const _CharT* __s, size_type __n)
1189 __glibcxx_requires_string_len(__s, __n);
1190 _M_check_length(size_type(0), __n,
"basic_string::append");
1191 return _M_append(__s, __n);
1200 append(
const _CharT* __s)
1202 __glibcxx_requires_string(__s);
1203 const size_type __n = traits_type::length(__s);
1204 _M_check_length(size_type(0), __n,
"basic_string::append");
1205 return _M_append(__s, __n);
1217 append(size_type __n, _CharT __c)
1218 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1220 #if __cplusplus >= 201103L 1227 append(initializer_list<_CharT> __l)
1228 {
return this->
append(__l.begin(), __l.size()); }
1239 #if __cplusplus >= 201103L 1240 template<
class _InputIterator,
1241 typename = std::_RequireInputIter<_InputIterator>>
1243 template<
class _InputIterator>
1246 append(_InputIterator __first, _InputIterator __last)
1249 #if __cplusplus > 201402L 1257 {
return this->
append(__sv.data(), __sv.size()); }
1266 template <
typename _Tp>
1267 _If_sv<_Tp, basic_string&>
1268 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1270 __sv_type __sv = __svt;
1271 return _M_append(__sv.data()
1272 + __sv._M_check(__pos,
"basic_string::append"),
1273 __sv._M_limit(__pos, __n));
1284 const size_type __size = this->
size();
1286 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1287 traits_type::assign(this->_M_data()[__size], __c);
1288 this->_M_set_length(__size + 1);
1297 assign(
const basic_string& __str)
1299 this->_M_assign(__str);
1303 #if __cplusplus >= 201103L 1313 assign(basic_string&& __str)
1314 noexcept(_Alloc_traits::_S_nothrow_move())
1318 return *
this = std::move(__str);
1336 assign(
const basic_string& __str, size_type __pos, size_type __n)
1337 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1338 + __str._M_check(__pos,
"basic_string::assign"),
1339 __str._M_limit(__pos, __n)); }
1352 assign(
const _CharT* __s, size_type __n)
1354 __glibcxx_requires_string_len(__s, __n);
1355 return _M_replace(size_type(0), this->
size(), __s, __n);
1368 assign(
const _CharT* __s)
1370 __glibcxx_requires_string(__s);
1371 return _M_replace(size_type(0), this->
size(), __s,
1372 traits_type::length(__s));
1385 assign(size_type __n, _CharT __c)
1386 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1396 #if __cplusplus >= 201103L 1397 template<
class _InputIterator,
1398 typename = std::_RequireInputIter<_InputIterator>>
1400 template<
class _InputIterator>
1403 assign(_InputIterator __first, _InputIterator __last)
1406 #if __cplusplus >= 201103L 1413 assign(initializer_list<_CharT> __l)
1414 {
return this->
assign(__l.begin(), __l.size()); }
1417 #if __cplusplus > 201402L 1425 {
return this->
assign(__sv.data(), __sv.size()); }
1434 template <
typename _Tp>
1435 _If_sv<_Tp, basic_string&>
1436 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
1438 __sv_type __sv = __svt;
1439 return _M_replace(size_type(0), this->
size(), __sv.data()
1440 + __sv._M_check(__pos,
"basic_string::assign"),
1441 __sv._M_limit(__pos, __n));
1445 #if __cplusplus >= 201103L 1462 insert(const_iterator __p, size_type __n, _CharT __c)
1464 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1465 const size_type __pos = __p -
begin();
1466 this->
replace(__p, __p, __n, __c);
1467 return iterator(this->_M_data() + __pos);
1484 insert(iterator __p, size_type __n, _CharT __c)
1485 { this->
replace(__p, __p, __n, __c); }
1488 #if __cplusplus >= 201103L 1503 template<
class _InputIterator,
1504 typename = std::_RequireInputIter<_InputIterator>>
1506 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1508 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1509 const size_type __pos = __p -
begin();
1510 this->
replace(__p, __p, __beg, __end);
1511 return iterator(this->_M_data() + __pos);
1526 template<
class _InputIterator>
1528 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1529 { this->
replace(__p, __p, __beg, __end); }
1532 #if __cplusplus >= 201103L 1540 insert(iterator __p, initializer_list<_CharT> __l)
1542 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1543 this->
insert(__p -
begin(), __l.begin(), __l.size());
1560 insert(size_type __pos1,
const basic_string& __str)
1561 {
return this->
replace(__pos1, size_type(0),
1562 __str._M_data(), __str.size()); }
1583 insert(size_type __pos1,
const basic_string& __str,
1584 size_type __pos2, size_type __n)
1585 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1586 + __str._M_check(__pos2,
"basic_string::insert"),
1587 __str._M_limit(__pos2, __n)); }
1606 insert(size_type __pos,
const _CharT* __s, size_type __n)
1607 {
return this->
replace(__pos, size_type(0), __s, __n); }
1625 insert(size_type __pos,
const _CharT* __s)
1627 __glibcxx_requires_string(__s);
1628 return this->
replace(__pos, size_type(0), __s,
1629 traits_type::length(__s));
1649 insert(size_type __pos, size_type __n, _CharT __c)
1650 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1651 size_type(0), __n, __c); }
1667 insert(__const_iterator __p, _CharT __c)
1669 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1670 const size_type __pos = __p -
begin();
1671 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1672 return iterator(_M_data() + __pos);
1675 #if __cplusplus > 201402L 1683 insert(size_type __pos, __sv_type __sv)
1684 {
return this->
insert(__pos, __sv.data(), __sv.size()); }
1695 template <
typename _Tp>
1696 _If_sv<_Tp, basic_string&>
1697 insert(size_type __pos1,
const _Tp& __svt,
1698 size_type __pos2, size_type __n = npos)
1700 __sv_type __sv = __svt;
1701 return this->
replace(__pos1, size_type(0), __sv.data()
1702 + __sv._M_check(__pos2,
"basic_string::insert"),
1703 __sv._M_limit(__pos2, __n));
1723 erase(size_type __pos = 0, size_type __n = npos)
1725 _M_check(__pos,
"basic_string::erase");
1727 this->_M_set_length(__pos);
1729 this->_M_erase(__pos, _M_limit(__pos, __n));
1742 erase(__const_iterator __position)
1744 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1745 && __position <
end());
1746 const size_type __pos = __position -
begin();
1747 this->_M_erase(__pos, size_type(1));
1748 return iterator(_M_data() + __pos);
1761 erase(__const_iterator __first, __const_iterator __last)
1763 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1764 && __last <=
end());
1765 const size_type __pos = __first -
begin();
1766 if (__last ==
end())
1767 this->_M_set_length(__pos);
1769 this->_M_erase(__pos, __last - __first);
1770 return iterator(this->_M_data() + __pos);
1773 #if __cplusplus >= 201103L 1782 __glibcxx_assert(!
empty());
1783 _M_erase(
size() - 1, 1);
1805 replace(size_type __pos, size_type __n,
const basic_string& __str)
1806 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1827 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
1828 size_type __pos2, size_type __n2)
1829 {
return this->
replace(__pos1, __n1, __str._M_data()
1830 + __str._M_check(__pos2,
"basic_string::replace"),
1831 __str._M_limit(__pos2, __n2)); }
1852 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1855 __glibcxx_requires_string_len(__s, __n2);
1856 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1857 _M_limit(__pos, __n1), __s, __n2);
1877 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1879 __glibcxx_requires_string(__s);
1880 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1901 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1902 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1903 _M_limit(__pos, __n1), __n2, __c); }
1919 replace(__const_iterator __i1, __const_iterator __i2,
1920 const basic_string& __str)
1921 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
1939 replace(__const_iterator __i1, __const_iterator __i2,
1940 const _CharT* __s, size_type __n)
1942 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1944 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
1961 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
1963 __glibcxx_requires_string(__s);
1964 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
1982 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
1985 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
1987 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2005 #if __cplusplus >= 201103L 2006 template<
class _InputIterator,
2007 typename = std::_RequireInputIter<_InputIterator>>
2009 replace(const_iterator __i1, const_iterator __i2,
2010 _InputIterator __k1, _InputIterator __k2)
2012 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2014 __glibcxx_requires_valid_range(__k1, __k2);
2015 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2016 std::__false_type());
2019 template<
class _InputIterator>
2020 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2021 typename __enable_if_not_native_iterator<_InputIterator>::__type
2025 replace(iterator __i1, iterator __i2,
2026 _InputIterator __k1, _InputIterator __k2)
2028 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2030 __glibcxx_requires_valid_range(__k1, __k2);
2031 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2032 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2039 replace(__const_iterator __i1, __const_iterator __i2,
2040 _CharT* __k1, _CharT* __k2)
2042 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2044 __glibcxx_requires_valid_range(__k1, __k2);
2050 replace(__const_iterator __i1, __const_iterator __i2,
2051 const _CharT* __k1,
const _CharT* __k2)
2053 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2055 __glibcxx_requires_valid_range(__k1, __k2);
2061 replace(__const_iterator __i1, __const_iterator __i2,
2062 iterator __k1, iterator __k2)
2064 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2066 __glibcxx_requires_valid_range(__k1, __k2);
2068 __k1.base(), __k2 - __k1);
2072 replace(__const_iterator __i1, __const_iterator __i2,
2073 const_iterator __k1, const_iterator __k2)
2075 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2077 __glibcxx_requires_valid_range(__k1, __k2);
2079 __k1.base(), __k2 - __k1);
2082 #if __cplusplus >= 201103L 2097 basic_string&
replace(const_iterator __i1, const_iterator __i2,
2098 initializer_list<_CharT> __l)
2099 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2102 #if __cplusplus > 201402L 2111 replace(size_type __pos, size_type __n, __sv_type __sv)
2112 {
return this->
replace(__pos, __n, __sv.data(), __sv.size()); }
2123 template <
typename _Tp>
2124 _If_sv<_Tp, basic_string&>
2125 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2126 size_type __pos2, size_type __n2 = npos)
2128 __sv_type __sv = __svt;
2129 return this->
replace(__pos1, __n1, __sv.data()
2130 + __sv._M_check(__pos2,
"basic_string::replace"),
2131 __sv._M_limit(__pos2, __n2));
2144 replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
2145 {
return this->
replace(__i1 -
begin(), __i2 - __i1, __sv); }
2149 template<
class _Integer>
2151 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2152 _Integer __n, _Integer __val, __true_type)
2153 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2155 template<
class _InputIterator>
2157 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2158 _InputIterator __k1, _InputIterator __k2,
2162 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2166 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2167 const size_type __len2);
2170 _M_append(
const _CharT* __s, size_type __n);
2187 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2197 swap(basic_string& __s) _GLIBCXX_NOEXCEPT;
2207 c_str() const _GLIBCXX_NOEXCEPT
2208 {
return _M_data(); }
2219 data() const _GLIBCXX_NOEXCEPT
2220 {
return _M_data(); }
2222 #if __cplusplus > 201402L 2231 {
return _M_data(); }
2239 {
return _M_get_allocator(); }
2254 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2268 find(
const basic_string& __str, size_type __pos = 0) const
2270 {
return this->
find(__str.data(), __pos, __str.size()); }
2272 #if __cplusplus > 201402L 2280 find(__sv_type __sv, size_type __pos = 0) const noexcept
2281 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2295 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2297 __glibcxx_requires_string(__s);
2298 return this->
find(__s, __pos, traits_type::length(__s));
2312 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2325 rfind(const basic_string& __str, size_type __pos = npos) const
2327 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2329 #if __cplusplus > 201402L 2337 rfind(__sv_type __sv, size_type __pos = npos) const noexcept
2338 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2354 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2368 rfind(
const _CharT* __s, size_type __pos = npos)
const 2370 __glibcxx_requires_string(__s);
2371 return this->
rfind(__s, __pos, traits_type::length(__s));
2385 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2399 find_first_of(const basic_string& __str, size_type __pos = 0) const
2401 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2403 #if __cplusplus > 201402L 2411 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2412 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2428 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2445 __glibcxx_requires_string(__s);
2446 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2462 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2463 {
return this->
find(__c, __pos); }
2477 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2479 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2481 #if __cplusplus > 201402L 2489 find_last_of(__sv_type __sv, size_type __pos = npos) const noexcept
2490 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2506 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2520 find_last_of(
const _CharT* __s, size_type __pos = npos) const
2523 __glibcxx_requires_string(__s);
2524 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2540 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2541 {
return this->
rfind(__c, __pos); }
2558 #if __cplusplus > 201402L 2584 size_type __n)
const _GLIBCXX_NOEXCEPT;
2600 __glibcxx_requires_string(__s);
2634 #if __cplusplus > 201402L 2660 size_type __n)
const _GLIBCXX_NOEXCEPT;
2676 __glibcxx_requires_string(__s);
2707 substr(size_type __pos = 0, size_type __n = npos)
const 2709 _M_check(__pos,
"basic_string::substr"), __n); }
2726 compare(
const basic_string& __str)
const 2728 const size_type __size = this->
size();
2729 const size_type __osize = __str.size();
2730 const size_type __len =
std::min(__size, __osize);
2732 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2734 __r = _S_compare(__size, __osize);
2738 #if __cplusplus > 201402L 2747 const size_type __size = this->
size();
2748 const size_type __osize = __sv.size();
2749 const size_type __len =
std::min(__size, __osize);
2751 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2753 __r = _S_compare(__size, __osize);
2765 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2766 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2777 template <
typename _Tp>
2779 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2780 size_type __pos2, size_type __n2 = npos)
const 2782 __sv_type __sv = __svt;
2783 return __sv_type(*
this)
2784 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2808 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2834 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2835 size_type __pos2, size_type __n2)
const;
2852 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2876 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2903 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2904 size_type __n2)
const;
2906 _GLIBCXX_END_NAMESPACE_CXX11
2907 #else // !_GLIBCXX_USE_CXX11_ABI 2972 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2975 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2979 typedef _Traits traits_type;
2980 typedef typename _Traits::char_type value_type;
2981 typedef _Alloc allocator_type;
2982 typedef typename _CharT_alloc_type::size_type size_type;
2983 typedef typename _CharT_alloc_type::difference_type difference_type;
2984 typedef typename _CharT_alloc_type::reference reference;
2985 typedef typename _CharT_alloc_type::const_reference const_reference;
2986 typedef typename _CharT_alloc_type::pointer pointer;
2987 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2988 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2989 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3011 size_type _M_length;
3012 size_type _M_capacity;
3013 _Atomic_word _M_refcount;
3016 struct _Rep : _Rep_base
3019 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3034 static const size_type _S_max_size;
3035 static const _CharT _S_terminal;
3039 static size_type _S_empty_rep_storage[];
3042 _S_empty_rep() _GLIBCXX_NOEXCEPT
3047 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3048 return *
reinterpret_cast<_Rep*
>(__p);
3052 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3054 #if defined(__GTHREADS) 3059 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3061 return this->_M_refcount < 0;
3066 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3068 #if defined(__GTHREADS) 3074 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3076 return this->_M_refcount > 0;
3081 _M_set_leaked() _GLIBCXX_NOEXCEPT
3082 { this->_M_refcount = -1; }
3085 _M_set_sharable() _GLIBCXX_NOEXCEPT
3086 { this->_M_refcount = 0; }
3089 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3091 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3092 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3095 this->_M_set_sharable();
3096 this->_M_length = __n;
3097 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3104 _M_refdata()
throw()
3105 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3108 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3110 return (!_M_is_leaked() && __alloc1 == __alloc2)
3111 ? _M_refcopy() : _M_clone(__alloc1);
3116 _S_create(size_type, size_type,
const _Alloc&);
3119 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3121 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3122 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3126 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3135 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3138 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3145 _M_destroy(
const _Alloc&)
throw();
3148 _M_refcopy()
throw()
3150 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3151 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3153 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3154 return _M_refdata();
3158 _M_clone(
const _Alloc&, size_type __res = 0);
3162 struct _Alloc_hider : _Alloc
3164 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3165 : _Alloc(__a), _M_p(__dat) { }
3175 static const size_type npos =
static_cast<size_type
>(-1);
3179 mutable _Alloc_hider _M_dataplus;
3182 _M_data() const _GLIBCXX_NOEXCEPT
3183 {
return _M_dataplus._M_p; }
3186 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3187 {
return (_M_dataplus._M_p = __p); }
3190 _M_rep()
const _GLIBCXX_NOEXCEPT
3191 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3196 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3197 {
return iterator(_M_data()); }
3200 _M_iend()
const _GLIBCXX_NOEXCEPT
3201 {
return iterator(_M_data() + this->
size()); }
3206 if (!_M_rep()->_M_is_leaked())
3211 _M_check(size_type __pos,
const char* __s)
const 3213 if (__pos > this->
size())
3214 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3215 "this->size() (which is %zu)"),
3216 __s, __pos, this->
size());
3221 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3224 __throw_length_error(__N(__s));
3229 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3231 const bool __testoff = __off < this->
size() - __pos;
3232 return __testoff ? __off : this->
size() - __pos;
3237 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3246 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3249 traits_type::assign(*__d, *__s);
3251 traits_type::copy(__d, __s, __n);
3255 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3258 traits_type::assign(*__d, *__s);
3260 traits_type::move(__d, __s, __n);
3264 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3267 traits_type::assign(*__d, __c);
3269 traits_type::assign(__d, __n, __c);
3274 template<
class _Iterator>
3276 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3278 for (; __k1 != __k2; ++__k1, (void)++__p)
3279 traits_type::assign(*__p, *__k1);
3283 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3284 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3287 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3289 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3292 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3293 { _M_copy(__p, __k1, __k2 - __k1); }
3296 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3298 { _M_copy(__p, __k1, __k2 - __k1); }
3301 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3303 const difference_type __d = difference_type(__n1 - __n2);
3305 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3306 return __gnu_cxx::__numeric_traits<int>::__max;
3307 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3308 return __gnu_cxx::__numeric_traits<int>::__min;
3314 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3320 _S_empty_rep() _GLIBCXX_NOEXCEPT
3321 {
return _Rep::_S_empty_rep(); }
3332 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3333 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3335 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3359 basic_string(
const basic_string& __str, size_type __pos,
3360 const _Alloc& __a = _Alloc());
3368 basic_string(
const basic_string& __str, size_type __pos,
3377 basic_string(
const basic_string& __str, size_type __pos,
3378 size_type __n,
const _Alloc& __a);
3390 const _Alloc& __a = _Alloc());
3396 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3403 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3405 #if __cplusplus >= 201103L 3414 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3417 : _M_dataplus(__str._M_dataplus)
3419 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3420 __str._M_data(_S_empty_rep()._M_refdata());
3422 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3440 template<
class _InputIterator>
3441 basic_string(_InputIterator __beg, _InputIterator __end,
3442 const _Alloc& __a = _Alloc());
3456 {
return this->
assign(__str); }
3464 {
return this->
assign(__s); }
3480 #if __cplusplus >= 201103L 3504 this->
assign(__l.begin(), __l.size());
3518 return iterator(_M_data());
3527 {
return const_iterator(_M_data()); }
3537 return iterator(_M_data() + this->
size());
3546 {
return const_iterator(_M_data() + this->
size()); }
3555 {
return reverse_iterator(this->
end()); }
3562 const_reverse_iterator
3564 {
return const_reverse_iterator(this->
end()); }
3573 {
return reverse_iterator(this->
begin()); }
3580 const_reverse_iterator
3582 {
return const_reverse_iterator(this->
begin()); }
3584 #if __cplusplus >= 201103L 3591 {
return const_iterator(this->_M_data()); }
3599 {
return const_iterator(this->_M_data() + this->
size()); }
3606 const_reverse_iterator
3608 {
return const_reverse_iterator(this->
end()); }
3615 const_reverse_iterator
3617 {
return const_reverse_iterator(this->
begin()); }
3626 {
return _M_rep()->_M_length; }
3632 {
return _M_rep()->_M_length; }
3637 {
return _Rep::_S_max_size; }
3650 resize(size_type __n, _CharT __c);
3664 { this->
resize(__n, _CharT()); }
3666 #if __cplusplus >= 201103L 3671 #if __cpp_exceptions 3689 {
return _M_rep()->_M_capacity; }
3709 reserve(size_type __res_arg = 0);
3714 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3718 if (_M_rep()->_M_is_shared())
3721 _M_data(_S_empty_rep()._M_refdata());
3724 _M_rep()->_M_set_length_and_sharable(0);
3730 { _M_mutate(0, this->
size(), 0); }
3739 {
return this->
size() == 0; }
3755 __glibcxx_assert(__pos <=
size());
3756 return _M_data()[__pos];
3774 __glibcxx_assert(__pos <=
size());
3776 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3778 return _M_data()[__pos];
3794 if (__n >= this->
size())
3795 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3796 "(which is %zu) >= this->size() " 3799 return _M_data()[__n];
3817 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3818 "(which is %zu) >= this->size() " 3822 return _M_data()[__n];
3825 #if __cplusplus >= 201103L 3833 __glibcxx_assert(!
empty());
3844 __glibcxx_assert(!
empty());
3855 __glibcxx_assert(!
empty());
3866 __glibcxx_assert(!
empty());
3879 {
return this->
append(__str); }
3888 {
return this->
append(__s); }
3902 #if __cplusplus >= 201103L 3910 {
return this->
append(__l.begin(), __l.size()); }
3919 append(
const basic_string& __str);
3935 append(
const basic_string& __str, size_type __pos, size_type __n);
3944 append(
const _CharT* __s, size_type __n);
3954 __glibcxx_requires_string(__s);
3955 return this->
append(__s, traits_type::length(__s));
3967 append(size_type __n, _CharT __c);
3969 #if __cplusplus >= 201103L 3977 {
return this->
append(__l.begin(), __l.size()); }
3988 template<
class _InputIterator>
3990 append(_InputIterator __first, _InputIterator __last)
3991 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4000 const size_type __len = 1 + this->
size();
4001 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4003 traits_type::assign(_M_data()[this->
size()], __c);
4004 _M_rep()->_M_set_length_and_sharable(__len);
4013 assign(
const basic_string& __str);
4015 #if __cplusplus >= 201103L 4047 assign(
const basic_string& __str, size_type __pos, size_type __n)
4048 {
return this->
assign(__str._M_data()
4049 + __str._M_check(__pos,
"basic_string::assign"),
4050 __str._M_limit(__pos, __n)); }
4063 assign(
const _CharT* __s, size_type __n);
4077 __glibcxx_requires_string(__s);
4078 return this->
assign(__s, traits_type::length(__s));
4092 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4102 template<
class _InputIterator>
4104 assign(_InputIterator __first, _InputIterator __last)
4105 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4107 #if __cplusplus >= 201103L 4115 {
return this->
assign(__l.begin(), __l.size()); }
4132 insert(iterator __p, size_type __n, _CharT __c)
4133 { this->
replace(__p, __p, __n, __c); }
4147 template<
class _InputIterator>
4149 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4150 { this->
replace(__p, __p, __beg, __end); }
4152 #if __cplusplus >= 201103L 4162 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4163 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4180 insert(size_type __pos1,
const basic_string& __str)
4181 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4202 insert(size_type __pos1,
const basic_string& __str,
4203 size_type __pos2, size_type __n)
4204 {
return this->
insert(__pos1, __str._M_data()
4205 + __str._M_check(__pos2,
"basic_string::insert"),
4206 __str._M_limit(__pos2, __n)); }
4225 insert(size_type __pos,
const _CharT* __s, size_type __n);
4245 __glibcxx_requires_string(__s);
4246 return this->
insert(__pos, __s, traits_type::length(__s));
4266 insert(size_type __pos, size_type __n, _CharT __c)
4267 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4268 size_type(0), __n, __c); }
4286 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4287 const size_type __pos = __p - _M_ibegin();
4288 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4289 _M_rep()->_M_set_leaked();
4290 return iterator(_M_data() + __pos);
4309 erase(size_type __pos = 0, size_type __n = npos)
4311 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4312 _M_limit(__pos, __n), size_type(0));
4327 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4328 && __position < _M_iend());
4329 const size_type __pos = __position - _M_ibegin();
4330 _M_mutate(__pos, size_type(1), size_type(0));
4331 _M_rep()->_M_set_leaked();
4332 return iterator(_M_data() + __pos);
4345 erase(iterator __first, iterator __last);
4347 #if __cplusplus >= 201103L 4356 __glibcxx_assert(!
empty());
4379 replace(size_type __pos, size_type __n,
const basic_string& __str)
4380 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4401 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4402 size_type __pos2, size_type __n2)
4403 {
return this->
replace(__pos1, __n1, __str._M_data()
4404 + __str._M_check(__pos2,
"basic_string::replace"),
4405 __str._M_limit(__pos2, __n2)); }
4426 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4446 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4448 __glibcxx_requires_string(__s);
4449 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4470 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4471 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4472 _M_limit(__pos, __n1), __n2, __c); }
4488 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4489 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4507 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4509 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4510 && __i2 <= _M_iend());
4511 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4528 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4530 __glibcxx_requires_string(__s);
4531 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4549 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4551 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4552 && __i2 <= _M_iend());
4553 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4571 template<
class _InputIterator>
4574 _InputIterator __k1, _InputIterator __k2)
4576 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4577 && __i2 <= _M_iend());
4578 __glibcxx_requires_valid_range(__k1, __k2);
4579 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4580 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4586 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4588 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4589 && __i2 <= _M_iend());
4590 __glibcxx_requires_valid_range(__k1, __k2);
4591 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4596 replace(iterator __i1, iterator __i2,
4597 const _CharT* __k1,
const _CharT* __k2)
4599 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4600 && __i2 <= _M_iend());
4601 __glibcxx_requires_valid_range(__k1, __k2);
4602 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4607 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4609 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4610 && __i2 <= _M_iend());
4611 __glibcxx_requires_valid_range(__k1, __k2);
4612 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4613 __k1.base(), __k2 - __k1);
4617 replace(iterator __i1, iterator __i2,
4618 const_iterator __k1, const_iterator __k2)
4620 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4621 && __i2 <= _M_iend());
4622 __glibcxx_requires_valid_range(__k1, __k2);
4623 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4624 __k1.base(), __k2 - __k1);
4627 #if __cplusplus >= 201103L 4642 basic_string&
replace(iterator __i1, iterator __i2,
4644 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4648 template<
class _Integer>
4650 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4651 _Integer __val, __true_type)
4652 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4654 template<
class _InputIterator>
4656 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4657 _InputIterator __k2, __false_type);
4660 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4664 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4669 template<
class _InIterator>
4671 _S_construct_aux(_InIterator __beg, _InIterator __end,
4672 const _Alloc& __a, __false_type)
4674 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4675 return _S_construct(__beg, __end, __a, _Tag());
4680 template<
class _Integer>
4682 _S_construct_aux(_Integer __beg, _Integer __end,
4683 const _Alloc& __a, __true_type)
4684 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4688 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4689 {
return _S_construct(__req, __c, __a); }
4691 template<
class _InIterator>
4693 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4695 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4696 return _S_construct_aux(__beg, __end, __a, _Integral());
4700 template<
class _InIterator>
4702 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4707 template<
class _FwdIterator>
4709 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4713 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4730 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4741 swap(basic_string& __s);
4752 {
return _M_data(); }
4764 {
return _M_data(); }
4766 #if __cplusplus > 201402L 4775 {
return _M_data(); }
4783 {
return _M_dataplus; }
4798 find(
const _CharT* __s, size_type __pos, size_type __n)
const 4812 find(
const basic_string& __str, size_type __pos = 0) const
4814 {
return this->
find(__str.data(), __pos, __str.size()); }
4827 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
4829 __glibcxx_requires_string(__s);
4830 return this->
find(__s, __pos, traits_type::length(__s));
4844 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4857 rfind(
const basic_string& __str, size_type __pos = npos) const
4859 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4874 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 4888 rfind(
const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
4890 __glibcxx_requires_string(__s);
4891 return this->
rfind(__s, __pos, traits_type::length(__s));
4905 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4921 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4936 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 4953 __glibcxx_requires_string(__s);
4954 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4971 {
return this->
find(__c, __pos); }
4987 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5002 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5019 __glibcxx_requires_string(__s);
5020 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5037 {
return this->
rfind(__c, __pos); }
5068 size_type __n)
const _GLIBCXX_NOEXCEPT;
5084 __glibcxx_requires_string(__s);
5132 size_type __n)
const _GLIBCXX_NOEXCEPT;
5148 __glibcxx_requires_string(__s);
5179 substr(size_type __pos = 0, size_type __n = npos)
const 5181 _M_check(__pos,
"basic_string::substr"), __n); }
5200 const size_type __size = this->
size();
5201 const size_type __osize = __str.size();
5202 const size_type __len =
std::min(__size, __osize);
5204 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5206 __r = _S_compare(__size, __osize);
5230 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5256 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5257 size_type __pos2, size_type __n2)
const;
5274 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5298 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5325 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5326 size_type __n2)
const;
5328 # ifdef _GLIBCXX_TM_TS_INTERNAL 5330 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5333 ::_txnal_cow_string_c_str(
const void *that);
5335 ::_txnal_cow_string_D1(
void *that);
5337 ::_txnal_cow_string_D1_commit(
void *that);
5340 #endif // !_GLIBCXX_USE_CXX11_ABI 5349 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5355 __str.append(__rhs);
5365 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5376 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5386 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5389 const _CharT* __rhs)
5392 __str.append(__rhs);
5402 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5407 typedef typename __string_type::size_type __size_type;
5408 __string_type __str(__lhs);
5409 __str.append(__size_type(1), __rhs);
5413 #if __cplusplus >= 201103L 5414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5418 {
return std::move(__lhs.append(__rhs)); }
5420 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5424 {
return std::move(__rhs.insert(0, __lhs)); }
5426 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5431 const auto __size = __lhs.size() + __rhs.size();
5432 const bool __cond = (__size > __lhs.capacity()
5433 && __size <= __rhs.capacity());
5434 return __cond ? std::move(__rhs.insert(0, __lhs))
5435 : std::move(__lhs.append(__rhs));
5438 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5442 {
return std::move(__rhs.insert(0, __lhs)); }
5444 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5448 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5450 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5453 const _CharT* __rhs)
5454 {
return std::move(__lhs.append(__rhs)); }
5456 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5460 {
return std::move(__lhs.append(1, __rhs)); }
5470 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5475 {
return __lhs.compare(__rhs) == 0; }
5477 template<
typename _CharT>
5479 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5482 {
return (__lhs.
size() == __rhs.
size()
5492 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5494 operator==(
const _CharT* __lhs,
5496 {
return __rhs.compare(__lhs) == 0; }
5504 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5507 const _CharT* __rhs)
5508 {
return __lhs.compare(__rhs) == 0; }
5517 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5522 {
return !(__lhs == __rhs); }
5530 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5532 operator!=(
const _CharT* __lhs,
5534 {
return !(__lhs == __rhs); }
5542 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5545 const _CharT* __rhs)
5546 {
return !(__lhs == __rhs); }
5555 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5557 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5560 {
return __lhs.
compare(__rhs) < 0; }
5568 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5570 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5571 const _CharT* __rhs)
5572 {
return __lhs.
compare(__rhs) < 0; }
5580 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5582 operator<(
const _CharT* __lhs,
5584 {
return __rhs.compare(__lhs) > 0; }
5593 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5598 {
return __lhs.compare(__rhs) > 0; }
5606 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5609 const _CharT* __rhs)
5610 {
return __lhs.compare(__rhs) > 0; }
5618 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5620 operator>(
const _CharT* __lhs,
5622 {
return __rhs.compare(__lhs) < 0; }
5631 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5633 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5636 {
return __lhs.
compare(__rhs) <= 0; }
5644 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5646 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5647 const _CharT* __rhs)
5648 {
return __lhs.
compare(__rhs) <= 0; }
5656 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5658 operator<=(
const _CharT* __lhs,
5660 {
return __rhs.compare(__lhs) >= 0; }
5669 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5674 {
return __lhs.compare(__rhs) >= 0; }
5682 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5685 const _CharT* __rhs)
5686 {
return __lhs.compare(__rhs) >= 0; }
5694 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5696 operator>=(
const _CharT* __lhs,
5698 {
return __rhs.compare(__lhs) <= 0; }
5707 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5711 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5712 { __lhs.swap(__rhs); }
5727 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5745 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5747 operator<<(basic_ostream<_CharT, _Traits>& __os,
5752 return __ostream_insert(__os, __str.
data(), __str.
size());
5768 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5785 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5791 #if __cplusplus >= 201103L 5793 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5800 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5812 #ifdef _GLIBCXX_USE_WCHAR_T 5819 _GLIBCXX_END_NAMESPACE_VERSION
5822 #if __cplusplus >= 201103L 5826 namespace std _GLIBCXX_VISIBILITY(default)
5828 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5829 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5831 #if _GLIBCXX_USE_C99_STDLIB 5834 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5835 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5839 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5840 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5843 inline unsigned long 5844 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5845 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5849 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5850 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5853 inline unsigned long long 5854 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5855 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5860 stof(
const string& __str,
size_t* __idx = 0)
5861 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5864 stod(
const string& __str,
size_t* __idx = 0)
5865 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5868 stold(
const string& __str,
size_t* __idx = 0)
5869 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5870 #endif // _GLIBCXX_USE_C99_STDLIB 5872 #if _GLIBCXX_USE_C99_STDIO 5877 to_string(
int __val)
5878 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5882 to_string(
unsigned __val)
5883 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5884 4 *
sizeof(unsigned),
5888 to_string(
long __val)
5889 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5893 to_string(
unsigned long __val)
5894 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5895 4 *
sizeof(
unsigned long),
5899 to_string(
long long __val)
5900 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5901 4 *
sizeof(
long long),
5905 to_string(
unsigned long long __val)
5906 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5907 4 *
sizeof(
unsigned long long),
5911 to_string(
float __val)
5914 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5915 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5920 to_string(
double __val)
5923 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5924 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5929 to_string(
long double __val)
5932 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5933 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5936 #endif // _GLIBCXX_USE_C99_STDIO 5938 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 5940 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5941 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5945 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5946 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5949 inline unsigned long 5950 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5951 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5955 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5956 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5959 inline unsigned long long 5960 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5961 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5966 stof(
const wstring& __str,
size_t* __idx = 0)
5967 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5970 stod(
const wstring& __str,
size_t* __idx = 0)
5971 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5974 stold(
const wstring& __str,
size_t* __idx = 0)
5975 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5977 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5980 to_wstring(
int __val)
5981 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5985 to_wstring(
unsigned __val)
5986 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5987 4 *
sizeof(unsigned),
5991 to_wstring(
long __val)
5992 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5996 to_wstring(
unsigned long __val)
5997 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5998 4 *
sizeof(
unsigned long),
6002 to_wstring(
long long __val)
6003 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6004 4 *
sizeof(
long long),
6008 to_wstring(
unsigned long long __val)
6009 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6010 4 *
sizeof(
unsigned long long),
6014 to_wstring(
float __val)
6017 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6018 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6023 to_wstring(
double __val)
6026 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6027 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6032 to_wstring(
long double __val)
6035 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6036 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6039 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6040 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6042 _GLIBCXX_END_NAMESPACE_CXX11
6043 _GLIBCXX_END_NAMESPACE_VERSION
6048 #if __cplusplus >= 201103L 6052 namespace std _GLIBCXX_VISIBILITY(default)
6054 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6058 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6062 :
public __hash_base<size_t, string>
6065 operator()(
const string& __s)
const noexcept
6066 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6073 #ifdef _GLIBCXX_USE_WCHAR_T 6077 :
public __hash_base<size_t, wstring>
6080 operator()(
const wstring& __s)
const noexcept
6081 {
return std::_Hash_impl::hash(__s.
data(),
6082 __s.
length() *
sizeof(wchar_t)); }
6091 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6095 :
public __hash_base<size_t, u16string>
6098 operator()(
const u16string& __s)
const noexcept
6099 {
return std::_Hash_impl::hash(__s.
data(),
6100 __s.
length() *
sizeof(char16_t)); }
6110 :
public __hash_base<size_t, u32string>
6113 operator()(
const u32string& __s)
const noexcept
6114 {
return std::_Hash_impl::hash(__s.
data(),
6115 __s.
length() *
sizeof(char32_t)); }
6123 _GLIBCXX_END_NAMESPACE_VERSION
6125 #if __cplusplus > 201103L 6127 #define __cpp_lib_string_udls 201304 6129 inline namespace literals
6131 inline namespace string_literals
6133 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6135 _GLIBCXX_DEFAULT_ABI_TAG
6137 operator""s(
const char* __str,
size_t __len)
6140 #ifdef _GLIBCXX_USE_WCHAR_T 6141 _GLIBCXX_DEFAULT_ABI_TAG
6143 operator""s(
const wchar_t* __str,
size_t __len)
6147 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6148 _GLIBCXX_DEFAULT_ABI_TAG
6150 operator""s(
const char16_t* __str,
size_t __len)
6153 _GLIBCXX_DEFAULT_ABI_TAG
6155 operator""s(
const char32_t* __str,
size_t __len)
6159 _GLIBCXX_END_NAMESPACE_VERSION
6163 #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.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
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.
Uniform interface to all pointer-like types.
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.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C 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.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
const_reference front() const noexcept
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
reverse_iterator rbegin()
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.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C 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 & 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.
const_iterator cend() const noexcept
ISO C++ entities toplevel namespace is std.
Template class basic_istream.
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.
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 find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
Basis for explicit traits specializations.
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.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
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.
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.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
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.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the 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.
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
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
~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 size() const noexcept
Returns the number of characters in the string, not including any null-termination.