1 // istream classes -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009
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 3, 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 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 // <http://www.gnu.org/licenses/>.
28 * This is an internal header file, included by other library headers.
29 * You should not attempt to use it directly.
33 // ISO C++ 14882: 27.6.1 Input streams
37 #define _ISTREAM_TCC 1
39 #pragma GCC system_header
41 #include <cxxabi-forced.h>
43 _GLIBCXX_BEGIN_NAMESPACE(std)
45 template<typename _CharT, typename _Traits>
46 basic_istream<_CharT, _Traits>::sentry::
47 sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false)
49 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
54 if (!__noskip && bool(__in.flags() & ios_base::skipws))
56 const __int_type __eof = traits_type::eof();
57 __streambuf_type* __sb = __in.rdbuf();
58 __int_type __c = __sb->sgetc();
60 const __ctype_type& __ct = __check_facet(__in._M_ctype);
61 while (!traits_type::eq_int_type(__c, __eof)
62 && __ct.is(ctype_base::space,
63 traits_type::to_char_type(__c)))
66 // _GLIBCXX_RESOLVE_LIB_DEFECTS
67 // 195. Should basic_istream::sentry's constructor ever
69 if (traits_type::eq_int_type(__c, __eof))
70 __err |= ios_base::eofbit;
74 if (__in.good() && __err == ios_base::goodbit)
78 __err |= ios_base::failbit;
83 template<typename _CharT, typename _Traits>
84 template<typename _ValueT>
85 basic_istream<_CharT, _Traits>&
86 basic_istream<_CharT, _Traits>::
87 _M_extract(_ValueT& __v)
89 sentry __cerb(*this, false);
92 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
95 const __num_get_type& __ng = __check_facet(this->_M_num_get);
96 __ng.get(*this, 0, *this, __err, __v);
98 __catch(__cxxabiv1::__forced_unwind&)
100 this->_M_setstate(ios_base::badbit);
101 __throw_exception_again;
104 { this->_M_setstate(ios_base::badbit); }
106 this->setstate(__err);
111 template<typename _CharT, typename _Traits>
112 basic_istream<_CharT, _Traits>&
113 basic_istream<_CharT, _Traits>::
114 operator>>(short& __n)
116 // _GLIBCXX_RESOLVE_LIB_DEFECTS
117 // 118. basic_istream uses nonexistent num_get member functions.
122 if (__gnu_cxx::__numeric_traits<short>::__min <= __l
123 && __l <= __gnu_cxx::__numeric_traits<short>::__max)
126 this->setstate(ios_base::failbit);
131 template<typename _CharT, typename _Traits>
132 basic_istream<_CharT, _Traits>&
133 basic_istream<_CharT, _Traits>::
136 // _GLIBCXX_RESOLVE_LIB_DEFECTS
137 // 118. basic_istream uses nonexistent num_get member functions.
142 if (__gnu_cxx::__numeric_traits<int>::__min <= __l
143 && __l <= __gnu_cxx::__numeric_traits<int>::__max)
146 this->setstate(ios_base::failbit);
151 template<typename _CharT, typename _Traits>
152 basic_istream<_CharT, _Traits>&
153 basic_istream<_CharT, _Traits>::
154 operator>>(__streambuf_type* __sbout)
156 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
157 sentry __cerb(*this, false);
158 if (__cerb && __sbout)
163 if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
164 __err |= ios_base::failbit;
166 __err |= ios_base::eofbit;
168 __catch(__cxxabiv1::__forced_unwind&)
170 this->_M_setstate(ios_base::failbit);
171 __throw_exception_again;
174 { this->_M_setstate(ios_base::failbit); }
177 __err |= ios_base::failbit;
179 this->setstate(__err);
183 template<typename _CharT, typename _Traits>
184 typename basic_istream<_CharT, _Traits>::int_type
185 basic_istream<_CharT, _Traits>::
188 const int_type __eof = traits_type::eof();
189 int_type __c = __eof;
191 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
192 sentry __cerb(*this, true);
197 __c = this->rdbuf()->sbumpc();
198 // 27.6.1.1 paragraph 3
199 if (!traits_type::eq_int_type(__c, __eof))
202 __err |= ios_base::eofbit;
204 __catch(__cxxabiv1::__forced_unwind&)
206 this->_M_setstate(ios_base::badbit);
207 __throw_exception_again;
210 { this->_M_setstate(ios_base::badbit); }
213 __err |= ios_base::failbit;
215 this->setstate(__err);
219 template<typename _CharT, typename _Traits>
220 basic_istream<_CharT, _Traits>&
221 basic_istream<_CharT, _Traits>::
225 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
226 sentry __cerb(*this, true);
231 const int_type __cb = this->rdbuf()->sbumpc();
232 // 27.6.1.1 paragraph 3
233 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
236 __c = traits_type::to_char_type(__cb);
239 __err |= ios_base::eofbit;
241 __catch(__cxxabiv1::__forced_unwind&)
243 this->_M_setstate(ios_base::badbit);
244 __throw_exception_again;
247 { this->_M_setstate(ios_base::badbit); }
250 __err |= ios_base::failbit;
252 this->setstate(__err);
256 template<typename _CharT, typename _Traits>
257 basic_istream<_CharT, _Traits>&
258 basic_istream<_CharT, _Traits>::
259 get(char_type* __s, streamsize __n, char_type __delim)
262 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
263 sentry __cerb(*this, true);
268 const int_type __idelim = traits_type::to_int_type(__delim);
269 const int_type __eof = traits_type::eof();
270 __streambuf_type* __sb = this->rdbuf();
271 int_type __c = __sb->sgetc();
273 while (_M_gcount + 1 < __n
274 && !traits_type::eq_int_type(__c, __eof)
275 && !traits_type::eq_int_type(__c, __idelim))
277 *__s++ = traits_type::to_char_type(__c);
279 __c = __sb->snextc();
281 if (traits_type::eq_int_type(__c, __eof))
282 __err |= ios_base::eofbit;
284 __catch(__cxxabiv1::__forced_unwind&)
286 this->_M_setstate(ios_base::badbit);
287 __throw_exception_again;
290 { this->_M_setstate(ios_base::badbit); }
292 // _GLIBCXX_RESOLVE_LIB_DEFECTS
293 // 243. get and getline when sentry reports failure.
297 __err |= ios_base::failbit;
299 this->setstate(__err);
303 template<typename _CharT, typename _Traits>
304 basic_istream<_CharT, _Traits>&
305 basic_istream<_CharT, _Traits>::
306 get(__streambuf_type& __sb, char_type __delim)
309 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
310 sentry __cerb(*this, true);
315 const int_type __idelim = traits_type::to_int_type(__delim);
316 const int_type __eof = traits_type::eof();
317 __streambuf_type* __this_sb = this->rdbuf();
318 int_type __c = __this_sb->sgetc();
319 char_type __c2 = traits_type::to_char_type(__c);
321 while (!traits_type::eq_int_type(__c, __eof)
322 && !traits_type::eq_int_type(__c, __idelim)
323 && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
326 __c = __this_sb->snextc();
327 __c2 = traits_type::to_char_type(__c);
329 if (traits_type::eq_int_type(__c, __eof))
330 __err |= ios_base::eofbit;
332 __catch(__cxxabiv1::__forced_unwind&)
334 this->_M_setstate(ios_base::badbit);
335 __throw_exception_again;
338 { this->_M_setstate(ios_base::badbit); }
341 __err |= ios_base::failbit;
343 this->setstate(__err);
347 template<typename _CharT, typename _Traits>
348 basic_istream<_CharT, _Traits>&
349 basic_istream<_CharT, _Traits>::
350 getline(char_type* __s, streamsize __n, char_type __delim)
353 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
354 sentry __cerb(*this, true);
359 const int_type __idelim = traits_type::to_int_type(__delim);
360 const int_type __eof = traits_type::eof();
361 __streambuf_type* __sb = this->rdbuf();
362 int_type __c = __sb->sgetc();
364 while (_M_gcount + 1 < __n
365 && !traits_type::eq_int_type(__c, __eof)
366 && !traits_type::eq_int_type(__c, __idelim))
368 *__s++ = traits_type::to_char_type(__c);
369 __c = __sb->snextc();
372 if (traits_type::eq_int_type(__c, __eof))
373 __err |= ios_base::eofbit;
376 if (traits_type::eq_int_type(__c, __idelim))
382 __err |= ios_base::failbit;
385 __catch(__cxxabiv1::__forced_unwind&)
387 this->_M_setstate(ios_base::badbit);
388 __throw_exception_again;
391 { this->_M_setstate(ios_base::badbit); }
393 // _GLIBCXX_RESOLVE_LIB_DEFECTS
394 // 243. get and getline when sentry reports failure.
398 __err |= ios_base::failbit;
400 this->setstate(__err);
404 // We provide three overloads, since the first two are much simpler
405 // than the general case. Also, the latter two can thus adopt the
406 // same "batchy" strategy used by getline above.
407 template<typename _CharT, typename _Traits>
408 basic_istream<_CharT, _Traits>&
409 basic_istream<_CharT, _Traits>::
413 sentry __cerb(*this, true);
416 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
419 const int_type __eof = traits_type::eof();
420 __streambuf_type* __sb = this->rdbuf();
422 if (traits_type::eq_int_type(__sb->sbumpc(), __eof))
423 __err |= ios_base::eofbit;
427 __catch(__cxxabiv1::__forced_unwind&)
429 this->_M_setstate(ios_base::badbit);
430 __throw_exception_again;
433 { this->_M_setstate(ios_base::badbit); }
435 this->setstate(__err);
440 template<typename _CharT, typename _Traits>
441 basic_istream<_CharT, _Traits>&
442 basic_istream<_CharT, _Traits>::
443 ignore(streamsize __n)
446 sentry __cerb(*this, true);
447 if (__cerb && __n > 0)
449 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
452 const int_type __eof = traits_type::eof();
453 __streambuf_type* __sb = this->rdbuf();
454 int_type __c = __sb->sgetc();
456 // N.B. On LFS-enabled platforms streamsize is still 32 bits
457 // wide: if we want to implement the standard mandated behavior
458 // for n == max() (see 27.6.1.3/24) we are at risk of signed
459 // integer overflow: thus these contortions. Also note that,
460 // by definition, when more than 2G chars are actually ignored,
461 // _M_gcount (the return value of gcount, that is) cannot be
462 // really correct, being unavoidably too small.
463 bool __large_ignore = false;
466 while (_M_gcount < __n
467 && !traits_type::eq_int_type(__c, __eof))
470 __c = __sb->snextc();
472 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
473 && !traits_type::eq_int_type(__c, __eof))
476 __gnu_cxx::__numeric_traits<streamsize>::__min;
477 __large_ignore = true;
484 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
486 if (traits_type::eq_int_type(__c, __eof))
487 __err |= ios_base::eofbit;
489 __catch(__cxxabiv1::__forced_unwind&)
491 this->_M_setstate(ios_base::badbit);
492 __throw_exception_again;
495 { this->_M_setstate(ios_base::badbit); }
497 this->setstate(__err);
502 template<typename _CharT, typename _Traits>
503 basic_istream<_CharT, _Traits>&
504 basic_istream<_CharT, _Traits>::
505 ignore(streamsize __n, int_type __delim)
508 sentry __cerb(*this, true);
509 if (__cerb && __n > 0)
511 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
514 const int_type __eof = traits_type::eof();
515 __streambuf_type* __sb = this->rdbuf();
516 int_type __c = __sb->sgetc();
518 // See comment above.
519 bool __large_ignore = false;
522 while (_M_gcount < __n
523 && !traits_type::eq_int_type(__c, __eof)
524 && !traits_type::eq_int_type(__c, __delim))
527 __c = __sb->snextc();
529 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
530 && !traits_type::eq_int_type(__c, __eof)
531 && !traits_type::eq_int_type(__c, __delim))
534 __gnu_cxx::__numeric_traits<streamsize>::__min;
535 __large_ignore = true;
542 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
544 if (traits_type::eq_int_type(__c, __eof))
545 __err |= ios_base::eofbit;
546 else if (traits_type::eq_int_type(__c, __delim))
549 < __gnu_cxx::__numeric_traits<streamsize>::__max)
554 __catch(__cxxabiv1::__forced_unwind&)
556 this->_M_setstate(ios_base::badbit);
557 __throw_exception_again;
560 { this->_M_setstate(ios_base::badbit); }
562 this->setstate(__err);
567 template<typename _CharT, typename _Traits>
568 typename basic_istream<_CharT, _Traits>::int_type
569 basic_istream<_CharT, _Traits>::
572 int_type __c = traits_type::eof();
574 sentry __cerb(*this, true);
577 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
580 __c = this->rdbuf()->sgetc();
581 if (traits_type::eq_int_type(__c, traits_type::eof()))
582 __err |= ios_base::eofbit;
584 __catch(__cxxabiv1::__forced_unwind&)
586 this->_M_setstate(ios_base::badbit);
587 __throw_exception_again;
590 { this->_M_setstate(ios_base::badbit); }
592 this->setstate(__err);
597 template<typename _CharT, typename _Traits>
598 basic_istream<_CharT, _Traits>&
599 basic_istream<_CharT, _Traits>::
600 read(char_type* __s, streamsize __n)
603 sentry __cerb(*this, true);
606 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
609 _M_gcount = this->rdbuf()->sgetn(__s, __n);
610 if (_M_gcount != __n)
611 __err |= (ios_base::eofbit | ios_base::failbit);
613 __catch(__cxxabiv1::__forced_unwind&)
615 this->_M_setstate(ios_base::badbit);
616 __throw_exception_again;
619 { this->_M_setstate(ios_base::badbit); }
621 this->setstate(__err);
626 template<typename _CharT, typename _Traits>
628 basic_istream<_CharT, _Traits>::
629 readsome(char_type* __s, streamsize __n)
632 sentry __cerb(*this, true);
635 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
638 // Cannot compare int_type with streamsize generically.
639 const streamsize __num = this->rdbuf()->in_avail();
641 _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
642 else if (__num == -1)
643 __err |= ios_base::eofbit;
645 __catch(__cxxabiv1::__forced_unwind&)
647 this->_M_setstate(ios_base::badbit);
648 __throw_exception_again;
651 { this->_M_setstate(ios_base::badbit); }
653 this->setstate(__err);
658 template<typename _CharT, typename _Traits>
659 basic_istream<_CharT, _Traits>&
660 basic_istream<_CharT, _Traits>::
661 putback(char_type __c)
663 // _GLIBCXX_RESOLVE_LIB_DEFECTS
664 // 60. What is a formatted input function?
666 sentry __cerb(*this, true);
669 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
672 const int_type __eof = traits_type::eof();
673 __streambuf_type* __sb = this->rdbuf();
675 || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
676 __err |= ios_base::badbit;
678 __catch(__cxxabiv1::__forced_unwind&)
680 this->_M_setstate(ios_base::badbit);
681 __throw_exception_again;
684 { this->_M_setstate(ios_base::badbit); }
686 this->setstate(__err);
691 template<typename _CharT, typename _Traits>
692 basic_istream<_CharT, _Traits>&
693 basic_istream<_CharT, _Traits>::
696 // _GLIBCXX_RESOLVE_LIB_DEFECTS
697 // 60. What is a formatted input function?
699 sentry __cerb(*this, true);
702 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
705 const int_type __eof = traits_type::eof();
706 __streambuf_type* __sb = this->rdbuf();
708 || traits_type::eq_int_type(__sb->sungetc(), __eof))
709 __err |= ios_base::badbit;
711 __catch(__cxxabiv1::__forced_unwind&)
713 this->_M_setstate(ios_base::badbit);
714 __throw_exception_again;
717 { this->_M_setstate(ios_base::badbit); }
719 this->setstate(__err);
724 template<typename _CharT, typename _Traits>
726 basic_istream<_CharT, _Traits>::
729 // _GLIBCXX_RESOLVE_LIB_DEFECTS
730 // DR60. Do not change _M_gcount.
732 sentry __cerb(*this, true);
735 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
738 __streambuf_type* __sb = this->rdbuf();
741 if (__sb->pubsync() == -1)
742 __err |= ios_base::badbit;
747 __catch(__cxxabiv1::__forced_unwind&)
749 this->_M_setstate(ios_base::badbit);
750 __throw_exception_again;
753 { this->_M_setstate(ios_base::badbit); }
755 this->setstate(__err);
760 template<typename _CharT, typename _Traits>
761 typename basic_istream<_CharT, _Traits>::pos_type
762 basic_istream<_CharT, _Traits>::
765 // _GLIBCXX_RESOLVE_LIB_DEFECTS
766 // DR60. Do not change _M_gcount.
767 pos_type __ret = pos_type(-1);
771 __ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
774 __catch(__cxxabiv1::__forced_unwind&)
776 this->_M_setstate(ios_base::badbit);
777 __throw_exception_again;
780 { this->_M_setstate(ios_base::badbit); }
784 template<typename _CharT, typename _Traits>
785 basic_istream<_CharT, _Traits>&
786 basic_istream<_CharT, _Traits>::
787 seekg(pos_type __pos)
789 // _GLIBCXX_RESOLVE_LIB_DEFECTS
790 // DR60. Do not change _M_gcount.
791 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
796 // 136. seekp, seekg setting wrong streams?
797 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
800 // 129. Need error indication from seekp() and seekg()
801 if (__p == pos_type(off_type(-1)))
802 __err |= ios_base::failbit;
805 __catch(__cxxabiv1::__forced_unwind&)
807 this->_M_setstate(ios_base::badbit);
808 __throw_exception_again;
811 { this->_M_setstate(ios_base::badbit); }
813 this->setstate(__err);
817 template<typename _CharT, typename _Traits>
818 basic_istream<_CharT, _Traits>&
819 basic_istream<_CharT, _Traits>::
820 seekg(off_type __off, ios_base::seekdir __dir)
822 // _GLIBCXX_RESOLVE_LIB_DEFECTS
823 // DR60. Do not change _M_gcount.
824 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
829 // 136. seekp, seekg setting wrong streams?
830 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
833 // 129. Need error indication from seekp() and seekg()
834 if (__p == pos_type(off_type(-1)))
835 __err |= ios_base::failbit;
838 __catch(__cxxabiv1::__forced_unwind&)
840 this->_M_setstate(ios_base::badbit);
841 __throw_exception_again;
844 { this->_M_setstate(ios_base::badbit); }
846 this->setstate(__err);
850 // 27.6.1.2.3 Character extraction templates
851 template<typename _CharT, typename _Traits>
852 basic_istream<_CharT, _Traits>&
853 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
855 typedef basic_istream<_CharT, _Traits> __istream_type;
856 typedef typename __istream_type::int_type __int_type;
858 typename __istream_type::sentry __cerb(__in, false);
861 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
864 const __int_type __cb = __in.rdbuf()->sbumpc();
865 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
866 __c = _Traits::to_char_type(__cb);
868 __err |= (ios_base::eofbit | ios_base::failbit);
870 __catch(__cxxabiv1::__forced_unwind&)
872 __in._M_setstate(ios_base::badbit);
873 __throw_exception_again;
876 { __in._M_setstate(ios_base::badbit); }
878 __in.setstate(__err);
883 template<typename _CharT, typename _Traits>
884 basic_istream<_CharT, _Traits>&
885 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
887 typedef basic_istream<_CharT, _Traits> __istream_type;
888 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
889 typedef typename _Traits::int_type int_type;
890 typedef _CharT char_type;
891 typedef ctype<_CharT> __ctype_type;
893 streamsize __extracted = 0;
894 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
895 typename __istream_type::sentry __cerb(__in, false);
900 // Figure out how many characters to extract.
901 streamsize __num = __in.width();
903 __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
905 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
907 const int_type __eof = _Traits::eof();
908 __streambuf_type* __sb = __in.rdbuf();
909 int_type __c = __sb->sgetc();
911 while (__extracted < __num - 1
912 && !_Traits::eq_int_type(__c, __eof)
913 && !__ct.is(ctype_base::space,
914 _Traits::to_char_type(__c)))
916 *__s++ = _Traits::to_char_type(__c);
918 __c = __sb->snextc();
920 if (_Traits::eq_int_type(__c, __eof))
921 __err |= ios_base::eofbit;
923 // _GLIBCXX_RESOLVE_LIB_DEFECTS
924 // 68. Extractors for char* should store null at end
928 __catch(__cxxabiv1::__forced_unwind&)
930 __in._M_setstate(ios_base::badbit);
931 __throw_exception_again;
934 { __in._M_setstate(ios_base::badbit); }
937 __err |= ios_base::failbit;
939 __in.setstate(__err);
943 // 27.6.1.4 Standard basic_istream manipulators
944 template<typename _CharT, typename _Traits>
945 basic_istream<_CharT, _Traits>&
946 ws(basic_istream<_CharT, _Traits>& __in)
948 typedef basic_istream<_CharT, _Traits> __istream_type;
949 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
950 typedef typename __istream_type::int_type __int_type;
951 typedef ctype<_CharT> __ctype_type;
953 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
954 const __int_type __eof = _Traits::eof();
955 __streambuf_type* __sb = __in.rdbuf();
956 __int_type __c = __sb->sgetc();
958 while (!_Traits::eq_int_type(__c, __eof)
959 && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
960 __c = __sb->snextc();
962 if (_Traits::eq_int_type(__c, __eof))
963 __in.setstate(ios_base::eofbit);
967 // Inhibit implicit instantiations for required instantiations,
968 // which are defined via explicit instantiations elsewhere.
969 // NB: This syntax is a GNU extension.
970 #if _GLIBCXX_EXTERN_TEMPLATE
971 extern template class basic_istream<char>;
972 extern template istream& ws(istream&);
973 extern template istream& operator>>(istream&, char&);
974 extern template istream& operator>>(istream&, char*);
975 extern template istream& operator>>(istream&, unsigned char&);
976 extern template istream& operator>>(istream&, signed char&);
977 extern template istream& operator>>(istream&, unsigned char*);
978 extern template istream& operator>>(istream&, signed char*);
980 extern template istream& istream::_M_extract(unsigned short&);
981 extern template istream& istream::_M_extract(unsigned int&);
982 extern template istream& istream::_M_extract(long&);
983 extern template istream& istream::_M_extract(unsigned long&);
984 extern template istream& istream::_M_extract(bool&);
985 #ifdef _GLIBCXX_USE_LONG_LONG
986 extern template istream& istream::_M_extract(long long&);
987 extern template istream& istream::_M_extract(unsigned long long&);
989 extern template istream& istream::_M_extract(float&);
990 extern template istream& istream::_M_extract(double&);
991 extern template istream& istream::_M_extract(long double&);
992 extern template istream& istream::_M_extract(void*&);
994 extern template class basic_iostream<char>;
996 #ifdef _GLIBCXX_USE_WCHAR_T
997 extern template class basic_istream<wchar_t>;
998 extern template wistream& ws(wistream&);
999 extern template wistream& operator>>(wistream&, wchar_t&);
1000 extern template wistream& operator>>(wistream&, wchar_t*);
1002 extern template wistream& wistream::_M_extract(unsigned short&);
1003 extern template wistream& wistream::_M_extract(unsigned int&);
1004 extern template wistream& wistream::_M_extract(long&);
1005 extern template wistream& wistream::_M_extract(unsigned long&);
1006 extern template wistream& wistream::_M_extract(bool&);
1007 #ifdef _GLIBCXX_USE_LONG_LONG
1008 extern template wistream& wistream::_M_extract(long long&);
1009 extern template wistream& wistream::_M_extract(unsigned long long&);
1011 extern template wistream& wistream::_M_extract(float&);
1012 extern template wistream& wistream::_M_extract(double&);
1013 extern template wistream& wistream::_M_extract(long double&);
1014 extern template wistream& wistream::_M_extract(void*&);
1016 extern template class basic_iostream<wchar_t>;
1020 _GLIBCXX_END_NAMESPACE