39 #ifndef _BASIC_STRING_TCC
40 #define _BASIC_STRING_TCC 1
42 #pragma GCC system_header
46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 #if _GLIBCXX_USE_CXX11_ABI
52 template<
typename _CharT,
typename _Traits,
typename _Alloc>
53 const typename basic_string<_CharT, _Traits, _Alloc>::size_type
56 template<
typename _CharT,
typename _Traits,
typename _Alloc>
60 swap(basic_string& __s) _GLIBCXX_NOEXCEPT
65 _Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator());
68 if (__s._M_is_local())
70 if (length() && __s.length())
72 _CharT __tmp_data[_S_local_capacity + 1];
73 traits_type::copy(__tmp_data, __s._M_local_buf,
75 traits_type::copy(__s._M_local_buf, _M_local_buf,
77 traits_type::copy(_M_local_buf, __tmp_data,
80 else if (__s.length())
82 traits_type::copy(_M_local_buf, __s._M_local_buf,
84 _M_length(__s.length());
90 traits_type::copy(__s._M_local_buf, _M_local_buf,
92 __s._M_length(length());
99 const size_type __tmp_capacity = __s._M_allocated_capacity;
100 traits_type::copy(__s._M_local_buf, _M_local_buf,
102 _M_data(__s._M_data());
103 __s._M_data(__s._M_local_buf);
104 _M_capacity(__tmp_capacity);
108 const size_type __tmp_capacity = _M_allocated_capacity;
109 if (__s._M_is_local())
111 traits_type::copy(_M_local_buf, __s._M_local_buf,
113 __s._M_data(_M_data());
114 _M_data(_M_local_buf);
118 pointer __tmp_ptr = _M_data();
119 _M_data(__s._M_data());
120 __s._M_data(__tmp_ptr);
121 _M_capacity(__s._M_allocated_capacity);
123 __s._M_capacity(__tmp_capacity);
126 const size_type __tmp_length = length();
127 _M_length(__s.length());
128 __s._M_length(__tmp_length);
131 template<
typename _CharT,
typename _Traits,
typename _Alloc>
133 typename basic_string<_CharT, _Traits, _Alloc>::pointer
134 basic_string<_CharT, _Traits, _Alloc>::
135 _M_create(size_type& __capacity, size_type __old_capacity)
139 if (__capacity > max_size())
140 std::__throw_length_error(__N(
"basic_string::_M_create"));
145 if (__capacity > __old_capacity && __capacity < 2 * __old_capacity)
147 __capacity = 2 * __old_capacity;
149 if (__capacity > max_size())
150 __capacity = max_size();
155 return _Alloc_traits::allocate(_M_get_allocator(), __capacity + 1);
162 template<
typename _CharT,
typename _Traits,
typename _Alloc>
163 template<
typename _InIterator>
166 basic_string<_CharT, _Traits, _Alloc>::
167 _M_construct(_InIterator __beg, _InIterator __end,
171 size_type __capacity = size_type(_S_local_capacity);
173 pointer __p = _M_use_local_data();
175 while (__beg != __end && __len < __capacity)
177 __p[__len++] = *__beg;
184 explicit _Guard(basic_string* __s) : _M_guarded(__s) { }
187 ~_Guard() {
if (_M_guarded) _M_guarded->_M_dispose(); }
189 basic_string* _M_guarded;
192 while (__beg != __end)
194 if (__len == __capacity)
197 __capacity = __len + 1;
198 pointer __another = _M_create(__capacity, __len);
199 this->_S_copy(__another, _M_data(), __len);
202 _M_capacity(__capacity);
204 traits_type::assign(_M_data()[__len++], *__beg);
208 __guard._M_guarded = 0;
210 _M_set_length(__len);
213 template<
typename _CharT,
typename _Traits,
typename _Alloc>
214 template<
typename _InIterator>
217 basic_string<_CharT, _Traits, _Alloc>::
218 _M_construct(_InIterator __beg, _InIterator __end,
221 size_type __dnew =
static_cast<size_type
>(
std::distance(__beg, __end));
223 if (__dnew > size_type(_S_local_capacity))
225 _M_data(_M_create(__dnew, size_type(0)));
235 explicit _Guard(basic_string* __s) : _M_guarded(__s) { }
238 ~_Guard() {
if (_M_guarded) _M_guarded->_M_dispose(); }
240 basic_string* _M_guarded;
243 this->_S_copy_chars(_M_data(), __beg, __end);
245 __guard._M_guarded = 0;
247 _M_set_length(__dnew);
250 template<
typename _CharT,
typename _Traits,
typename _Alloc>
253 basic_string<_CharT, _Traits, _Alloc>::
254 _M_construct(size_type __n, _CharT __c)
256 if (__n > size_type(_S_local_capacity))
258 _M_data(_M_create(__n, size_type(0)));
265 this->_S_assign(_M_data(), __n, __c);
270 template<
typename _CharT,
typename _Traits,
typename _Alloc>
273 basic_string<_CharT, _Traits, _Alloc>::
274 _M_assign(
const basic_string& __str)
278 const size_type __rsize = __str.length();
279 const size_type __capacity = capacity();
281 if (__rsize > __capacity)
283 size_type __new_capacity = __rsize;
284 pointer __tmp = _M_create(__new_capacity, __capacity);
287 _M_capacity(__new_capacity);
291 this->_S_copy(_M_data(), __str._M_data(), __rsize);
293 _M_set_length(__rsize);
297 template<
typename _CharT,
typename _Traits,
typename _Alloc>
303 const size_type __capacity = capacity();
308 if (__res <= __capacity)
311 pointer __tmp = _M_create(__res, __capacity);
312 this->_S_copy(__tmp, _M_data(), length() + 1);
318 template<
typename _CharT,
typename _Traits,
typename _Alloc>
321 basic_string<_CharT, _Traits, _Alloc>::
322 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
325 const size_type __how_much = length() - __pos - __len1;
327 size_type __new_capacity = length() + __len2 - __len1;
328 pointer __r = _M_create(__new_capacity, capacity());
331 this->_S_copy(__r, _M_data(), __pos);
333 this->_S_copy(__r + __pos, __s, __len2);
335 this->_S_copy(__r + __pos + __len2,
336 _M_data() + __pos + __len1, __how_much);
340 _M_capacity(__new_capacity);
343 template<
typename _CharT,
typename _Traits,
typename _Alloc>
346 basic_string<_CharT, _Traits, _Alloc>::
347 _M_erase(size_type __pos, size_type __n)
349 const size_type __how_much = length() - __pos - __n;
351 if (__how_much && __n)
352 this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
354 _M_set_length(length() - __n);
357 template<
typename _CharT,
typename _Traits,
typename _Alloc>
366 const size_type __length = length();
367 const size_type __capacity = _M_allocated_capacity;
369 if (__length <= size_type(_S_local_capacity))
371 this->_S_copy(_M_use_local_data(), _M_data(), __length + 1);
372 _M_destroy(__capacity);
373 _M_data(_M_local_data());
376 else if (__length < __capacity)
380 = _Alloc_traits::allocate(_M_get_allocator(), __length + 1);
381 this->_S_copy(__tmp, _M_data(), __length + 1);
384 _M_capacity(__length);
393 template<
typename _CharT,
typename _Traits,
typename _Alloc>
397 resize(size_type __n, _CharT __c)
399 const size_type __size = this->
size();
401 this->append(__n - __size, __c);
402 else if (__n < __size)
403 this->_M_set_length(__n);
406 template<
typename _CharT,
typename _Traits,
typename _Alloc>
408 basic_string<_CharT, _Traits, _Alloc>&
409 basic_string<_CharT, _Traits, _Alloc>::
410 _M_append(
const _CharT* __s, size_type __n)
412 const size_type __len = __n + this->
size();
414 if (__len <= this->capacity())
417 this->_S_copy(this->_M_data() + this->
size(), __s, __n);
420 this->_M_mutate(this->
size(), size_type(0), __s, __n);
422 this->_M_set_length(__len);
426 template<
typename _CharT,
typename _Traits,
typename _Alloc>
427 template<
typename _InputIterator>
429 basic_string<_CharT, _Traits, _Alloc>&
430 basic_string<_CharT, _Traits, _Alloc>::
431 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
432 _InputIterator __k1, _InputIterator __k2,
437 const basic_string __s(__k1, __k2, this->get_allocator());
438 const size_type __n1 = __i2 - __i1;
439 return _M_replace(__i1 -
begin(), __n1, __s._M_data(),
443 template<
typename _CharT,
typename _Traits,
typename _Alloc>
445 basic_string<_CharT, _Traits, _Alloc>&
446 basic_string<_CharT, _Traits, _Alloc>::
447 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
450 _M_check_length(__n1, __n2,
"basic_string::_M_replace_aux");
452 const size_type __old_size = this->
size();
453 const size_type __new_size = __old_size + __n2 - __n1;
455 if (__new_size <= this->capacity())
457 pointer __p = this->_M_data() + __pos1;
459 const size_type __how_much = __old_size - __pos1 - __n1;
460 if (__how_much && __n1 != __n2)
461 this->_S_move(__p + __n2, __p + __n1, __how_much);
464 this->_M_mutate(__pos1, __n1, 0, __n2);
467 this->_S_assign(this->_M_data() + __pos1, __n2, __c);
469 this->_M_set_length(__new_size);
473 template<
typename _CharT,
typename _Traits,
typename _Alloc>
475 basic_string<_CharT, _Traits, _Alloc>&
476 basic_string<_CharT, _Traits, _Alloc>::
477 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
478 const size_type __len2)
480 _M_check_length(__len1, __len2,
"basic_string::_M_replace");
482 const size_type __old_size = this->
size();
483 const size_type __new_size = __old_size + __len2 - __len1;
485 if (__new_size <= this->capacity())
487 pointer __p = this->_M_data() + __pos;
489 const size_type __how_much = __old_size - __pos - __len1;
490 #if __cpp_lib_is_constant_evaluated
493 auto __newp = _Alloc_traits::allocate(_M_get_allocator(),
495 _S_copy(__newp, this->_M_data(), __pos);
496 _S_copy(__newp + __pos, __s, __len2);
497 _S_copy(__newp + __pos + __len2, __p + __len1, __how_much);
498 _S_copy(this->_M_data(), __newp, __new_size);
499 this->_M_get_allocator().deallocate(__newp, __new_size);
503 if (_M_disjunct(__s))
505 if (__how_much && __len1 != __len2)
506 this->_S_move(__p + __len2, __p + __len1, __how_much);
508 this->_S_copy(__p, __s, __len2);
513 if (__len2 && __len2 <= __len1)
514 this->_S_move(__p, __s, __len2);
515 if (__how_much && __len1 != __len2)
516 this->_S_move(__p + __len2, __p + __len1, __how_much);
519 if (__s + __len2 <= __p + __len1)
520 this->_S_move(__p, __s, __len2);
521 else if (__s >= __p + __len1)
525 const size_type __poff = (__s - __p) + (__len2 - __len1);
526 this->_S_copy(__p, __p + __poff, __len2);
530 const size_type __nleft = (__p + __len1) - __s;
531 this->_S_move(__p, __s, __nleft);
534 if (__len2 < __nleft)
535 __builtin_unreachable();
536 this->_S_copy(__p + __nleft, __p + __len2,
543 this->_M_mutate(__pos, __len1, __s, __len2);
545 this->_M_set_length(__new_size);
549 template<
typename _CharT,
typename _Traits,
typename _Alloc>
551 typename basic_string<_CharT, _Traits, _Alloc>::size_type
553 copy(_CharT* __s, size_type __n, size_type __pos)
const
555 _M_check(__pos,
"basic_string::copy");
556 __n = _M_limit(__pos, __n);
557 __glibcxx_requires_string_len(__s, __n);
559 _S_copy(__s, _M_data() + __pos, __n);
564 #if __cplusplus > 202002L
565 template<
typename _CharT,
typename _Traits,
typename _Alloc>
566 template<
typename _Operation>
568 basic_string<_CharT, _Traits, _Alloc>::
569 resize_and_overwrite(size_type __n, _Operation __op)
571 const size_type __capacity = capacity();
573 if (__n > __capacity)
575 __p = _M_create(__n, __capacity);
576 this->_S_copy(__p, _M_data(), length());
577 #if __cpp_lib_is_constant_evaluated
579 traits_type::assign(__p + length(), __n - length(), _CharT());
588 constexpr ~_Terminator() { _M_this->_M_set_length(_M_r); }
589 basic_string* _M_this;
592 _Terminator __term{
this};
593 const size_type __n2 [[maybe_unused]] = __n;
595 _GLIBCXX_DEBUG_ASSERT(__term._M_r >= 0 && __term._M_r <= __n2);
601 #if __cpp_lib_constexpr_string >= 201907L
602 # define _GLIBCXX_STRING_CONSTEXPR constexpr
604 # define _GLIBCXX_STRING_CONSTEXPR
607 template<
typename _CharT,
typename _Traits,
typename _Alloc>
609 basic_string<_CharT, _Traits, _Alloc>
613 __glibcxx_requires_string(__lhs);
615 typedef typename __string_type::size_type __size_type;
617 rebind<_CharT>::other _Char_alloc_type;
619 const __size_type __len = _Traits::length(__lhs);
620 __string_type __str(_Alloc_traits::_S_select_on_copy(
622 __str.reserve(__len + __rhs.
size());
623 __str.append(__lhs, __len);
628 template<
typename _CharT,
typename _Traits,
typename _Alloc>
630 basic_string<_CharT, _Traits, _Alloc>
634 typedef typename __string_type::size_type __size_type;
636 rebind<_CharT>::other _Char_alloc_type;
638 __string_type __str(_Alloc_traits::_S_select_on_copy(
640 const __size_type __len = __rhs.
size();
641 __str.reserve(__len + 1);
642 __str.append(__size_type(1), __lhs);
647 template<
typename _CharT,
typename _Traits,
typename _Alloc>
648 _GLIBCXX_STRING_CONSTEXPR
649 typename basic_string<_CharT, _Traits, _Alloc>::size_type
651 find(
const _CharT* __s, size_type __pos, size_type __n)
const
654 __glibcxx_requires_string_len(__s, __n);
655 const size_type __size = this->
size();
658 return __pos <= __size ? __pos : npos;
662 const _CharT __elem0 = __s[0];
663 const _CharT*
const __data =
data();
664 const _CharT* __first = __data + __pos;
665 const _CharT*
const __last = __data + __size;
666 size_type __len = __size - __pos;
671 __first = traits_type::find(__first, __len - __n + 1, __elem0);
677 if (traits_type::compare(__first, __s, __n) == 0)
678 return __first - __data;
679 __len = __last - ++__first;
684 template<
typename _CharT,
typename _Traits,
typename _Alloc>
685 _GLIBCXX_STRING_CONSTEXPR
686 typename basic_string<_CharT, _Traits, _Alloc>::size_type
688 find(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
690 size_type __ret = npos;
691 const size_type __size = this->
size();
694 const _CharT* __data = _M_data();
695 const size_type __n = __size - __pos;
696 const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
698 __ret = __p - __data;
703 template<
typename _CharT,
typename _Traits,
typename _Alloc>
704 _GLIBCXX_STRING_CONSTEXPR
705 typename basic_string<_CharT, _Traits, _Alloc>::size_type
707 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
710 __glibcxx_requires_string_len(__s, __n);
711 const size_type __size = this->
size();
714 __pos =
std::min(size_type(__size - __n), __pos);
715 const _CharT* __data = _M_data();
718 if (traits_type::compare(__data + __pos, __s, __n) == 0)
726 template<
typename _CharT,
typename _Traits,
typename _Alloc>
727 _GLIBCXX_STRING_CONSTEXPR
728 typename basic_string<_CharT, _Traits, _Alloc>::size_type
730 rfind(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
732 size_type __size = this->
size();
735 if (--__size > __pos)
737 for (++__size; __size-- > 0; )
738 if (traits_type::eq(_M_data()[__size], __c))
744 template<
typename _CharT,
typename _Traits,
typename _Alloc>
745 _GLIBCXX_STRING_CONSTEXPR
746 typename basic_string<_CharT, _Traits, _Alloc>::size_type
748 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
751 __glibcxx_requires_string_len(__s, __n);
752 for (; __n && __pos < this->
size(); ++__pos)
754 const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
761 template<
typename _CharT,
typename _Traits,
typename _Alloc>
762 _GLIBCXX_STRING_CONSTEXPR
763 typename basic_string<_CharT, _Traits, _Alloc>::size_type
765 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
768 __glibcxx_requires_string_len(__s, __n);
769 size_type __size = this->
size();
772 if (--__size > __pos)
776 if (traits_type::find(__s, __n, _M_data()[__size]))
779 while (__size-- != 0);
784 template<
typename _CharT,
typename _Traits,
typename _Alloc>
785 _GLIBCXX_STRING_CONSTEXPR
786 typename basic_string<_CharT, _Traits, _Alloc>::size_type
791 __glibcxx_requires_string_len(__s, __n);
792 for (; __pos < this->
size(); ++__pos)
793 if (!traits_type::find(__s, __n, _M_data()[__pos]))
798 template<
typename _CharT,
typename _Traits,
typename _Alloc>
799 _GLIBCXX_STRING_CONSTEXPR
800 typename basic_string<_CharT, _Traits, _Alloc>::size_type
804 for (; __pos < this->
size(); ++__pos)
805 if (!traits_type::eq(_M_data()[__pos], __c))
810 template<
typename _CharT,
typename _Traits,
typename _Alloc>
811 _GLIBCXX_STRING_CONSTEXPR
812 typename basic_string<_CharT, _Traits, _Alloc>::size_type
817 __glibcxx_requires_string_len(__s, __n);
818 size_type __size = this->
size();
821 if (--__size > __pos)
825 if (!traits_type::find(__s, __n, _M_data()[__size]))
833 template<
typename _CharT,
typename _Traits,
typename _Alloc>
834 _GLIBCXX_STRING_CONSTEXPR
835 typename basic_string<_CharT, _Traits, _Alloc>::size_type
839 size_type __size = this->
size();
842 if (--__size > __pos)
846 if (!traits_type::eq(_M_data()[__size], __c))
854 template<
typename _CharT,
typename _Traits,
typename _Alloc>
855 _GLIBCXX_STRING_CONSTEXPR
860 _M_check(__pos,
"basic_string::compare");
861 __n = _M_limit(__pos, __n);
862 const size_type __osize = __str.
size();
863 const size_type __len =
std::min(__n, __osize);
864 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
866 __r = _S_compare(__n, __osize);
870 template<
typename _CharT,
typename _Traits,
typename _Alloc>
871 _GLIBCXX_STRING_CONSTEXPR
875 size_type __pos2, size_type __n2)
const
877 _M_check(__pos1,
"basic_string::compare");
878 __str._M_check(__pos2,
"basic_string::compare");
879 __n1 = _M_limit(__pos1, __n1);
880 __n2 = __str._M_limit(__pos2, __n2);
881 const size_type __len =
std::min(__n1, __n2);
882 int __r = traits_type::compare(_M_data() + __pos1,
883 __str.
data() + __pos2, __len);
885 __r = _S_compare(__n1, __n2);
889 template<
typename _CharT,
typename _Traits,
typename _Alloc>
890 _GLIBCXX_STRING_CONSTEXPR
893 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
895 __glibcxx_requires_string(__s);
896 const size_type __size = this->
size();
897 const size_type __osize = traits_type::length(__s);
898 const size_type __len =
std::min(__size, __osize);
899 int __r = traits_type::compare(_M_data(), __s, __len);
901 __r = _S_compare(__size, __osize);
905 template<
typename _CharT,
typename _Traits,
typename _Alloc>
906 _GLIBCXX_STRING_CONSTEXPR
909 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
911 __glibcxx_requires_string(__s);
912 _M_check(__pos,
"basic_string::compare");
913 __n1 = _M_limit(__pos, __n1);
914 const size_type __osize = traits_type::length(__s);
915 const size_type __len =
std::min(__n1, __osize);
916 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
918 __r = _S_compare(__n1, __osize);
922 template<
typename _CharT,
typename _Traits,
typename _Alloc>
923 _GLIBCXX_STRING_CONSTEXPR
926 compare(size_type __pos, size_type __n1,
const _CharT* __s,
927 size_type __n2)
const
929 __glibcxx_requires_string_len(__s, __n2);
930 _M_check(__pos,
"basic_string::compare");
931 __n1 = _M_limit(__pos, __n1);
932 const size_type __len =
std::min(__n1, __n2);
933 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
935 __r = _S_compare(__n1, __n2);
939 #undef _GLIBCXX_STRING_CONSTEXPR
942 template<
typename _CharT,
typename _Traits,
typename _Alloc>
949 typedef typename __istream_type::ios_base __ios_base;
950 typedef typename __istream_type::int_type __int_type;
951 typedef typename __string_type::size_type __size_type;
953 typedef typename __ctype_type::ctype_base __ctype_base;
955 __size_type __extracted = 0;
956 typename __ios_base::iostate __err = __ios_base::goodbit;
957 typename __istream_type::sentry __cerb(__in,
false);
965 __size_type __len = 0;
967 const __size_type __n = __w > 0 ?
static_cast<__size_type
>(__w)
969 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
970 const __int_type __eof = _Traits::eof();
971 __int_type __c = __in.
rdbuf()->sgetc();
973 while (__extracted < __n
974 && !_Traits::eq_int_type(__c, __eof)
975 && !__ct.is(__ctype_base::space,
976 _Traits::to_char_type(__c)))
978 if (__len ==
sizeof(__buf) /
sizeof(_CharT))
980 __str.
append(__buf,
sizeof(__buf) /
sizeof(_CharT));
983 __buf[__len++] = _Traits::to_char_type(__c);
985 __c = __in.
rdbuf()->snextc();
987 __str.
append(__buf, __len);
989 if (__extracted < __n && _Traits::eq_int_type(__c, __eof))
990 __err |= __ios_base::eofbit;
995 __in._M_setstate(__ios_base::badbit);
996 __throw_exception_again;
1003 __in._M_setstate(__ios_base::badbit);
1008 __err |= __ios_base::failbit;
1014 template<
typename _CharT,
typename _Traits,
typename _Alloc>
1015 basic_istream<_CharT, _Traits>&
1021 typedef typename __istream_type::ios_base __ios_base;
1022 typedef typename __istream_type::int_type __int_type;
1023 typedef typename __string_type::size_type __size_type;
1025 __size_type __extracted = 0;
1026 const __size_type __n = __str.
max_size();
1027 typename __ios_base::iostate __err = __ios_base::goodbit;
1028 typename __istream_type::sentry __cerb(__in,
true);
1034 const __int_type __idelim = _Traits::to_int_type(__delim);
1035 const __int_type __eof = _Traits::eof();
1036 __int_type __c = __in.
rdbuf()->sgetc();
1038 while (__extracted < __n
1039 && !_Traits::eq_int_type(__c, __eof)
1040 && !_Traits::eq_int_type(__c, __idelim))
1042 __str += _Traits::to_char_type(__c);
1044 __c = __in.
rdbuf()->snextc();
1047 if (_Traits::eq_int_type(__c, __eof))
1048 __err |= __ios_base::eofbit;
1049 else if (_Traits::eq_int_type(__c, __idelim))
1052 __in.
rdbuf()->sbumpc();
1055 __err |= __ios_base::failbit;
1059 __in._M_setstate(__ios_base::badbit);
1060 __throw_exception_again;
1067 __in._M_setstate(__ios_base::badbit);
1071 __err |= __ios_base::failbit;
1079 #if _GLIBCXX_EXTERN_TEMPLATE
1085 # if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
1086 extern template class basic_string<char>;
1087 # elif ! _GLIBCXX_USE_CXX11_ABI
1090 extern template basic_string<char>::size_type
1091 basic_string<char>::_Rep::_S_empty_rep_storage[];
1095 basic_istream<char>&
1098 basic_ostream<char>&
1099 operator<<(basic_ostream<char>&,
const string&);
1101 basic_istream<char>&
1102 getline(basic_istream<char>&,
string&,
char);
1104 basic_istream<char>&
1105 getline(basic_istream<char>&,
string&);
1107 #ifdef _GLIBCXX_USE_WCHAR_T
1108 # if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
1109 extern template class basic_string<wchar_t>;
1110 # elif ! _GLIBCXX_USE_CXX11_ABI
1111 extern template basic_string<wchar_t>::size_type
1112 basic_string<wchar_t>::_Rep::_S_empty_rep_storage[];
1116 basic_istream<wchar_t>&
1119 basic_ostream<wchar_t>&
1122 basic_istream<wchar_t>&
1125 basic_istream<wchar_t>&
1130 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr bool is_constant_evaluated() noexcept
Returns true only when called during constant evaluation.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
Return the data pointer of a container.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
void setstate(iostate __state)
Sets additional flags in the error state.
Template class basic_istream.
Managing sequences of characters and character-like objects.
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
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.
int compare(const basic_string &__str) const
Compare to a 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.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void reserve()
Equivalent to shrink_to_fit().
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & append(const basic_string &__str)
Append a string to this string.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
Thrown as part of forced unwinding.
streamsize width() const
Flags access.
locale getloc() const
Locale access.
Primary class template ctype facet.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.