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);
532 this->_S_copy(__p + __nleft, __p + __len2,
539 this->_M_mutate(__pos, __len1, __s, __len2);
541 this->_M_set_length(__new_size);
545 template<
typename _CharT,
typename _Traits,
typename _Alloc>
547 typename basic_string<_CharT, _Traits, _Alloc>::size_type
549 copy(_CharT* __s, size_type __n, size_type __pos)
const
551 _M_check(__pos,
"basic_string::copy");
552 __n = _M_limit(__pos, __n);
553 __glibcxx_requires_string_len(__s, __n);
555 _S_copy(__s, _M_data() + __pos, __n);
560 #if __cplusplus > 202002L
561 template<
typename _CharT,
typename _Traits,
typename _Alloc>
562 template<
typename _Operation>
564 basic_string<_CharT, _Traits, _Alloc>::
565 resize_and_overwrite(size_type __n, _Operation __op)
567 const size_type __capacity = capacity();
569 if (__n > __capacity)
571 __p = _M_create(__n, __capacity);
572 this->_S_copy(__p, _M_data(), length());
573 #if __cpp_lib_is_constant_evaluated
575 traits_type::assign(__p + length(), __n - length(), _CharT());
584 constexpr ~_Terminator() { _M_this->_M_set_length(_M_r); }
585 basic_string* _M_this;
588 _Terminator __term{
this};
589 const size_type __n2 [[maybe_unused]] = __n;
591 _GLIBCXX_DEBUG_ASSERT(__term._M_r >= 0 && __term._M_r <= __n2);
597 #if __cpp_lib_constexpr_string >= 201907L
598 # define _GLIBCXX_STRING_CONSTEXPR constexpr
600 # define _GLIBCXX_STRING_CONSTEXPR
603 template<
typename _CharT,
typename _Traits,
typename _Alloc>
605 basic_string<_CharT, _Traits, _Alloc>
609 __glibcxx_requires_string(__lhs);
611 typedef typename __string_type::size_type __size_type;
613 rebind<_CharT>::other _Char_alloc_type;
615 const __size_type __len = _Traits::length(__lhs);
616 __string_type __str(_Alloc_traits::_S_select_on_copy(
618 __str.reserve(__len + __rhs.
size());
619 __str.append(__lhs, __len);
624 template<
typename _CharT,
typename _Traits,
typename _Alloc>
626 basic_string<_CharT, _Traits, _Alloc>
630 typedef typename __string_type::size_type __size_type;
632 rebind<_CharT>::other _Char_alloc_type;
634 __string_type __str(_Alloc_traits::_S_select_on_copy(
636 const __size_type __len = __rhs.
size();
637 __str.reserve(__len + 1);
638 __str.append(__size_type(1), __lhs);
643 template<
typename _CharT,
typename _Traits,
typename _Alloc>
644 _GLIBCXX_STRING_CONSTEXPR
645 typename basic_string<_CharT, _Traits, _Alloc>::size_type
647 find(
const _CharT* __s, size_type __pos, size_type __n)
const
650 __glibcxx_requires_string_len(__s, __n);
651 const size_type __size = this->
size();
654 return __pos <= __size ? __pos : npos;
658 const _CharT __elem0 = __s[0];
659 const _CharT*
const __data =
data();
660 const _CharT* __first = __data + __pos;
661 const _CharT*
const __last = __data + __size;
662 size_type __len = __size - __pos;
667 __first = traits_type::find(__first, __len - __n + 1, __elem0);
673 if (traits_type::compare(__first, __s, __n) == 0)
674 return __first - __data;
675 __len = __last - ++__first;
680 template<
typename _CharT,
typename _Traits,
typename _Alloc>
681 _GLIBCXX_STRING_CONSTEXPR
682 typename basic_string<_CharT, _Traits, _Alloc>::size_type
684 find(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
686 size_type __ret = npos;
687 const size_type __size = this->
size();
690 const _CharT* __data = _M_data();
691 const size_type __n = __size - __pos;
692 const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
694 __ret = __p - __data;
699 template<
typename _CharT,
typename _Traits,
typename _Alloc>
700 _GLIBCXX_STRING_CONSTEXPR
701 typename basic_string<_CharT, _Traits, _Alloc>::size_type
703 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
706 __glibcxx_requires_string_len(__s, __n);
707 const size_type __size = this->
size();
710 __pos =
std::min(size_type(__size - __n), __pos);
711 const _CharT* __data = _M_data();
714 if (traits_type::compare(__data + __pos, __s, __n) == 0)
722 template<
typename _CharT,
typename _Traits,
typename _Alloc>
723 _GLIBCXX_STRING_CONSTEXPR
724 typename basic_string<_CharT, _Traits, _Alloc>::size_type
726 rfind(_CharT __c, size_type __pos)
const _GLIBCXX_NOEXCEPT
728 size_type __size = this->
size();
731 if (--__size > __pos)
733 for (++__size; __size-- > 0; )
734 if (traits_type::eq(_M_data()[__size], __c))
740 template<
typename _CharT,
typename _Traits,
typename _Alloc>
741 _GLIBCXX_STRING_CONSTEXPR
742 typename basic_string<_CharT, _Traits, _Alloc>::size_type
744 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
747 __glibcxx_requires_string_len(__s, __n);
748 for (; __n && __pos < this->
size(); ++__pos)
750 const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
757 template<
typename _CharT,
typename _Traits,
typename _Alloc>
758 _GLIBCXX_STRING_CONSTEXPR
759 typename basic_string<_CharT, _Traits, _Alloc>::size_type
761 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
764 __glibcxx_requires_string_len(__s, __n);
765 size_type __size = this->
size();
768 if (--__size > __pos)
772 if (traits_type::find(__s, __n, _M_data()[__size]))
775 while (__size-- != 0);
780 template<
typename _CharT,
typename _Traits,
typename _Alloc>
781 _GLIBCXX_STRING_CONSTEXPR
782 typename basic_string<_CharT, _Traits, _Alloc>::size_type
787 __glibcxx_requires_string_len(__s, __n);
788 for (; __pos < this->
size(); ++__pos)
789 if (!traits_type::find(__s, __n, _M_data()[__pos]))
794 template<
typename _CharT,
typename _Traits,
typename _Alloc>
795 _GLIBCXX_STRING_CONSTEXPR
796 typename basic_string<_CharT, _Traits, _Alloc>::size_type
800 for (; __pos < this->
size(); ++__pos)
801 if (!traits_type::eq(_M_data()[__pos], __c))
806 template<
typename _CharT,
typename _Traits,
typename _Alloc>
807 _GLIBCXX_STRING_CONSTEXPR
808 typename basic_string<_CharT, _Traits, _Alloc>::size_type
813 __glibcxx_requires_string_len(__s, __n);
814 size_type __size = this->
size();
817 if (--__size > __pos)
821 if (!traits_type::find(__s, __n, _M_data()[__size]))
829 template<
typename _CharT,
typename _Traits,
typename _Alloc>
830 _GLIBCXX_STRING_CONSTEXPR
831 typename basic_string<_CharT, _Traits, _Alloc>::size_type
835 size_type __size = this->
size();
838 if (--__size > __pos)
842 if (!traits_type::eq(_M_data()[__size], __c))
850 template<
typename _CharT,
typename _Traits,
typename _Alloc>
851 _GLIBCXX_STRING_CONSTEXPR
856 _M_check(__pos,
"basic_string::compare");
857 __n = _M_limit(__pos, __n);
858 const size_type __osize = __str.
size();
859 const size_type __len =
std::min(__n, __osize);
860 int __r = traits_type::compare(_M_data() + __pos, __str.
data(), __len);
862 __r = _S_compare(__n, __osize);
866 template<
typename _CharT,
typename _Traits,
typename _Alloc>
867 _GLIBCXX_STRING_CONSTEXPR
871 size_type __pos2, size_type __n2)
const
873 _M_check(__pos1,
"basic_string::compare");
874 __str._M_check(__pos2,
"basic_string::compare");
875 __n1 = _M_limit(__pos1, __n1);
876 __n2 = __str._M_limit(__pos2, __n2);
877 const size_type __len =
std::min(__n1, __n2);
878 int __r = traits_type::compare(_M_data() + __pos1,
879 __str.
data() + __pos2, __len);
881 __r = _S_compare(__n1, __n2);
885 template<
typename _CharT,
typename _Traits,
typename _Alloc>
886 _GLIBCXX_STRING_CONSTEXPR
889 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
891 __glibcxx_requires_string(__s);
892 const size_type __size = this->
size();
893 const size_type __osize = traits_type::length(__s);
894 const size_type __len =
std::min(__size, __osize);
895 int __r = traits_type::compare(_M_data(), __s, __len);
897 __r = _S_compare(__size, __osize);
901 template<
typename _CharT,
typename _Traits,
typename _Alloc>
902 _GLIBCXX_STRING_CONSTEXPR
905 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const
907 __glibcxx_requires_string(__s);
908 _M_check(__pos,
"basic_string::compare");
909 __n1 = _M_limit(__pos, __n1);
910 const size_type __osize = traits_type::length(__s);
911 const size_type __len =
std::min(__n1, __osize);
912 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
914 __r = _S_compare(__n1, __osize);
918 template<
typename _CharT,
typename _Traits,
typename _Alloc>
919 _GLIBCXX_STRING_CONSTEXPR
922 compare(size_type __pos, size_type __n1,
const _CharT* __s,
923 size_type __n2)
const
925 __glibcxx_requires_string_len(__s, __n2);
926 _M_check(__pos,
"basic_string::compare");
927 __n1 = _M_limit(__pos, __n1);
928 const size_type __len =
std::min(__n1, __n2);
929 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
931 __r = _S_compare(__n1, __n2);
935 #undef _GLIBCXX_STRING_CONSTEXPR
938 template<
typename _CharT,
typename _Traits,
typename _Alloc>
945 typedef typename __istream_type::ios_base __ios_base;
946 typedef typename __istream_type::int_type __int_type;
947 typedef typename __string_type::size_type __size_type;
949 typedef typename __ctype_type::ctype_base __ctype_base;
951 __size_type __extracted = 0;
952 typename __ios_base::iostate __err = __ios_base::goodbit;
953 typename __istream_type::sentry __cerb(__in,
false);
961 __size_type __len = 0;
963 const __size_type __n = __w > 0 ?
static_cast<__size_type
>(__w)
965 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
966 const __int_type __eof = _Traits::eof();
967 __int_type __c = __in.
rdbuf()->sgetc();
969 while (__extracted < __n
970 && !_Traits::eq_int_type(__c, __eof)
971 && !__ct.is(__ctype_base::space,
972 _Traits::to_char_type(__c)))
974 if (__len ==
sizeof(__buf) /
sizeof(_CharT))
976 __str.
append(__buf,
sizeof(__buf) /
sizeof(_CharT));
979 __buf[__len++] = _Traits::to_char_type(__c);
981 __c = __in.
rdbuf()->snextc();
983 __str.
append(__buf, __len);
985 if (__extracted < __n && _Traits::eq_int_type(__c, __eof))
986 __err |= __ios_base::eofbit;
991 __in._M_setstate(__ios_base::badbit);
992 __throw_exception_again;
999 __in._M_setstate(__ios_base::badbit);
1004 __err |= __ios_base::failbit;
1010 template<
typename _CharT,
typename _Traits,
typename _Alloc>
1011 basic_istream<_CharT, _Traits>&
1017 typedef typename __istream_type::ios_base __ios_base;
1018 typedef typename __istream_type::int_type __int_type;
1019 typedef typename __string_type::size_type __size_type;
1021 __size_type __extracted = 0;
1022 const __size_type __n = __str.
max_size();
1023 typename __ios_base::iostate __err = __ios_base::goodbit;
1024 typename __istream_type::sentry __cerb(__in,
true);
1030 const __int_type __idelim = _Traits::to_int_type(__delim);
1031 const __int_type __eof = _Traits::eof();
1032 __int_type __c = __in.
rdbuf()->sgetc();
1034 while (__extracted < __n
1035 && !_Traits::eq_int_type(__c, __eof)
1036 && !_Traits::eq_int_type(__c, __idelim))
1038 __str += _Traits::to_char_type(__c);
1040 __c = __in.
rdbuf()->snextc();
1043 if (_Traits::eq_int_type(__c, __eof))
1044 __err |= __ios_base::eofbit;
1045 else if (_Traits::eq_int_type(__c, __idelim))
1048 __in.
rdbuf()->sbumpc();
1051 __err |= __ios_base::failbit;
1055 __in._M_setstate(__ios_base::badbit);
1056 __throw_exception_again;
1063 __in._M_setstate(__ios_base::badbit);
1067 __err |= __ios_base::failbit;
1075 #if _GLIBCXX_EXTERN_TEMPLATE
1081 # if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
1082 extern template class basic_string<char>;
1083 # elif ! _GLIBCXX_USE_CXX11_ABI
1086 extern template basic_string<char>::size_type
1087 basic_string<char>::_Rep::_S_empty_rep_storage[];
1091 basic_istream<char>&
1094 basic_ostream<char>&
1095 operator<<(basic_ostream<char>&,
const string&);
1097 basic_istream<char>&
1098 getline(basic_istream<char>&,
string&,
char);
1100 basic_istream<char>&
1101 getline(basic_istream<char>&,
string&);
1103 #ifdef _GLIBCXX_USE_WCHAR_T
1104 # if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0
1105 extern template class basic_string<wchar_t>;
1106 # elif ! _GLIBCXX_USE_CXX11_ABI
1107 extern template basic_string<wchar_t>::size_type
1108 basic_string<wchar_t>::_Rep::_S_empty_rep_storage[];
1112 basic_istream<wchar_t>&
1115 basic_ostream<wchar_t>&
1118 basic_istream<wchar_t>&
1121 basic_istream<wchar_t>&
1126 _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.