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;
2267 find(
const basic_string& __str, size_type __pos = 0) const
2269 {
return this->
find(__str.data(), __pos, __str.size()); }
2271 #if __cplusplus > 201402L 2279 find(__sv_type __sv, size_type __pos = 0) const noexcept
2280 {
return this->
find(__sv.data(), __pos, __sv.size()); }
2294 find(
const _CharT* __s, size_type __pos = 0)
const 2296 __glibcxx_requires_string(__s);
2297 return this->
find(__s, __pos, traits_type::length(__s));
2311 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2324 rfind(const basic_string& __str, size_type __pos = npos) const
2326 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2328 #if __cplusplus > 201402L 2336 rfind(__sv_type __sv, size_type __pos = npos) const noexcept
2337 {
return this->
rfind(__sv.data(), __pos, __sv.size()); }
2353 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
2366 rfind(
const _CharT* __s, size_type __pos = npos)
const 2368 __glibcxx_requires_string(__s);
2369 return this->
rfind(__s, __pos, traits_type::length(__s));
2383 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2397 find_first_of(const basic_string& __str, size_type __pos = 0) const
2399 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2401 #if __cplusplus > 201402L 2409 find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
2410 {
return this->
find_first_of(__sv.data(), __pos, __sv.size()); }
2426 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2441 __glibcxx_requires_string(__s);
2442 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2458 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2459 {
return this->
find(__c, __pos); }
2473 find_last_of(
const basic_string& __str, size_type __pos = npos) const
2475 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2477 #if __cplusplus > 201402L 2485 find_last_of(__sv_type __sv, size_type __pos = npos) const noexcept
2486 {
return this->
find_last_of(__sv.data(), __pos, __sv.size()); }
2502 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
2515 find_last_of(
const _CharT* __s, size_type __pos = npos)
const 2517 __glibcxx_requires_string(__s);
2518 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2534 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
2535 {
return this->
rfind(__c, __pos); }
2552 #if __cplusplus > 201402L 2578 size_type __n)
const;
2593 __glibcxx_requires_string(__s);
2627 #if __cplusplus > 201402L 2653 size_type __n)
const;
2668 __glibcxx_requires_string(__s);
2699 substr(size_type __pos = 0, size_type __n = npos)
const 2701 _M_check(__pos,
"basic_string::substr"), __n); }
2718 compare(
const basic_string& __str)
const 2720 const size_type __size = this->
size();
2721 const size_type __osize = __str.size();
2722 const size_type __len =
std::min(__size, __osize);
2724 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2726 __r = _S_compare(__size, __osize);
2730 #if __cplusplus > 201402L 2739 const size_type __size = this->
size();
2740 const size_type __osize = __sv.size();
2741 const size_type __len =
std::min(__size, __osize);
2743 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2745 __r = _S_compare(__size, __osize);
2757 compare(size_type __pos, size_type __n, __sv_type __sv)
const 2758 {
return __sv_type(*this).substr(__pos, __n).compare(__sv); }
2769 template <
typename _Tp>
2771 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2772 size_type __pos2, size_type __n2 = npos)
const 2774 __sv_type __sv = __svt;
2775 return __sv_type(*
this)
2776 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2800 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
2826 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
2827 size_type __pos2, size_type __n2)
const;
2844 compare(
const _CharT* __s)
const;
2868 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
2895 compare(size_type __pos, size_type __n1,
const _CharT* __s,
2896 size_type __n2)
const;
2898 _GLIBCXX_END_NAMESPACE_CXX11
2899 #else // !_GLIBCXX_USE_CXX11_ABI 2964 template<
typename _CharT,
typename _Traits,
typename _Alloc>
2967 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
2971 typedef _Traits traits_type;
2972 typedef typename _Traits::char_type value_type;
2973 typedef _Alloc allocator_type;
2974 typedef typename _CharT_alloc_type::size_type size_type;
2975 typedef typename _CharT_alloc_type::difference_type difference_type;
2976 typedef typename _CharT_alloc_type::reference reference;
2977 typedef typename _CharT_alloc_type::const_reference const_reference;
2978 typedef typename _CharT_alloc_type::pointer pointer;
2979 typedef typename _CharT_alloc_type::const_pointer const_pointer;
2980 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
2981 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3003 size_type _M_length;
3004 size_type _M_capacity;
3005 _Atomic_word _M_refcount;
3008 struct _Rep : _Rep_base
3011 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3026 static const size_type _S_max_size;
3027 static const _CharT _S_terminal;
3031 static size_type _S_empty_rep_storage[];
3034 _S_empty_rep() _GLIBCXX_NOEXCEPT
3039 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3040 return *
reinterpret_cast<_Rep*
>(__p);
3044 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3046 #if defined(__GTHREADS) 3051 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3053 return this->_M_refcount < 0;
3058 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3060 #if defined(__GTHREADS) 3066 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3068 return this->_M_refcount > 0;
3073 _M_set_leaked() _GLIBCXX_NOEXCEPT
3074 { this->_M_refcount = -1; }
3077 _M_set_sharable() _GLIBCXX_NOEXCEPT
3078 { this->_M_refcount = 0; }
3081 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3083 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3084 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3087 this->_M_set_sharable();
3088 this->_M_length = __n;
3089 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3096 _M_refdata()
throw()
3097 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3100 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3102 return (!_M_is_leaked() && __alloc1 == __alloc2)
3103 ? _M_refcopy() : _M_clone(__alloc1);
3108 _S_create(size_type, size_type,
const _Alloc&);
3111 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3113 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3114 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3118 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3127 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3130 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3137 _M_destroy(
const _Alloc&)
throw();
3140 _M_refcopy()
throw()
3142 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3143 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3145 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3146 return _M_refdata();
3150 _M_clone(
const _Alloc&, size_type __res = 0);
3154 struct _Alloc_hider : _Alloc
3156 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3157 : _Alloc(__a), _M_p(__dat) { }
3167 static const size_type npos =
static_cast<size_type
>(-1);
3171 mutable _Alloc_hider _M_dataplus;
3174 _M_data() const _GLIBCXX_NOEXCEPT
3175 {
return _M_dataplus._M_p; }
3178 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3179 {
return (_M_dataplus._M_p = __p); }
3182 _M_rep()
const _GLIBCXX_NOEXCEPT
3183 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3188 _M_ibegin()
const _GLIBCXX_NOEXCEPT
3189 {
return iterator(_M_data()); }
3192 _M_iend()
const _GLIBCXX_NOEXCEPT
3193 {
return iterator(_M_data() + this->
size()); }
3198 if (!_M_rep()->_M_is_leaked())
3203 _M_check(size_type __pos,
const char* __s)
const 3205 if (__pos > this->
size())
3206 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3207 "this->size() (which is %zu)"),
3208 __s, __pos, this->
size());
3213 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3216 __throw_length_error(__N(__s));
3221 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3223 const bool __testoff = __off < this->
size() - __pos;
3224 return __testoff ? __off : this->
size() - __pos;
3229 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3238 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3241 traits_type::assign(*__d, *__s);
3243 traits_type::copy(__d, __s, __n);
3247 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3250 traits_type::assign(*__d, *__s);
3252 traits_type::move(__d, __s, __n);
3256 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3259 traits_type::assign(*__d, __c);
3261 traits_type::assign(__d, __n, __c);
3266 template<
class _Iterator>
3268 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3270 for (; __k1 != __k2; ++__k1, (void)++__p)
3271 traits_type::assign(*__p, *__k1);
3275 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3276 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3279 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3281 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3284 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3285 { _M_copy(__p, __k1, __k2 - __k1); }
3288 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3290 { _M_copy(__p, __k1, __k2 - __k1); }
3293 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3295 const difference_type __d = difference_type(__n1 - __n2);
3297 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3298 return __gnu_cxx::__numeric_traits<int>::__max;
3299 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3300 return __gnu_cxx::__numeric_traits<int>::__min;
3306 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3312 _S_empty_rep() _GLIBCXX_NOEXCEPT
3313 {
return _Rep::_S_empty_rep(); }
3324 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3325 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3327 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3351 basic_string(
const basic_string& __str, size_type __pos,
3352 const _Alloc& __a = _Alloc());
3360 basic_string(
const basic_string& __str, size_type __pos,
3369 basic_string(
const basic_string& __str, size_type __pos,
3370 size_type __n,
const _Alloc& __a);
3382 const _Alloc& __a = _Alloc());
3388 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3395 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3397 #if __cplusplus >= 201103L 3406 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3409 : _M_dataplus(__str._M_dataplus)
3411 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3412 __str._M_data(_S_empty_rep()._M_refdata());
3414 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3432 template<
class _InputIterator>
3433 basic_string(_InputIterator __beg, _InputIterator __end,
3434 const _Alloc& __a = _Alloc());
3448 {
return this->
assign(__str); }
3456 {
return this->
assign(__s); }
3472 #if __cplusplus >= 201103L 3496 this->
assign(__l.begin(), __l.size());
3510 return iterator(_M_data());
3519 {
return const_iterator(_M_data()); }
3529 return iterator(_M_data() + this->
size());
3538 {
return const_iterator(_M_data() + this->
size()); }
3547 {
return reverse_iterator(this->
end()); }
3554 const_reverse_iterator
3556 {
return const_reverse_iterator(this->
end()); }
3565 {
return reverse_iterator(this->
begin()); }
3572 const_reverse_iterator
3574 {
return const_reverse_iterator(this->
begin()); }
3576 #if __cplusplus >= 201103L 3583 {
return const_iterator(this->_M_data()); }
3591 {
return const_iterator(this->_M_data() + this->
size()); }
3598 const_reverse_iterator
3600 {
return const_reverse_iterator(this->
end()); }
3607 const_reverse_iterator
3609 {
return const_reverse_iterator(this->
begin()); }
3618 {
return _M_rep()->_M_length; }
3624 {
return _M_rep()->_M_length; }
3629 {
return _Rep::_S_max_size; }
3642 resize(size_type __n, _CharT __c);
3656 { this->
resize(__n, _CharT()); }
3658 #if __cplusplus >= 201103L 3663 #if __cpp_exceptions 3681 {
return _M_rep()->_M_capacity; }
3701 reserve(size_type __res_arg = 0);
3706 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3710 if (_M_rep()->_M_is_shared())
3713 _M_data(_S_empty_rep()._M_refdata());
3716 _M_rep()->_M_set_length_and_sharable(0);
3722 { _M_mutate(0, this->
size(), 0); }
3731 {
return this->
size() == 0; }
3747 __glibcxx_assert(__pos <=
size());
3748 return _M_data()[__pos];
3766 __glibcxx_assert(__pos <=
size());
3768 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3770 return _M_data()[__pos];
3786 if (__n >= this->
size())
3787 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3788 "(which is %zu) >= this->size() " 3791 return _M_data()[__n];
3809 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 3810 "(which is %zu) >= this->size() " 3814 return _M_data()[__n];
3817 #if __cplusplus >= 201103L 3825 __glibcxx_assert(!
empty());
3836 __glibcxx_assert(!
empty());
3847 __glibcxx_assert(!
empty());
3858 __glibcxx_assert(!
empty());
3871 {
return this->
append(__str); }
3880 {
return this->
append(__s); }
3894 #if __cplusplus >= 201103L 3902 {
return this->
append(__l.begin(), __l.size()); }
3911 append(
const basic_string& __str);
3927 append(
const basic_string& __str, size_type __pos, size_type __n);
3936 append(
const _CharT* __s, size_type __n);
3946 __glibcxx_requires_string(__s);
3947 return this->
append(__s, traits_type::length(__s));
3959 append(size_type __n, _CharT __c);
3961 #if __cplusplus >= 201103L 3969 {
return this->
append(__l.begin(), __l.size()); }
3980 template<
class _InputIterator>
3982 append(_InputIterator __first, _InputIterator __last)
3983 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
3992 const size_type __len = 1 + this->
size();
3993 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
3995 traits_type::assign(_M_data()[this->
size()], __c);
3996 _M_rep()->_M_set_length_and_sharable(__len);
4005 assign(
const basic_string& __str);
4007 #if __cplusplus >= 201103L 4039 assign(
const basic_string& __str, size_type __pos, size_type __n)
4040 {
return this->
assign(__str._M_data()
4041 + __str._M_check(__pos,
"basic_string::assign"),
4042 __str._M_limit(__pos, __n)); }
4055 assign(
const _CharT* __s, size_type __n);
4069 __glibcxx_requires_string(__s);
4070 return this->
assign(__s, traits_type::length(__s));
4084 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4094 template<
class _InputIterator>
4096 assign(_InputIterator __first, _InputIterator __last)
4097 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4099 #if __cplusplus >= 201103L 4107 {
return this->
assign(__l.begin(), __l.size()); }
4124 insert(iterator __p, size_type __n, _CharT __c)
4125 { this->
replace(__p, __p, __n, __c); }
4139 template<
class _InputIterator>
4141 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4142 { this->
replace(__p, __p, __beg, __end); }
4144 #if __cplusplus >= 201103L 4154 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4155 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4172 insert(size_type __pos1,
const basic_string& __str)
4173 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4194 insert(size_type __pos1,
const basic_string& __str,
4195 size_type __pos2, size_type __n)
4196 {
return this->
insert(__pos1, __str._M_data()
4197 + __str._M_check(__pos2,
"basic_string::insert"),
4198 __str._M_limit(__pos2, __n)); }
4217 insert(size_type __pos,
const _CharT* __s, size_type __n);
4237 __glibcxx_requires_string(__s);
4238 return this->
insert(__pos, __s, traits_type::length(__s));
4258 insert(size_type __pos, size_type __n, _CharT __c)
4259 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4260 size_type(0), __n, __c); }
4278 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4279 const size_type __pos = __p - _M_ibegin();
4280 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4281 _M_rep()->_M_set_leaked();
4282 return iterator(_M_data() + __pos);
4301 erase(size_type __pos = 0, size_type __n = npos)
4303 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4304 _M_limit(__pos, __n), size_type(0));
4319 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4320 && __position < _M_iend());
4321 const size_type __pos = __position - _M_ibegin();
4322 _M_mutate(__pos, size_type(1), size_type(0));
4323 _M_rep()->_M_set_leaked();
4324 return iterator(_M_data() + __pos);
4337 erase(iterator __first, iterator __last);
4339 #if __cplusplus >= 201103L 4348 __glibcxx_assert(!
empty());
4371 replace(size_type __pos, size_type __n,
const basic_string& __str)
4372 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4393 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
4394 size_type __pos2, size_type __n2)
4395 {
return this->
replace(__pos1, __n1, __str._M_data()
4396 + __str._M_check(__pos2,
"basic_string::replace"),
4397 __str._M_limit(__pos2, __n2)); }
4418 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4438 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4440 __glibcxx_requires_string(__s);
4441 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4462 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4463 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4464 _M_limit(__pos, __n1), __n2, __c); }
4480 replace(iterator __i1, iterator __i2,
const basic_string& __str)
4481 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4499 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4501 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4502 && __i2 <= _M_iend());
4503 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4520 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4522 __glibcxx_requires_string(__s);
4523 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4541 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4543 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4544 && __i2 <= _M_iend());
4545 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4563 template<
class _InputIterator>
4566 _InputIterator __k1, _InputIterator __k2)
4568 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4569 && __i2 <= _M_iend());
4570 __glibcxx_requires_valid_range(__k1, __k2);
4571 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4572 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4578 replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
4580 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4581 && __i2 <= _M_iend());
4582 __glibcxx_requires_valid_range(__k1, __k2);
4583 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4588 replace(iterator __i1, iterator __i2,
4589 const _CharT* __k1,
const _CharT* __k2)
4591 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4592 && __i2 <= _M_iend());
4593 __glibcxx_requires_valid_range(__k1, __k2);
4594 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4599 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4601 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4602 && __i2 <= _M_iend());
4603 __glibcxx_requires_valid_range(__k1, __k2);
4604 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4605 __k1.base(), __k2 - __k1);
4609 replace(iterator __i1, iterator __i2,
4610 const_iterator __k1, const_iterator __k2)
4612 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4613 && __i2 <= _M_iend());
4614 __glibcxx_requires_valid_range(__k1, __k2);
4615 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4616 __k1.base(), __k2 - __k1);
4619 #if __cplusplus >= 201103L 4634 basic_string&
replace(iterator __i1, iterator __i2,
4636 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4640 template<
class _Integer>
4642 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
4643 _Integer __val, __true_type)
4644 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
4646 template<
class _InputIterator>
4648 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
4649 _InputIterator __k2, __false_type);
4652 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
4656 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
4661 template<
class _InIterator>
4663 _S_construct_aux(_InIterator __beg, _InIterator __end,
4664 const _Alloc& __a, __false_type)
4666 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
4667 return _S_construct(__beg, __end, __a, _Tag());
4672 template<
class _Integer>
4674 _S_construct_aux(_Integer __beg, _Integer __end,
4675 const _Alloc& __a, __true_type)
4676 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
4680 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
4681 {
return _S_construct(__req, __c, __a); }
4683 template<
class _InIterator>
4685 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
4687 typedef typename std::__is_integer<_InIterator>::__type _Integral;
4688 return _S_construct_aux(__beg, __end, __a, _Integral());
4692 template<
class _InIterator>
4694 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
4699 template<
class _FwdIterator>
4701 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
4705 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
4722 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
4733 swap(basic_string& __s);
4744 {
return _M_data(); }
4756 {
return _M_data(); }
4758 #if __cplusplus > 201402L 4767 {
return _M_data(); }
4775 {
return _M_dataplus; }
4790 find(
const _CharT* __s, size_type __pos, size_type __n)
const;
4803 find(
const basic_string& __str, size_type __pos = 0) const
4805 {
return this->
find(__str.data(), __pos, __str.size()); }
4818 find(
const _CharT* __s, size_type __pos = 0)
const 4820 __glibcxx_requires_string(__s);
4821 return this->
find(__s, __pos, traits_type::length(__s));
4835 find(_CharT __c, size_type __pos = 0)
const _GLIBCXX_NOEXCEPT;
4848 rfind(
const basic_string& __str, size_type __pos = npos) const
4850 {
return this->
rfind(__str.data(), __pos, __str.size()); }
4865 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const;
4878 rfind(
const _CharT* __s, size_type __pos = npos)
const 4880 __glibcxx_requires_string(__s);
4881 return this->
rfind(__s, __pos, traits_type::length(__s));
4895 rfind(_CharT __c, size_type __pos = npos)
const _GLIBCXX_NOEXCEPT;
4911 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
4926 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
4941 __glibcxx_requires_string(__s);
4942 return this->
find_first_of(__s, __pos, traits_type::length(__s));
4959 {
return this->
find(__c, __pos); }
4975 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
4990 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const;
5005 __glibcxx_requires_string(__s);
5006 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5023 {
return this->
rfind(__c, __pos); }
5054 size_type __n)
const;
5069 __glibcxx_requires_string(__s);
5117 size_type __n)
const;
5132 __glibcxx_requires_string(__s);
5163 substr(size_type __pos = 0, size_type __n = npos)
const 5165 _M_check(__pos,
"basic_string::substr"), __n); }
5184 const size_type __size = this->
size();
5185 const size_type __osize = __str.size();
5186 const size_type __len =
std::min(__size, __osize);
5188 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5190 __r = _S_compare(__size, __osize);
5214 compare(size_type __pos, size_type __n,
const basic_string& __str)
const;
5240 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
5241 size_type __pos2, size_type __n2)
const;
5258 compare(
const _CharT* __s)
const;
5282 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5309 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5310 size_type __n2)
const;
5312 # ifdef _GLIBCXX_TM_TS_INTERNAL 5314 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5317 ::_txnal_cow_string_c_str(
const void *that);
5319 ::_txnal_cow_string_D1(
void *that);
5321 ::_txnal_cow_string_D1_commit(
void *that);
5324 #endif // !_GLIBCXX_USE_CXX11_ABI 5333 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5339 __str.append(__rhs);
5349 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5360 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5370 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5373 const _CharT* __rhs)
5376 __str.append(__rhs);
5386 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5391 typedef typename __string_type::size_type __size_type;
5392 __string_type __str(__lhs);
5393 __str.append(__size_type(1), __rhs);
5397 #if __cplusplus >= 201103L 5398 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5402 {
return std::move(__lhs.append(__rhs)); }
5404 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5408 {
return std::move(__rhs.insert(0, __lhs)); }
5410 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5415 const auto __size = __lhs.size() + __rhs.size();
5416 const bool __cond = (__size > __lhs.capacity()
5417 && __size <= __rhs.capacity());
5418 return __cond ? std::move(__rhs.insert(0, __lhs))
5419 : std::move(__lhs.append(__rhs));
5422 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5426 {
return std::move(__rhs.insert(0, __lhs)); }
5428 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5432 {
return std::move(__rhs.insert(0, 1, __lhs)); }
5434 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5437 const _CharT* __rhs)
5438 {
return std::move(__lhs.append(__rhs)); }
5440 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5444 {
return std::move(__lhs.append(1, __rhs)); }
5454 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5459 {
return __lhs.compare(__rhs) == 0; }
5461 template<
typename _CharT>
5463 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
5466 {
return (__lhs.
size() == __rhs.
size()
5476 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5478 operator==(
const _CharT* __lhs,
5480 {
return __rhs.compare(__lhs) == 0; }
5488 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5491 const _CharT* __rhs)
5492 {
return __lhs.compare(__rhs) == 0; }
5501 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5506 {
return !(__lhs == __rhs); }
5514 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5516 operator!=(
const _CharT* __lhs,
5518 {
return !(__lhs == __rhs); }
5526 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5529 const _CharT* __rhs)
5530 {
return !(__lhs == __rhs); }
5539 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5541 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5544 {
return __lhs.
compare(__rhs) < 0; }
5552 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5554 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5555 const _CharT* __rhs)
5556 {
return __lhs.
compare(__rhs) < 0; }
5564 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5566 operator<(
const _CharT* __lhs,
5568 {
return __rhs.compare(__lhs) > 0; }
5577 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5582 {
return __lhs.compare(__rhs) > 0; }
5590 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5593 const _CharT* __rhs)
5594 {
return __lhs.compare(__rhs) > 0; }
5602 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5604 operator>(
const _CharT* __lhs,
5606 {
return __rhs.compare(__lhs) < 0; }
5615 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5617 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5620 {
return __lhs.
compare(__rhs) <= 0; }
5628 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5630 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5631 const _CharT* __rhs)
5632 {
return __lhs.
compare(__rhs) <= 0; }
5640 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5642 operator<=(
const _CharT* __lhs,
5644 {
return __rhs.compare(__lhs) >= 0; }
5653 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5658 {
return __lhs.compare(__rhs) >= 0; }
5666 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5669 const _CharT* __rhs)
5670 {
return __lhs.compare(__rhs) >= 0; }
5678 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5680 operator>=(
const _CharT* __lhs,
5682 {
return __rhs.compare(__lhs) <= 0; }
5691 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5695 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
5696 { __lhs.swap(__rhs); }
5711 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5729 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5731 operator<<(basic_ostream<_CharT, _Traits>& __os,
5736 return __ostream_insert(__os, __str.
data(), __str.
size());
5752 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5769 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5775 #if __cplusplus >= 201103L 5777 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5784 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5796 #ifdef _GLIBCXX_USE_WCHAR_T 5803 _GLIBCXX_END_NAMESPACE_VERSION
5806 #if __cplusplus >= 201103L 5810 namespace std _GLIBCXX_VISIBILITY(default)
5812 _GLIBCXX_BEGIN_NAMESPACE_VERSION
5813 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5815 #if _GLIBCXX_USE_C99_STDLIB 5818 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5819 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.
c_str(),
5823 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5824 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.
c_str(),
5827 inline unsigned long 5828 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5829 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.
c_str(),
5833 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5834 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.
c_str(),
5837 inline unsigned long long 5838 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
5839 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.
c_str(),
5844 stof(
const string& __str,
size_t* __idx = 0)
5845 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.
c_str(), __idx); }
5848 stod(
const string& __str,
size_t* __idx = 0)
5849 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.
c_str(), __idx); }
5852 stold(
const string& __str,
size_t* __idx = 0)
5853 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.
c_str(), __idx); }
5854 #endif // _GLIBCXX_USE_C99_STDLIB 5856 #if _GLIBCXX_USE_C99_STDIO 5861 to_string(
int __val)
5862 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
5866 to_string(
unsigned __val)
5867 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5868 4 *
sizeof(unsigned),
5872 to_string(
long __val)
5873 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
5877 to_string(
unsigned long __val)
5878 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5879 4 *
sizeof(
unsigned long),
5883 to_string(
long long __val)
5884 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5885 4 *
sizeof(
long long),
5889 to_string(
unsigned long long __val)
5890 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
5891 4 *
sizeof(
unsigned long long),
5895 to_string(
float __val)
5898 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
5899 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5904 to_string(
double __val)
5907 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
5908 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5913 to_string(
long double __val)
5916 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
5917 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
5920 #endif // _GLIBCXX_USE_C99_STDIO 5922 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 5924 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5925 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.
c_str(),
5929 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5930 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.
c_str(),
5933 inline unsigned long 5934 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5935 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.
c_str(),
5939 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5940 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.
c_str(),
5943 inline unsigned long long 5944 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
5945 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.
c_str(),
5950 stof(
const wstring& __str,
size_t* __idx = 0)
5951 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.
c_str(), __idx); }
5954 stod(
const wstring& __str,
size_t* __idx = 0)
5955 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.
c_str(), __idx); }
5958 stold(
const wstring& __str,
size_t* __idx = 0)
5959 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.
c_str(), __idx); }
5961 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 5964 to_wstring(
int __val)
5965 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
5969 to_wstring(
unsigned __val)
5970 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5971 4 *
sizeof(unsigned),
5975 to_wstring(
long __val)
5976 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
5980 to_wstring(
unsigned long __val)
5981 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5982 4 *
sizeof(
unsigned long),
5986 to_wstring(
long long __val)
5987 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5988 4 *
sizeof(
long long),
5992 to_wstring(
unsigned long long __val)
5993 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
5994 4 *
sizeof(
unsigned long long),
5998 to_wstring(
float __val)
6001 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6002 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6007 to_wstring(
double __val)
6010 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6011 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6016 to_wstring(
long double __val)
6019 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6020 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6023 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6024 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6026 _GLIBCXX_END_NAMESPACE_CXX11
6027 _GLIBCXX_END_NAMESPACE_VERSION
6032 #if __cplusplus >= 201103L 6036 namespace std _GLIBCXX_VISIBILITY(default)
6038 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6042 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6046 :
public __hash_base<size_t, string>
6049 operator()(
const string& __s)
const noexcept
6050 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6057 #ifdef _GLIBCXX_USE_WCHAR_T 6061 :
public __hash_base<size_t, wstring>
6064 operator()(
const wstring& __s)
const noexcept
6065 {
return std::_Hash_impl::hash(__s.
data(),
6066 __s.
length() *
sizeof(wchar_t)); }
6075 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6079 :
public __hash_base<size_t, u16string>
6082 operator()(
const u16string& __s)
const noexcept
6083 {
return std::_Hash_impl::hash(__s.
data(),
6084 __s.
length() *
sizeof(char16_t)); }
6094 :
public __hash_base<size_t, u32string>
6097 operator()(
const u32string& __s)
const noexcept
6098 {
return std::_Hash_impl::hash(__s.
data(),
6099 __s.
length() *
sizeof(char32_t)); }
6107 _GLIBCXX_END_NAMESPACE_VERSION
6109 #if __cplusplus > 201103L 6111 #define __cpp_lib_string_udls 201304 6113 inline namespace literals
6115 inline namespace string_literals
6117 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6119 _GLIBCXX_DEFAULT_ABI_TAG
6121 operator""s(
const char* __str,
size_t __len)
6124 #ifdef _GLIBCXX_USE_WCHAR_T 6125 _GLIBCXX_DEFAULT_ABI_TAG
6127 operator""s(
const wchar_t* __str,
size_t __len)
6131 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6132 _GLIBCXX_DEFAULT_ABI_TAG
6134 operator""s(
const char16_t* __str,
size_t __len)
6137 _GLIBCXX_DEFAULT_ABI_TAG
6139 operator""s(
const char32_t* __str,
size_t __len)
6143 _GLIBCXX_END_NAMESPACE_VERSION
6147 #endif // __cplusplus > 201103L size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Find last position of a character not in C string.
const _CharT * data() const noexcept
Return const pointer to contents.
Primary class template hash.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & append(const basic_string &__str)
Append a string to this string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Find position of a character not in C string.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
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
Find last position of a character of C string.
char_type widen(char __c) const
Widens characters.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
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.
Managing sequences of characters and character-like objects.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
const_reverse_iterator crend() const noexcept
Uniform interface to C++98 and C++11 allocators.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
ISO C++ entities toplevel namespace is std.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void swap(basic_string &__s)
Swap contents with another string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find(const _CharT *__s, size_type __pos=0) const
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Find position of a character of C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
Template class basic_ostream.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n)
Set value to a substring of a string.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
Basis for explicit traits specializations.
reverse_iterator rbegin()
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
Uniform interface to all pointer-like types.
size_type capacity() const noexcept
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the 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.
int compare(const basic_string &__str) const
Compare to a string.
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_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
iterator insert(iterator __p, _CharT __c)
Insert one character.
reference at(size_type __n)
Provides access to the data contained in the string.
const_iterator cend() const noexcept
basic_string & operator=(_CharT __c)
Set value to string of length 1.
bool empty() const noexcept
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
const_reverse_iterator rend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
~basic_string() noexcept
Destroy the string instance.
const_iterator begin() const noexcept
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
const_iterator end() const noexcept
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
iterator erase(iterator __position)
Remove one character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
void pop_back()
Remove the last character.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string()
Default constructor creates an empty string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
void resize(size_type __n)
Resizes the string to the specified number of characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
One of the comparison functors.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Forward iterators support a superset of input iterator operations.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n)
Insert a substring.
const_iterator cbegin() const noexcept
static const size_type npos
Value returned by various member functions when they fail.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
void push_back(_CharT __c)
Append a single character.
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
const_reverse_iterator crbegin() const noexcept
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
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.
const_reference back() const noexcept
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
Template class basic_istream.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
size_type rfind(const _CharT *__s, size_type __pos=npos) const
Find last position of a C string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference front() const noexcept