35 #define _ISTREAM_TCC 1
37 #ifdef _GLIBCXX_SYSHDR
38 #pragma GCC system_header
41 #pragma GCC diagnostic push
42 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 template<
typename _CharT,
typename _Traits>
63 const __int_type __eof = traits_type::eof();
65 __int_type __c = __sb->
sgetc();
67 const __ctype_type& __ct = __check_facet(__in._M_ctype);
68 while (!traits_type::eq_int_type(__c, __eof)
69 && __ct.is(ctype_base::space,
70 traits_type::to_char_type(__c)))
76 if (traits_type::eq_int_type(__c, __eof))
83 __throw_exception_again;
98 template<
typename _CharT,
typename _Traits>
99 template<
typename _ValueT>
104 sentry __cerb(*
this,
false);
110 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
114 = use_facet<__num_get_type>(this->_M_ios_locale);
116 __ng.
get(*
this, 0, *
this, __err, __v);
121 __throw_exception_again;
126 this->setstate(__err);
131 template<
typename _CharT,
typename _Traits>
132 basic_istream<_CharT, _Traits>&
138 sentry __cerb(*
this,
false);
145 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
149 = use_facet<__num_get_type>(this->_M_ios_locale);
151 __ng.
get(*
this, 0, *
this, __err, __l);
155 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
158 __n = __gnu_cxx::__numeric_traits<short>::__min;
160 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
163 __n = __gnu_cxx::__numeric_traits<short>::__max;
171 __throw_exception_again;
176 this->setstate(__err);
181 template<
typename _CharT,
typename _Traits>
188 sentry __cerb(*
this,
false);
195 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
199 = use_facet<__num_get_type>(this->_M_ios_locale);
201 __ng.
get(*
this, 0, *
this, __err, __l);
205 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
208 __n = __gnu_cxx::__numeric_traits<int>::__min;
210 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
213 __n = __gnu_cxx::__numeric_traits<int>::__max;
221 __throw_exception_again;
226 this->setstate(__err);
231 template<
typename _CharT,
typename _Traits>
237 sentry __cerb(*
this,
false);
238 if (__cerb && __sbout)
243 if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
251 __throw_exception_again;
259 this->setstate(__err);
263 template<
typename _CharT,
typename _Traits>
264 typename basic_istream<_CharT, _Traits>::int_type
268 const int_type __eof = traits_type::eof();
269 int_type __c = __eof;
272 sentry __cerb(*
this,
true);
277 __c = this->rdbuf()->sbumpc();
279 if (!traits_type::eq_int_type(__c, __eof))
287 __throw_exception_again;
295 this->setstate(__err);
299 template<
typename _CharT,
typename _Traits>
306 sentry __cerb(*
this,
true);
311 const int_type __cb = this->rdbuf()->sbumpc();
313 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
316 __c = traits_type::to_char_type(__cb);
324 __throw_exception_again;
332 this->setstate(__err);
336 template<
typename _CharT,
typename _Traits>
343 sentry __cerb(*
this,
true);
348 const int_type __idelim = traits_type::to_int_type(__delim);
349 const int_type __eof = traits_type::eof();
351 int_type __c = __sb->
sgetc();
354 && !traits_type::eq_int_type(__c, __eof)
355 && !traits_type::eq_int_type(__c, __idelim))
357 *__s++ = traits_type::to_char_type(__c);
361 if (traits_type::eq_int_type(__c, __eof))
367 __throw_exception_again;
379 this->setstate(__err);
383 template<
typename _CharT,
typename _Traits>
390 sentry __cerb(*
this,
true);
395 const int_type __idelim = traits_type::to_int_type(__delim);
396 const int_type __eof = traits_type::eof();
398 int_type __c = __this_sb->
sgetc();
399 char_type __c2 = traits_type::to_char_type(__c);
400 #pragma GCC diagnostic push
401 #pragma GCC diagnostic ignored "-Wlong-long"
402 unsigned long long __gcount = 0;
403 #pragma GCC diagnostic pop
405 while (!traits_type::eq_int_type(__c, __eof)
406 && !traits_type::eq_int_type(__c, __idelim)
407 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
410 __c = __this_sb->
snextc();
411 __c2 = traits_type::to_char_type(__c);
413 if (traits_type::eq_int_type(__c, __eof))
417 if (__gcount <= __gnu_cxx::__numeric_traits<streamsize>::__max)
420 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
425 __throw_exception_again;
433 this->setstate(__err);
437 template<
typename _CharT,
typename _Traits>
444 sentry __cerb(*
this,
true);
449 const int_type __idelim = traits_type::to_int_type(__delim);
450 const int_type __eof = traits_type::eof();
452 int_type __c = __sb->
sgetc();
455 && !traits_type::eq_int_type(__c, __eof)
456 && !traits_type::eq_int_type(__c, __idelim))
458 *__s++ = traits_type::to_char_type(__c);
462 if (traits_type::eq_int_type(__c, __eof))
466 if (traits_type::eq_int_type(__c, __idelim))
478 __throw_exception_again;
490 this->setstate(__err);
497 template<
typename _CharT,
typename _Traits>
503 sentry __cerb(*
this,
true);
509 const int_type __eof = traits_type::eof();
512 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
520 __throw_exception_again;
525 this->setstate(__err);
530 template<
typename _CharT,
typename _Traits>
536 sentry __cerb(*
this,
true);
537 if (__cerb && __n > 0)
542 const int_type __eof = traits_type::eof();
544 int_type __c = __sb->
sgetc();
553 bool __large_ignore =
false;
557 && !traits_type::eq_int_type(__c, __eof))
562 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
563 && !traits_type::eq_int_type(__c, __eof))
566 __gnu_cxx::__numeric_traits<streamsize>::__min;
567 __large_ignore =
true;
573 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
576 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
578 if (traits_type::eq_int_type(__c, __eof))
583 if (traits_type::eq_int_type(__c, __eof))
590 __throw_exception_again;
595 this->setstate(__err);
600 template<
typename _CharT,
typename _Traits>
606 sentry __cerb(*
this,
true);
607 if (__cerb && __n > 0)
612 const int_type __eof = traits_type::eof();
614 int_type __c = __sb->
sgetc();
617 bool __large_ignore =
false;
621 && !traits_type::eq_int_type(__c, __eof)
622 && !traits_type::eq_int_type(__c, __delim))
627 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
628 && !traits_type::eq_int_type(__c, __eof)
629 && !traits_type::eq_int_type(__c, __delim))
632 __gnu_cxx::__numeric_traits<streamsize>::__min;
633 __large_ignore =
true;
639 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
642 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
644 if (traits_type::eq_int_type(__c, __eof))
655 if (traits_type::eq_int_type(__c, __eof))
667 __throw_exception_again;
672 this->setstate(__err);
677 template<
typename _CharT,
typename _Traits>
678 typename basic_istream<_CharT, _Traits>::int_type
682 int_type __c = traits_type::eof();
684 sentry __cerb(*
this,
true);
690 __c = this->rdbuf()->sgetc();
691 if (traits_type::eq_int_type(__c, traits_type::eof()))
697 __throw_exception_again;
702 this->setstate(__err);
707 template<
typename _CharT,
typename _Traits>
713 sentry __cerb(*
this,
true);
719 _M_gcount = this->rdbuf()->sgetn(__s, __n);
726 __throw_exception_again;
731 this->setstate(__err);
736 template<
typename _CharT,
typename _Traits>
742 sentry __cerb(*
this,
true);
749 const streamsize __num = this->rdbuf()->in_avail();
752 else if (__num == -1)
758 __throw_exception_again;
763 this->setstate(__err);
768 template<
typename _CharT,
typename _Traits>
778 sentry __cerb(*
this,
true);
784 const int_type __eof = traits_type::eof();
787 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
793 __throw_exception_again;
798 this->setstate(__err);
803 template<
typename _CharT,
typename _Traits>
813 sentry __cerb(*
this,
true);
819 const int_type __eof = traits_type::eof();
822 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
828 __throw_exception_again;
833 this->setstate(__err);
838 template<
typename _CharT,
typename _Traits>
846 sentry __cerb(*
this,
true);
864 __throw_exception_again;
869 this->setstate(__err);
874 template<
typename _CharT,
typename _Traits>
875 typename basic_istream<_CharT, _Traits>::pos_type
881 pos_type __ret = pos_type(-1);
882 sentry __cerb(*
this,
true);
894 __throw_exception_again;
902 template<
typename _CharT,
typename _Traits>
911 sentry __cerb(*
this,
true);
920 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
924 if (__p == pos_type(off_type(-1)))
931 __throw_exception_again;
936 this->setstate(__err);
941 template<
typename _CharT,
typename _Traits>
944 seekg(off_type __off, ios_base::seekdir __dir)
950 sentry __cerb(*
this,
true);
959 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
963 if (__p == pos_type(off_type(-1)))
970 __throw_exception_again;
975 this->setstate(__err);
981 template<
typename _CharT,
typename _Traits>
986 typedef typename __istream_type::int_type __int_type;
988 typename __istream_type::sentry __cerb(__in,
false);
994 const __int_type __cb = __in.rdbuf()->sbumpc();
995 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
996 __c = _Traits::to_char_type(__cb);
1003 __throw_exception_again;
1008 __in.setstate(__err);
1013 template<
typename _CharT,
typename _Traits>
1015 __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s,
1018 typedef basic_istream<_CharT, _Traits> __istream_type;
1019 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
1020 typedef typename _Traits::int_type int_type;
1021 typedef _CharT char_type;
1022 typedef ctype<_CharT> __ctype_type;
1026 typename __istream_type::sentry __cerb(__in,
false);
1033 if (0 < __width && __width < __num)
1036 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
1038 const int_type __eof = _Traits::eof();
1039 __streambuf_type* __sb = __in.rdbuf();
1040 int_type __c = __sb->sgetc();
1042 while (__extracted < __num - 1
1043 && !_Traits::eq_int_type(__c, __eof)
1044 && !__ct.is(ctype_base::space,
1045 _Traits::to_char_type(__c)))
1047 *__s++ = _Traits::to_char_type(__c);
1049 __c = __sb->snextc();
1052 if (__extracted < __num - 1
1053 && _Traits::eq_int_type(__c, __eof))
1064 __throw_exception_again;
1072 __in.setstate(__err);
1076 template<
typename _CharT,
typename _Traits>
1077 basic_istream<_CharT, _Traits>&
1082 typedef typename __istream_type::int_type __int_type;
1087 typename __istream_type::sentry __cerb(__in,
true);
1093 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
1094 const __int_type __eof = _Traits::eof();
1095 __streambuf_type* __sb = __in.rdbuf();
1096 __int_type __c = __sb->sgetc();
1100 if (_Traits::eq_int_type(__c, __eof))
1105 if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1107 __c = __sb->snextc();
1113 __throw_exception_again;
1120 __in.setstate(__err);
1127 #if _GLIBCXX_EXTERN_TEMPLATE
1128 #pragma GCC diagnostic push
1129 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
1130 #pragma GCC diagnostic ignored "-Wlong-long"
1131 extern template class basic_istream<char>;
1137 extern template istream& istream::_M_extract(
unsigned short&);
1138 extern template istream& istream::_M_extract(
unsigned int&);
1139 extern template istream& istream::_M_extract(
long&);
1140 extern template istream& istream::_M_extract(
unsigned long&);
1141 extern template istream& istream::_M_extract(
bool&);
1142 #ifdef _GLIBCXX_USE_LONG_LONG
1143 #pragma GCC diagnostic push
1144 #pragma GCC diagnostic ignored "-Wlong-long"
1145 extern template istream& istream::_M_extract(
long long&);
1146 extern template istream& istream::_M_extract(
unsigned long long&);
1147 #pragma GCC diagnostic pop
1149 extern template istream& istream::_M_extract(
float&);
1150 extern template istream& istream::_M_extract(
double&);
1151 extern template istream& istream::_M_extract(
long double&);
1152 extern template istream& istream::_M_extract(
void*&);
1154 extern template class basic_iostream<char>;
1156 #ifdef _GLIBCXX_USE_WCHAR_T
1157 extern template class basic_istream<wchar_t>;
1162 extern template wistream& wistream::_M_extract(
unsigned short&);
1163 extern template wistream& wistream::_M_extract(
unsigned int&);
1164 extern template wistream& wistream::_M_extract(
long&);
1165 extern template wistream& wistream::_M_extract(
unsigned long&);
1166 extern template wistream& wistream::_M_extract(
bool&);
1167 #ifdef _GLIBCXX_USE_LONG_LONG
1168 extern template wistream& wistream::_M_extract(
long long&);
1169 extern template wistream& wistream::_M_extract(
unsigned long long&);
1171 extern template wistream& wistream::_M_extract(
float&);
1172 extern template wistream& wistream::_M_extract(
double&);
1173 extern template wistream& wistream::_M_extract(
long double&);
1174 extern template wistream& wistream::_M_extract(
void*&);
1176 extern template class basic_iostream<wchar_t>;
1178 #pragma GCC diagnostic pop
1181 _GLIBCXX_END_NAMESPACE_VERSION
1184 #pragma GCC diagnostic pop