37#pragma GCC system_header
41namespace std _GLIBCXX_VISIBILITY(default)
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template<
typename _CharT,
typename _Traits>
56 if (!__noskip && bool(__in.flags() & ios_base::skipws))
58 const __int_type __eof = traits_type::eof();
59 __streambuf_type* __sb = __in.rdbuf();
60 __int_type __c = __sb->sgetc();
62 const __ctype_type& __ct = __check_facet(__in._M_ctype);
63 while (!traits_type::eq_int_type(__c, __eof)
64 && __ct.is(ctype_base::space,
65 traits_type::to_char_type(__c)))
71 if (traits_type::eq_int_type(__c, __eof))
72 __err |= ios_base::eofbit;
78 __throw_exception_again;
93 template<
typename _CharT,
typename _Traits>
94 template<
typename _ValueT>
95 basic_istream<_CharT, _Traits>&
96 basic_istream<_CharT, _Traits>::
97 _M_extract(_ValueT& __v)
99 sentry __cerb(*
this,
false);
105#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
106 const __num_get_type& __ng = __check_facet(this->_M_num_get);
108 const __num_get_type& __ng
111 __ng.get(*
this, 0, *
this, __err, __v);
116 __throw_exception_again;
121 this->setstate(__err);
126 template<
typename _CharT,
typename _Traits>
127 basic_istream<_CharT, _Traits>&
133 sentry __cerb(*
this,
false);
140#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
146 __ng.
get(*
this, 0, *
this, __err, __l);
150 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
153 __n = __gnu_cxx::__numeric_traits<short>::__min;
155 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
158 __n = __gnu_cxx::__numeric_traits<short>::__max;
166 __throw_exception_again;
171 this->setstate(__err);
176 template<
typename _CharT,
typename _Traits>
183 sentry __cerb(*
this,
false);
190#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
196 __ng.
get(*
this, 0, *
this, __err, __l);
200 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
203 __n = __gnu_cxx::__numeric_traits<int>::__min;
205 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
208 __n = __gnu_cxx::__numeric_traits<int>::__max;
216 __throw_exception_again;
221 this->setstate(__err);
226 template<
typename _CharT,
typename _Traits>
227 basic_istream<_CharT, _Traits>&
232 sentry __cerb(*
this,
false);
233 if (__cerb && __sbout)
238 if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
246 __throw_exception_again;
254 this->setstate(__err);
258 template<
typename _CharT,
typename _Traits>
259 typename basic_istream<_CharT, _Traits>::int_type
263 const int_type __eof = traits_type::eof();
264 int_type __c = __eof;
267 sentry __cerb(*
this,
true);
272 __c = this->rdbuf()->sbumpc();
274 if (!traits_type::eq_int_type(__c, __eof))
282 __throw_exception_again;
290 this->setstate(__err);
294 template<
typename _CharT,
typename _Traits>
301 sentry __cerb(*
this,
true);
306 const int_type __cb = this->rdbuf()->sbumpc();
308 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
311 __c = traits_type::to_char_type(__cb);
319 __throw_exception_again;
327 this->setstate(__err);
331 template<
typename _CharT,
typename _Traits>
338 sentry __cerb(*
this,
true);
343 const int_type __idelim = traits_type::to_int_type(__delim);
344 const int_type __eof = traits_type::eof();
346 int_type __c = __sb->
sgetc();
348 while (_M_gcount + 1 < __n
349 && !traits_type::eq_int_type(__c, __eof)
350 && !traits_type::eq_int_type(__c, __idelim))
352 *__s++ = traits_type::to_char_type(__c);
356 if (traits_type::eq_int_type(__c, __eof))
362 __throw_exception_again;
374 this->setstate(__err);
378 template<
typename _CharT,
typename _Traits>
379 basic_istream<_CharT, _Traits>&
385 sentry __cerb(*
this,
true);
390 const int_type __idelim = traits_type::to_int_type(__delim);
391 const int_type __eof = traits_type::eof();
393 int_type __c = __this_sb->
sgetc();
394 char_type __c2 = traits_type::to_char_type(__c);
395#pragma GCC diagnostic push
396#pragma GCC diagnostic ignored "-Wlong-long"
397 unsigned long long __gcount = 0;
398#pragma GCC diagnostic pop
400 while (!traits_type::eq_int_type(__c, __eof)
401 && !traits_type::eq_int_type(__c, __idelim)
402 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
405 __c = __this_sb->
snextc();
406 __c2 = traits_type::to_char_type(__c);
408 if (traits_type::eq_int_type(__c, __eof))
412 if (__gcount <= __gnu_cxx::__numeric_traits<streamsize>::__max)
413 _M_gcount = __gcount;
415 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
420 __throw_exception_again;
428 this->setstate(__err);
432 template<
typename _CharT,
typename _Traits>
433 basic_istream<_CharT, _Traits>&
439 sentry __cerb(*
this,
true);
444 const int_type __idelim = traits_type::to_int_type(__delim);
445 const int_type __eof = traits_type::eof();
447 int_type __c = __sb->
sgetc();
449 while (_M_gcount + 1 < __n
450 && !traits_type::eq_int_type(__c, __eof)
451 && !traits_type::eq_int_type(__c, __idelim))
453 *__s++ = traits_type::to_char_type(__c);
457 if (traits_type::eq_int_type(__c, __eof))
461 if (traits_type::eq_int_type(__c, __idelim))
473 __throw_exception_again;
485 this->setstate(__err);
492 template<
typename _CharT,
typename _Traits>
493 basic_istream<_CharT, _Traits>&
498 sentry __cerb(*
this,
true);
504 const int_type __eof = traits_type::eof();
507 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
515 __throw_exception_again;
520 this->setstate(__err);
525 template<
typename _CharT,
typename _Traits>
526 basic_istream<_CharT, _Traits>&
531 sentry __cerb(*
this,
true);
532 if (__cerb && __n > 0)
537 const int_type __eof = traits_type::eof();
539 int_type __c = __sb->
sgetc();
548 bool __large_ignore =
false;
551 while (_M_gcount < __n
552 && !traits_type::eq_int_type(__c, __eof))
557 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
558 && !traits_type::eq_int_type(__c, __eof))
561 __gnu_cxx::__numeric_traits<streamsize>::__min;
562 __large_ignore =
true;
568 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
571 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
573 if (traits_type::eq_int_type(__c, __eof))
576 else if (_M_gcount < __n)
578 if (traits_type::eq_int_type(__c, __eof))
585 __throw_exception_again;
590 this->setstate(__err);
595 template<
typename _CharT,
typename _Traits>
596 basic_istream<_CharT, _Traits>&
601 sentry __cerb(*
this,
true);
602 if (__cerb && __n > 0)
607 const int_type __eof = traits_type::eof();
609 int_type __c = __sb->
sgetc();
612 bool __large_ignore =
false;
615 while (_M_gcount < __n
616 && !traits_type::eq_int_type(__c, __eof)
617 && !traits_type::eq_int_type(__c, __delim))
622 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
623 && !traits_type::eq_int_type(__c, __eof)
624 && !traits_type::eq_int_type(__c, __delim))
627 __gnu_cxx::__numeric_traits<streamsize>::__min;
628 __large_ignore =
true;
634 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
637 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
639 if (traits_type::eq_int_type(__c, __eof))
643 if (_M_gcount != __n)
648 else if (_M_gcount < __n)
650 if (traits_type::eq_int_type(__c, __eof))
662 __throw_exception_again;
667 this->setstate(__err);
672 template<
typename _CharT,
typename _Traits>
673 typename basic_istream<_CharT, _Traits>::int_type
677 int_type __c = traits_type::eof();
679 sentry __cerb(*
this,
true);
685 __c = this->rdbuf()->sgetc();
686 if (traits_type::eq_int_type(__c, traits_type::eof()))
692 __throw_exception_again;
697 this->setstate(__err);
702 template<
typename _CharT,
typename _Traits>
703 basic_istream<_CharT, _Traits>&
708 sentry __cerb(*
this,
true);
714 _M_gcount = this->rdbuf()->sgetn(__s, __n);
715 if (_M_gcount != __n)
721 __throw_exception_again;
726 this->setstate(__err);
731 template<
typename _CharT,
typename _Traits>
737 sentry __cerb(*
this,
true);
744 const streamsize __num = this->rdbuf()->in_avail();
746 _M_gcount = this->rdbuf()->sgetn(__s,
std::min(__num, __n));
747 else if (__num == -1)
753 __throw_exception_again;
758 this->setstate(__err);
763 template<
typename _CharT,
typename _Traits>
773 sentry __cerb(*
this,
true);
779 const int_type __eof = traits_type::eof();
782 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
788 __throw_exception_again;
793 this->setstate(__err);
798 template<
typename _CharT,
typename _Traits>
808 sentry __cerb(*
this,
true);
814 const int_type __eof = traits_type::eof();
817 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
823 __throw_exception_again;
828 this->setstate(__err);
833 template<
typename _CharT,
typename _Traits>
841 sentry __cerb(*
this,
true);
859 __throw_exception_again;
864 this->setstate(__err);
869 template<
typename _CharT,
typename _Traits>
870 typename basic_istream<_CharT, _Traits>::pos_type
876 pos_type __ret = pos_type(-1);
877 sentry __cerb(*
this,
true);
889 __throw_exception_again;
897 template<
typename _CharT,
typename _Traits>
900 seekg(pos_type __pos)
906 sentry __cerb(*
this,
true);
915 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
919 if (__p == pos_type(off_type(-1)))
926 __throw_exception_again;
931 this->setstate(__err);
936 template<
typename _CharT,
typename _Traits>
939 seekg(off_type __off, ios_base::seekdir __dir)
945 sentry __cerb(*
this,
true);
954 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
958 if (__p == pos_type(off_type(-1)))
965 __throw_exception_again;
970 this->setstate(__err);
976 template<
typename _CharT,
typename _Traits>
981 typedef typename __istream_type::int_type __int_type;
983 typename __istream_type::sentry __cerb(__in,
false);
989 const __int_type __cb = __in.
rdbuf()->sbumpc();
990 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
991 __c = _Traits::to_char_type(__cb);
998 __throw_exception_again;
1008 template<
typename _CharT,
typename _Traits>
1010 __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s,
1013 typedef basic_istream<_CharT, _Traits> __istream_type;
1014 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
1015 typedef typename _Traits::int_type int_type;
1016 typedef _CharT char_type;
1017 typedef ctype<_CharT> __ctype_type;
1021 typename __istream_type::sentry __cerb(__in,
false);
1028 if (0 < __width && __width < __num)
1033 const int_type __eof = _Traits::eof();
1034 __streambuf_type* __sb = __in.rdbuf();
1035 int_type __c = __sb->
sgetc();
1037 while (__extracted < __num - 1
1038 && !_Traits::eq_int_type(__c, __eof)
1039 && !__ct.is(ctype_base::space,
1040 _Traits::to_char_type(__c)))
1042 *__s++ = _Traits::to_char_type(__c);
1044 __c = __sb->snextc();
1047 if (__extracted < __num - 1
1048 && _Traits::eq_int_type(__c, __eof))
1059 __throw_exception_again;
1067 __in.setstate(__err);
1071 template<
typename _CharT,
typename _Traits>
1072 basic_istream<_CharT, _Traits>&
1077 typedef typename __istream_type::int_type __int_type;
1082 typename __istream_type::sentry __cerb(__in,
true);
1089 const __int_type __eof = _Traits::eof();
1090 __streambuf_type* __sb = __in.
rdbuf();
1091 __int_type __c = __sb->sgetc();
1095 if (_Traits::eq_int_type(__c, __eof))
1100 if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1102 __c = __sb->snextc();
1108 __throw_exception_again;
1122#if _GLIBCXX_EXTERN_TEMPLATE
1123#pragma GCC diagnostic push
1124#pragma GCC diagnostic ignored "-Wc++11-extensions"
1125#pragma GCC diagnostic ignored "-Wlong-long"
1126 extern template class basic_istream<char>;
1132 extern template istream& istream::_M_extract(
unsigned short&);
1133 extern template istream& istream::_M_extract(
unsigned int&);
1134 extern template istream& istream::_M_extract(
long&);
1135 extern template istream& istream::_M_extract(
unsigned long&);
1136 extern template istream& istream::_M_extract(
bool&);
1137#ifdef _GLIBCXX_USE_LONG_LONG
1138#pragma GCC diagnostic push
1139#pragma GCC diagnostic ignored "-Wlong-long"
1140 extern template istream& istream::_M_extract(
long long&);
1141 extern template istream& istream::_M_extract(
unsigned long long&);
1142#pragma GCC diagnostic pop
1144 extern template istream& istream::_M_extract(
float&);
1145 extern template istream& istream::_M_extract(
double&);
1146 extern template istream& istream::_M_extract(
long double&);
1147 extern template istream& istream::_M_extract(
void*&);
1149 extern template class basic_iostream<char>;
1151#ifdef _GLIBCXX_USE_WCHAR_T
1152 extern template class basic_istream<wchar_t>;
1157 extern template wistream& wistream::_M_extract(
unsigned short&);
1158 extern template wistream& wistream::_M_extract(
unsigned int&);
1159 extern template wistream& wistream::_M_extract(
long&);
1160 extern template wistream& wistream::_M_extract(
unsigned long&);
1161 extern template wistream& wistream::_M_extract(
bool&);
1162#ifdef _GLIBCXX_USE_LONG_LONG
1163 extern template wistream& wistream::_M_extract(
long long&);
1164 extern template wistream& wistream::_M_extract(
unsigned long long&);
1166 extern template wistream& wistream::_M_extract(
float&);
1167 extern template wistream& wistream::_M_extract(
double&);
1168 extern template wistream& wistream::_M_extract(
long double&);
1169 extern template wistream& wistream::_M_extract(
void*&);
1171 extern template class basic_iostream<wchar_t>;
1173#pragma GCC diagnostic pop
1176_GLIBCXX_END_NAMESPACE_VERSION
basic_istream< char > istream
Base class for char input streams.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
const _Facet & use_facet(const locale &__loc)
Return a facet.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
void setstate(iostate __state)
Sets additional flags in the error state.
bool good() const
Fast error checking.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
The actual work of input and output (interface).
int_type snextc()
Getting the next character.
int_type sbumpc()
Getting the next character.
int_type sungetc()
Moving backwards in the input stream.
int_type sgetc()
Getting the next character.
int pubsync()
Calls virtual sync function.
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
int_type sputc(char_type __c)
Entry point for all single-character output functions.
Template class basic_istream.
__istream_type & seekg(pos_type)
Changing the current read position.
int_type get()
Simple extraction.
streamsize readsome(char_type *__s, streamsize __n)
Extraction until the buffer is exhausted, but no more.
int_type peek()
Looking ahead in the stream.
__istream_type & unget()
Unextracting the previous character.
pos_type tellg()
Getting the current read position.
__istream_type & ignore()
Simple extraction.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
__istream_type & putback(char_type __c)
Unextracting a single character.
__istream_type & getline(char_type *__s, streamsize __n, char_type __delim)
String extraction.
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
int sync()
Synchronizing the stream buffer.
Performs setup work for input streams.
sentry(basic_istream< _CharT, _Traits > &__is, bool __noskipws=false)
The constructor performs all the work.
Thrown as part of forced unwinding.
static const seekdir cur
Request a seek relative to the current position within the sequence.
static const openmode in
Open for input. Default for ifstream and fstream.
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
static const iostate goodbit
Indicates all is well.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
_Ios_Iostate iostate
This is a bitmask type.
locale getloc() const
Locale access.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
Primary class template ctype facet.
Primary class template num_get.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.