1 // istream classes -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5 // Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
38 // ISO C++ 14882: 27.6.1 Input streams
42 #define _ISTREAM_TCC 1
44 #pragma GCC system_header
46 #include <cxxabi-internal.h>
48 _GLIBCXX_BEGIN_NAMESPACE(std)
50 template<typename _CharT, typename _Traits>
51 basic_istream<_CharT, _Traits>::sentry::
52 sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false)
54 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
59 if (!__noskip && (__in.flags() & ios_base::skipws))
61 const __int_type __eof = traits_type::eof();
62 __streambuf_type* __sb = __in.rdbuf();
63 __int_type __c = __sb->sgetc();
65 const __ctype_type& __ct = __check_facet(__in._M_ctype);
66 while (!traits_type::eq_int_type(__c, __eof)
67 && __ct.is(ctype_base::space,
68 traits_type::to_char_type(__c)))
71 // _GLIBCXX_RESOLVE_LIB_DEFECTS
72 // 195. Should basic_istream::sentry's constructor ever
74 if (traits_type::eq_int_type(__c, __eof))
75 __err |= ios_base::eofbit;
79 if (__in.good() && __err == ios_base::goodbit)
83 __err |= ios_base::failbit;
88 template<typename _CharT, typename _Traits>
89 template<typename _ValueT>
90 basic_istream<_CharT, _Traits>&
91 basic_istream<_CharT, _Traits>::
92 _M_extract(_ValueT& __v)
94 sentry __cerb(*this, false);
97 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
100 const __num_get_type& __ng = __check_facet(this->_M_num_get);
101 __ng.get(*this, 0, *this, __err, __v);
103 catch(__cxxabiv1::__forced_unwind&)
105 this->_M_setstate(ios_base::badbit);
106 __throw_exception_again;
109 { this->_M_setstate(ios_base::badbit); }
111 this->setstate(__err);
116 template<typename _CharT, typename _Traits>
117 basic_istream<_CharT, _Traits>&
118 basic_istream<_CharT, _Traits>::
119 operator>>(short& __n)
121 // _GLIBCXX_RESOLVE_LIB_DEFECTS
122 // 118. basic_istream uses nonexistent num_get member functions.
127 if (__gnu_cxx::__numeric_traits<short>::__min <= __l
128 && __l <= __gnu_cxx::__numeric_traits<short>::__max)
131 this->setstate(ios_base::failbit);
136 template<typename _CharT, typename _Traits>
137 basic_istream<_CharT, _Traits>&
138 basic_istream<_CharT, _Traits>::
141 // _GLIBCXX_RESOLVE_LIB_DEFECTS
142 // 118. basic_istream uses nonexistent num_get member functions.
147 if (__gnu_cxx::__numeric_traits<int>::__min <= __l
148 && __l <= __gnu_cxx::__numeric_traits<int>::__max)
151 this->setstate(ios_base::failbit);
156 template<typename _CharT, typename _Traits>
157 basic_istream<_CharT, _Traits>&
158 basic_istream<_CharT, _Traits>::
159 operator>>(__streambuf_type* __sbout)
161 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
162 sentry __cerb(*this, false);
163 if (__cerb && __sbout)
168 if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
169 __err |= ios_base::failbit;
171 __err |= ios_base::eofbit;
173 catch(__cxxabiv1::__forced_unwind&)
175 this->_M_setstate(ios_base::failbit);
176 __throw_exception_again;
179 { this->_M_setstate(ios_base::failbit); }
182 __err |= ios_base::failbit;
184 this->setstate(__err);
188 template<typename _CharT, typename _Traits>
189 typename basic_istream<_CharT, _Traits>::int_type
190 basic_istream<_CharT, _Traits>::
193 const int_type __eof = traits_type::eof();
194 int_type __c = __eof;
196 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
197 sentry __cerb(*this, true);
202 __c = this->rdbuf()->sbumpc();
203 // 27.6.1.1 paragraph 3
204 if (!traits_type::eq_int_type(__c, __eof))
207 __err |= ios_base::eofbit;
209 catch(__cxxabiv1::__forced_unwind&)
211 this->_M_setstate(ios_base::badbit);
212 __throw_exception_again;
215 { this->_M_setstate(ios_base::badbit); }
218 __err |= ios_base::failbit;
220 this->setstate(__err);
224 template<typename _CharT, typename _Traits>
225 basic_istream<_CharT, _Traits>&
226 basic_istream<_CharT, _Traits>::
230 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
231 sentry __cerb(*this, true);
236 const int_type __cb = this->rdbuf()->sbumpc();
237 // 27.6.1.1 paragraph 3
238 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
241 __c = traits_type::to_char_type(__cb);
244 __err |= ios_base::eofbit;
246 catch(__cxxabiv1::__forced_unwind&)
248 this->_M_setstate(ios_base::badbit);
249 __throw_exception_again;
252 { this->_M_setstate(ios_base::badbit); }
255 __err |= ios_base::failbit;
257 this->setstate(__err);
261 template<typename _CharT, typename _Traits>
262 basic_istream<_CharT, _Traits>&
263 basic_istream<_CharT, _Traits>::
264 get(char_type* __s, streamsize __n, char_type __delim)
267 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
268 sentry __cerb(*this, true);
273 const int_type __idelim = traits_type::to_int_type(__delim);
274 const int_type __eof = traits_type::eof();
275 __streambuf_type* __sb = this->rdbuf();
276 int_type __c = __sb->sgetc();
278 while (_M_gcount + 1 < __n
279 && !traits_type::eq_int_type(__c, __eof)
280 && !traits_type::eq_int_type(__c, __idelim))
282 *__s++ = traits_type::to_char_type(__c);
284 __c = __sb->snextc();
286 if (traits_type::eq_int_type(__c, __eof))
287 __err |= ios_base::eofbit;
289 catch(__cxxabiv1::__forced_unwind&)
291 this->_M_setstate(ios_base::badbit);
292 __throw_exception_again;
295 { this->_M_setstate(ios_base::badbit); }
297 // _GLIBCXX_RESOLVE_LIB_DEFECTS
298 // 243. get and getline when sentry reports failure.
302 __err |= ios_base::failbit;
304 this->setstate(__err);
308 template<typename _CharT, typename _Traits>
309 basic_istream<_CharT, _Traits>&
310 basic_istream<_CharT, _Traits>::
311 get(__streambuf_type& __sb, char_type __delim)
314 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
315 sentry __cerb(*this, true);
320 const int_type __idelim = traits_type::to_int_type(__delim);
321 const int_type __eof = traits_type::eof();
322 __streambuf_type* __this_sb = this->rdbuf();
323 int_type __c = __this_sb->sgetc();
324 char_type __c2 = traits_type::to_char_type(__c);
326 while (!traits_type::eq_int_type(__c, __eof)
327 && !traits_type::eq_int_type(__c, __idelim)
328 && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
331 __c = __this_sb->snextc();
332 __c2 = traits_type::to_char_type(__c);
334 if (traits_type::eq_int_type(__c, __eof))
335 __err |= ios_base::eofbit;
337 catch(__cxxabiv1::__forced_unwind&)
339 this->_M_setstate(ios_base::badbit);
340 __throw_exception_again;
343 { this->_M_setstate(ios_base::badbit); }
346 __err |= ios_base::failbit;
348 this->setstate(__err);
352 template<typename _CharT, typename _Traits>
353 basic_istream<_CharT, _Traits>&
354 basic_istream<_CharT, _Traits>::
355 getline(char_type* __s, streamsize __n, char_type __delim)
358 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
359 sentry __cerb(*this, true);
364 const int_type __idelim = traits_type::to_int_type(__delim);
365 const int_type __eof = traits_type::eof();
366 __streambuf_type* __sb = this->rdbuf();
367 int_type __c = __sb->sgetc();
369 while (_M_gcount + 1 < __n
370 && !traits_type::eq_int_type(__c, __eof)
371 && !traits_type::eq_int_type(__c, __idelim))
373 *__s++ = traits_type::to_char_type(__c);
374 __c = __sb->snextc();
377 if (traits_type::eq_int_type(__c, __eof))
378 __err |= ios_base::eofbit;
381 if (traits_type::eq_int_type(__c, __idelim))
387 __err |= ios_base::failbit;
390 catch(__cxxabiv1::__forced_unwind&)
392 this->_M_setstate(ios_base::badbit);
393 __throw_exception_again;
396 { this->_M_setstate(ios_base::badbit); }
398 // _GLIBCXX_RESOLVE_LIB_DEFECTS
399 // 243. get and getline when sentry reports failure.
403 __err |= ios_base::failbit;
405 this->setstate(__err);
409 // We provide three overloads, since the first two are much simpler
410 // than the general case. Also, the latter two can thus adopt the
411 // same "batchy" strategy used by getline above.
412 template<typename _CharT, typename _Traits>
413 basic_istream<_CharT, _Traits>&
414 basic_istream<_CharT, _Traits>::
418 sentry __cerb(*this, true);
421 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
424 const int_type __eof = traits_type::eof();
425 __streambuf_type* __sb = this->rdbuf();
427 if (traits_type::eq_int_type(__sb->sbumpc(), __eof))
428 __err |= ios_base::eofbit;
432 catch(__cxxabiv1::__forced_unwind&)
434 this->_M_setstate(ios_base::badbit);
435 __throw_exception_again;
438 { this->_M_setstate(ios_base::badbit); }
440 this->setstate(__err);
445 template<typename _CharT, typename _Traits>
446 basic_istream<_CharT, _Traits>&
447 basic_istream<_CharT, _Traits>::
448 ignore(streamsize __n)
451 sentry __cerb(*this, true);
452 if (__cerb && __n > 0)
454 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
457 const int_type __eof = traits_type::eof();
458 __streambuf_type* __sb = this->rdbuf();
459 int_type __c = __sb->sgetc();
461 // N.B. On LFS-enabled platforms streamsize is still 32 bits
462 // wide: if we want to implement the standard mandated behavior
463 // for n == max() (see 27.6.1.3/24) we are at risk of signed
464 // integer overflow: thus these contortions. Also note that,
465 // by definition, when more than 2G chars are actually ignored,
466 // _M_gcount (the return value of gcount, that is) cannot be
467 // really correct, being unavoidably too small.
468 bool __large_ignore = false;
471 while (_M_gcount < __n
472 && !traits_type::eq_int_type(__c, __eof))
475 __c = __sb->snextc();
477 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
478 && !traits_type::eq_int_type(__c, __eof))
481 __gnu_cxx::__numeric_traits<streamsize>::__min;
482 __large_ignore = true;
489 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
491 if (traits_type::eq_int_type(__c, __eof))
492 __err |= ios_base::eofbit;
494 catch(__cxxabiv1::__forced_unwind&)
496 this->_M_setstate(ios_base::badbit);
497 __throw_exception_again;
500 { this->_M_setstate(ios_base::badbit); }
502 this->setstate(__err);
507 template<typename _CharT, typename _Traits>
508 basic_istream<_CharT, _Traits>&
509 basic_istream<_CharT, _Traits>::
510 ignore(streamsize __n, int_type __delim)
513 sentry __cerb(*this, true);
514 if (__cerb && __n > 0)
516 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
519 const int_type __eof = traits_type::eof();
520 __streambuf_type* __sb = this->rdbuf();
521 int_type __c = __sb->sgetc();
523 // See comment above.
524 bool __large_ignore = false;
527 while (_M_gcount < __n
528 && !traits_type::eq_int_type(__c, __eof)
529 && !traits_type::eq_int_type(__c, __delim))
532 __c = __sb->snextc();
534 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
535 && !traits_type::eq_int_type(__c, __eof)
536 && !traits_type::eq_int_type(__c, __delim))
539 __gnu_cxx::__numeric_traits<streamsize>::__min;
540 __large_ignore = true;
547 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
549 if (traits_type::eq_int_type(__c, __eof))
550 __err |= ios_base::eofbit;
551 else if (traits_type::eq_int_type(__c, __delim))
554 < __gnu_cxx::__numeric_traits<streamsize>::__max)
559 catch(__cxxabiv1::__forced_unwind&)
561 this->_M_setstate(ios_base::badbit);
562 __throw_exception_again;
565 { this->_M_setstate(ios_base::badbit); }
567 this->setstate(__err);
572 template<typename _CharT, typename _Traits>
573 typename basic_istream<_CharT, _Traits>::int_type
574 basic_istream<_CharT, _Traits>::
577 int_type __c = traits_type::eof();
579 sentry __cerb(*this, true);
582 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
585 __c = this->rdbuf()->sgetc();
586 if (traits_type::eq_int_type(__c, traits_type::eof()))
587 __err |= ios_base::eofbit;
589 catch(__cxxabiv1::__forced_unwind&)
591 this->_M_setstate(ios_base::badbit);
592 __throw_exception_again;
595 { this->_M_setstate(ios_base::badbit); }
597 this->setstate(__err);
602 template<typename _CharT, typename _Traits>
603 basic_istream<_CharT, _Traits>&
604 basic_istream<_CharT, _Traits>::
605 read(char_type* __s, streamsize __n)
608 sentry __cerb(*this, true);
611 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
614 _M_gcount = this->rdbuf()->sgetn(__s, __n);
615 if (_M_gcount != __n)
616 __err |= (ios_base::eofbit | ios_base::failbit);
618 catch(__cxxabiv1::__forced_unwind&)
620 this->_M_setstate(ios_base::badbit);
621 __throw_exception_again;
624 { this->_M_setstate(ios_base::badbit); }
626 this->setstate(__err);
631 template<typename _CharT, typename _Traits>
633 basic_istream<_CharT, _Traits>::
634 readsome(char_type* __s, streamsize __n)
637 sentry __cerb(*this, true);
640 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
643 // Cannot compare int_type with streamsize generically.
644 const streamsize __num = this->rdbuf()->in_avail();
646 _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
647 else if (__num == -1)
648 __err |= ios_base::eofbit;
650 catch(__cxxabiv1::__forced_unwind&)
652 this->_M_setstate(ios_base::badbit);
653 __throw_exception_again;
656 { this->_M_setstate(ios_base::badbit); }
658 this->setstate(__err);
663 template<typename _CharT, typename _Traits>
664 basic_istream<_CharT, _Traits>&
665 basic_istream<_CharT, _Traits>::
666 putback(char_type __c)
668 // _GLIBCXX_RESOLVE_LIB_DEFECTS
669 // 60. What is a formatted input function?
671 sentry __cerb(*this, true);
674 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
677 const int_type __eof = traits_type::eof();
678 __streambuf_type* __sb = this->rdbuf();
680 || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
681 __err |= ios_base::badbit;
683 catch(__cxxabiv1::__forced_unwind&)
685 this->_M_setstate(ios_base::badbit);
686 __throw_exception_again;
689 { this->_M_setstate(ios_base::badbit); }
691 this->setstate(__err);
696 template<typename _CharT, typename _Traits>
697 basic_istream<_CharT, _Traits>&
698 basic_istream<_CharT, _Traits>::
701 // _GLIBCXX_RESOLVE_LIB_DEFECTS
702 // 60. What is a formatted input function?
704 sentry __cerb(*this, true);
707 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
710 const int_type __eof = traits_type::eof();
711 __streambuf_type* __sb = this->rdbuf();
713 || traits_type::eq_int_type(__sb->sungetc(), __eof))
714 __err |= ios_base::badbit;
716 catch(__cxxabiv1::__forced_unwind&)
718 this->_M_setstate(ios_base::badbit);
719 __throw_exception_again;
722 { this->_M_setstate(ios_base::badbit); }
724 this->setstate(__err);
729 template<typename _CharT, typename _Traits>
731 basic_istream<_CharT, _Traits>::
734 // _GLIBCXX_RESOLVE_LIB_DEFECTS
735 // DR60. Do not change _M_gcount.
737 sentry __cerb(*this, true);
740 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
743 __streambuf_type* __sb = this->rdbuf();
746 if (__sb->pubsync() == -1)
747 __err |= ios_base::badbit;
752 catch(__cxxabiv1::__forced_unwind&)
754 this->_M_setstate(ios_base::badbit);
755 __throw_exception_again;
758 { this->_M_setstate(ios_base::badbit); }
760 this->setstate(__err);
765 template<typename _CharT, typename _Traits>
766 typename basic_istream<_CharT, _Traits>::pos_type
767 basic_istream<_CharT, _Traits>::
770 // _GLIBCXX_RESOLVE_LIB_DEFECTS
771 // DR60. Do not change _M_gcount.
772 pos_type __ret = pos_type(-1);
776 __ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
779 catch(__cxxabiv1::__forced_unwind&)
781 this->_M_setstate(ios_base::badbit);
782 __throw_exception_again;
785 { this->_M_setstate(ios_base::badbit); }
789 template<typename _CharT, typename _Traits>
790 basic_istream<_CharT, _Traits>&
791 basic_istream<_CharT, _Traits>::
792 seekg(pos_type __pos)
794 // _GLIBCXX_RESOLVE_LIB_DEFECTS
795 // DR60. Do not change _M_gcount.
796 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
801 // 136. seekp, seekg setting wrong streams?
802 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
805 // 129. Need error indication from seekp() and seekg()
806 if (__p == pos_type(off_type(-1)))
807 __err |= ios_base::failbit;
810 catch(__cxxabiv1::__forced_unwind&)
812 this->_M_setstate(ios_base::badbit);
813 __throw_exception_again;
816 { this->_M_setstate(ios_base::badbit); }
818 this->setstate(__err);
822 template<typename _CharT, typename _Traits>
823 basic_istream<_CharT, _Traits>&
824 basic_istream<_CharT, _Traits>::
825 seekg(off_type __off, ios_base::seekdir __dir)
827 // _GLIBCXX_RESOLVE_LIB_DEFECTS
828 // DR60. Do not change _M_gcount.
829 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
834 // 136. seekp, seekg setting wrong streams?
835 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
838 // 129. Need error indication from seekp() and seekg()
839 if (__p == pos_type(off_type(-1)))
840 __err |= ios_base::failbit;
843 catch(__cxxabiv1::__forced_unwind&)
845 this->_M_setstate(ios_base::badbit);
846 __throw_exception_again;
849 { this->_M_setstate(ios_base::badbit); }
851 this->setstate(__err);
855 // 27.6.1.2.3 Character extraction templates
856 template<typename _CharT, typename _Traits>
857 basic_istream<_CharT, _Traits>&
858 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
860 typedef basic_istream<_CharT, _Traits> __istream_type;
861 typedef typename __istream_type::int_type __int_type;
863 typename __istream_type::sentry __cerb(__in, false);
866 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
869 const __int_type __cb = __in.rdbuf()->sbumpc();
870 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
871 __c = _Traits::to_char_type(__cb);
873 __err |= (ios_base::eofbit | ios_base::failbit);
875 catch(__cxxabiv1::__forced_unwind&)
877 __in._M_setstate(ios_base::badbit);
878 __throw_exception_again;
881 { __in._M_setstate(ios_base::badbit); }
883 __in.setstate(__err);
888 template<typename _CharT, typename _Traits>
889 basic_istream<_CharT, _Traits>&
890 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
892 typedef basic_istream<_CharT, _Traits> __istream_type;
893 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
894 typedef typename _Traits::int_type int_type;
895 typedef _CharT char_type;
896 typedef ctype<_CharT> __ctype_type;
898 streamsize __extracted = 0;
899 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
900 typename __istream_type::sentry __cerb(__in, false);
905 // Figure out how many characters to extract.
906 streamsize __num = __in.width();
908 __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
910 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
912 const int_type __eof = _Traits::eof();
913 __streambuf_type* __sb = __in.rdbuf();
914 int_type __c = __sb->sgetc();
916 while (__extracted < __num - 1
917 && !_Traits::eq_int_type(__c, __eof)
918 && !__ct.is(ctype_base::space,
919 _Traits::to_char_type(__c)))
921 *__s++ = _Traits::to_char_type(__c);
923 __c = __sb->snextc();
925 if (_Traits::eq_int_type(__c, __eof))
926 __err |= ios_base::eofbit;
928 // _GLIBCXX_RESOLVE_LIB_DEFECTS
929 // 68. Extractors for char* should store null at end
933 catch(__cxxabiv1::__forced_unwind&)
935 __in._M_setstate(ios_base::badbit);
936 __throw_exception_again;
939 { __in._M_setstate(ios_base::badbit); }
942 __err |= ios_base::failbit;
944 __in.setstate(__err);
948 // 27.6.1.4 Standard basic_istream manipulators
949 template<typename _CharT, typename _Traits>
950 basic_istream<_CharT, _Traits>&
951 ws(basic_istream<_CharT, _Traits>& __in)
953 typedef basic_istream<_CharT, _Traits> __istream_type;
954 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
955 typedef typename __istream_type::int_type __int_type;
956 typedef ctype<_CharT> __ctype_type;
958 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
959 const __int_type __eof = _Traits::eof();
960 __streambuf_type* __sb = __in.rdbuf();
961 __int_type __c = __sb->sgetc();
963 while (!_Traits::eq_int_type(__c, __eof)
964 && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
965 __c = __sb->snextc();
967 if (_Traits::eq_int_type(__c, __eof))
968 __in.setstate(ios_base::eofbit);
972 // Inhibit implicit instantiations for required instantiations,
973 // which are defined via explicit instantiations elsewhere.
974 // NB: This syntax is a GNU extension.
975 #if _GLIBCXX_EXTERN_TEMPLATE
976 extern template class basic_istream<char>;
977 extern template istream& ws(istream&);
978 extern template istream& operator>>(istream&, char&);
979 extern template istream& operator>>(istream&, char*);
980 extern template istream& operator>>(istream&, unsigned char&);
981 extern template istream& operator>>(istream&, signed char&);
982 extern template istream& operator>>(istream&, unsigned char*);
983 extern template istream& operator>>(istream&, signed char*);
985 extern template istream& istream::_M_extract(unsigned short&);
986 extern template istream& istream::_M_extract(unsigned int&);
987 extern template istream& istream::_M_extract(long&);
988 extern template istream& istream::_M_extract(unsigned long&);
989 extern template istream& istream::_M_extract(bool&);
990 #ifdef _GLIBCXX_USE_LONG_LONG
991 extern template istream& istream::_M_extract(long long&);
992 extern template istream& istream::_M_extract(unsigned long long&);
994 extern template istream& istream::_M_extract(float&);
995 extern template istream& istream::_M_extract(double&);
996 extern template istream& istream::_M_extract(long double&);
997 extern template istream& istream::_M_extract(void*&);
999 extern template class basic_iostream<char>;
1001 #ifdef _GLIBCXX_USE_WCHAR_T
1002 extern template class basic_istream<wchar_t>;
1003 extern template wistream& ws(wistream&);
1004 extern template wistream& operator>>(wistream&, wchar_t&);
1005 extern template wistream& operator>>(wistream&, wchar_t*);
1007 extern template wistream& wistream::_M_extract(unsigned short&);
1008 extern template wistream& wistream::_M_extract(unsigned int&);
1009 extern template wistream& wistream::_M_extract(long&);
1010 extern template wistream& wistream::_M_extract(unsigned long&);
1011 extern template wistream& wistream::_M_extract(bool&);
1012 #ifdef _GLIBCXX_USE_LONG_LONG
1013 extern template wistream& wistream::_M_extract(long long&);
1014 extern template wistream& wistream::_M_extract(unsigned long long&);
1016 extern template wistream& wistream::_M_extract(float&);
1017 extern template wistream& wistream::_M_extract(double&);
1018 extern template wistream& wistream::_M_extract(long double&);
1019 extern template wistream& wistream::_M_extract(void*&);
1021 extern template class basic_iostream<wchar_t>;
1025 _GLIBCXX_END_NAMESPACE