OSDN Git Service

2003-04-12 Paolo Carlini <pcarlini@unitus.it>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / std / std_istream.h
1 // Input streams -*- C++ -*-
2
3 // Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 //
32 // ISO C++ 14882: 27.6.1  Input streams
33 //
34
35 /** @file istream
36  *  This is a Standard C++ Library header.  You should @c #include this header
37  *  in your programs, rather than any of the "st[dl]_*.h" implementation files.
38  */
39
40 #ifndef _CPP_ISTREAM
41 #define _CPP_ISTREAM    1
42
43 #pragma GCC system_header
44
45 #include <ios>
46 #include <limits> // For numeric_limits
47
48 namespace std
49 {
50   // [27.6.1.1] Template class basic_istream
51   /**
52    *  @brief  Controlling input.
53    *
54    *  This is the base class for all input streams.  It provides text
55    *  formatting of all builtin types, and communicates with any class
56    *  derived from basic_streambuf to do the actual input.
57   */
58   template<typename _CharT, typename _Traits>
59     class basic_istream : virtual public basic_ios<_CharT, _Traits>
60     {
61     public:
62       // Types (inherited from basic_ios (27.4.4)):
63       typedef _CharT                                    char_type;
64       typedef typename _Traits::int_type                int_type;
65       typedef typename _Traits::pos_type                pos_type;
66       typedef typename _Traits::off_type                off_type;
67       typedef _Traits                                   traits_type;
68       
69       // Non-standard Types:
70       typedef basic_streambuf<_CharT, _Traits>          __streambuf_type;
71       typedef basic_ios<_CharT, _Traits>                __ios_type;
72       typedef basic_istream<_CharT, _Traits>            __istream_type;
73       typedef istreambuf_iterator<_CharT, _Traits>      __istreambuf_iter;
74       typedef num_get<_CharT, __istreambuf_iter>        __numget_type;
75       typedef ctype<_CharT>                             __ctype_type;
76
77       template<typename _CharT2, typename _Traits2>
78         friend basic_istream<_CharT2, _Traits2>&
79         operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
80  
81       template<typename _CharT2, typename _Traits2>
82         friend basic_istream<_CharT2, _Traits2>&
83         operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
84  
85     protected:
86       // Data Members:
87       /**
88        *  @if maint
89        *  The number of characters extracted in the previous unformatted
90        *  function; see gcount().
91        *  @endif
92       */
93       streamsize                _M_gcount;
94
95     public:
96       // [27.6.1.1.1] constructor/destructor
97       /**
98        *  @brief  Base constructor.
99        *
100        *  This ctor is almost never called by the user directly, rather from
101        *  derived classes' initialization lists, which pass a pointer to
102        *  their own stream buffer.
103       */
104       explicit 
105       basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
106       { this->init(__sb); }
107
108       /**
109        *  @brief  Base destructor.
110        *
111        *  This does very little apart from providing a virtual base dtor.
112       */
113       virtual 
114       ~basic_istream() 
115       { _M_gcount = streamsize(0); }
116
117       // [27.6.1.1.2] prefix/suffix
118       class sentry;
119       friend class sentry;
120
121       // [27.6.1.2] formatted input
122       // [27.6.1.2.3] basic_istream::operator>>
123       //@{
124       /**
125        *  @brief  Interface for manipulators.
126        *
127        *  Manuipulators such as @c std::ws and @c std::dec use these
128        *  functions in constructs like "std::cin >> std::ws".  For more
129        *  information, see the iomanip header.
130       */
131       __istream_type&
132       operator>>(__istream_type& (*__pf)(__istream_type&));
133
134       __istream_type&
135       operator>>(__ios_type& (*__pf)(__ios_type&));
136
137       __istream_type&
138       operator>>(ios_base& (*__pf)(ios_base&));
139       //@}
140       
141       // [27.6.1.2.2] arithmetic extractors
142       /**
143        *  @name Arithmetic Extractors
144        *
145        *  All the @c operator>> functions (aka <em>formatted input
146        *  functions</em>) have some common behavior.  Each starts by
147        *  constructing a temporary object of type std::basic_istream::sentry
148        *  with the second argument (noskipws) set to false.  This has several
149        *  effects, concluding with the setting of a status flag; see the
150        *  sentry documentation for more.
151        *
152        *  If the sentry status is good, the function tries to extract
153        *  whatever data is appropriate for the type of the argument.
154        *
155        *  If an exception is thrown during extraction, ios_base::badbit
156        *  will be turned on in the stream's error state without causing an
157        *  ios_base::failure to be thrown.  The original exception will then
158        *  be rethrown.
159       */
160       //@{
161       /**
162        *  @brief  Basic arithmetic extractors
163        *  @param  A variable of builtin type.
164        *  @return  @c *this if successful
165        *
166        *  These functions use the stream's current locale (specifically, the
167        *  @c num_get facet) to parse the input data.
168       */
169       __istream_type& 
170       operator>>(bool& __n);
171       
172       __istream_type& 
173       operator>>(short& __n);
174       
175       __istream_type& 
176       operator>>(unsigned short& __n);
177
178       __istream_type& 
179       operator>>(int& __n);
180       
181       __istream_type& 
182       operator>>(unsigned int& __n);
183
184       __istream_type& 
185       operator>>(long& __n);
186       
187       __istream_type& 
188       operator>>(unsigned long& __n);
189
190 #ifdef _GLIBCPP_USE_LONG_LONG
191       __istream_type& 
192       operator>>(long long& __n);
193
194       __istream_type& 
195       operator>>(unsigned long long& __n);
196 #endif
197
198       __istream_type& 
199       operator>>(float& __f);
200
201       __istream_type& 
202       operator>>(double& __f);
203
204       __istream_type& 
205       operator>>(long double& __f);
206
207       __istream_type& 
208       operator>>(void*& __p);
209
210       /**
211        *  @brief  Extracting into another streambuf.
212        *  @param  sb  A pointer to a streambuf
213        *
214        *  This function behaves like one of the basic arithmetic extractors,
215        *  in that it also constructs a sentry onject and has the same error
216        *  handling behavior.
217        *
218        *  If @a sb is NULL, the stream will set failbit in its error state.
219        *
220        *  Characters are extracted from this stream and inserted into the
221        *  @a sb streambuf until one of the following occurs:
222        *
223        *  - the input stream reaches end-of-file,
224        *  - insertion into the output buffer fails (in this case, the
225        *    character that would have been inserted is not extracted), or
226        *  - an exception occurs (and in this case is caught)
227        *
228        *  If the function inserts no characters, failbit is set.
229       */
230       __istream_type& 
231       operator>>(__streambuf_type* __sb);
232       //@}
233       
234       // [27.6.1.3] unformatted input
235       /**
236        *  @brief  Character counting
237        *  @return  The number of characters extracted by the previous
238        *           unformatted input function dispatched for this stream.
239       */
240       inline streamsize 
241       gcount() const 
242       { return _M_gcount; }
243       
244       /**
245        *  @name Unformatted Input Functions
246        *
247        *  All the unformatted input functions have some common behavior.
248        *  Each starts by constructing a temporary object of type
249        *  std::basic_istream::sentry with the second argument (noskipws)
250        *  set to true.  This has several effects, concluding with the
251        *  setting of a status flag; see the sentry documentation for more.
252        *
253        *  If the sentry status is good, the function tries to extract
254        *  whatever data is appropriate for the type of the argument.
255        *
256        *  The number of characters extracted is stored for later retrieval
257        *  by gcount().
258        *
259        *  If an exception is thrown during extraction, ios_base::badbit
260        *  will be turned on in the stream's error state without causing an
261        *  ios_base::failure to be thrown.  The original exception will then
262        *  be rethrown.
263       */
264       //@{
265       /**
266        *  @brief  Simple extraction.
267        *  @return  A character, or eof().
268        *
269        *  Tries to extract a character.  If none are available, sets failbit
270        *  and returns traits::eof().
271       */
272       int_type 
273       get();
274
275       /**
276        *  @brief  Simple extraction.
277        *  @param  c  The character in which to store data.
278        *  @return  *this
279        *
280        *  Tries to extract a character and store it in @a c.  If none are
281        *  available, sets failbit and returns traits::eof().
282        *
283        *  @note  This function is not overloaded on signed char and
284        *         unsigned char.
285       */
286       __istream_type& 
287       get(char_type& __c);
288
289       /**
290        *  @brief  Simple multiple-character extraction.
291        *  @param  s  Pointer to an array.
292        *  @param  n  Maximum number of characters to store in @a s.
293        *  @param  delim  A "stop" character.
294        *  @return  *this
295        *
296        *  Characters are extracted and stored into @a s until one of the
297        *  following happens:
298        *
299        *  - @c n-1 characters are stored
300        *  - the input sequence reaches EOF
301        *  - the next character equals @a delim, in which case the character
302        *    is not extracted
303        *
304        * If no characters are stored, failbit is set in the stream's error
305        * state.
306        *
307        * In any case, a null character is stored into the next location in
308        * the array.
309        *
310        *  @note  This function is not overloaded on signed char and
311        *         unsigned char.
312       */
313       __istream_type& 
314       get(char_type* __s, streamsize __n, char_type __delim);
315
316       /**
317        *  @brief  Simple multiple-character extraction.
318        *  @param  s  Pointer to an array.
319        *  @param  n  Maximum number of characters to store in @a s.
320        *  @return  *this
321        *
322        *  Returns @c get(s,n,widen('\n')).
323       */
324       inline __istream_type& 
325       get(char_type* __s, streamsize __n)
326       { return this->get(__s, __n, this->widen('\n')); }
327
328       /**
329        *  @brief  Extraction into another streambuf.
330        *  @param  sb  A streambuf in which to store data.
331        *  @param  delim  A "stop" character.
332        *  @return  *this
333        *
334        *  Characters are extracted and inserted into @a sb until one of the
335        *  following happens:
336        *
337        *  - the input sequence reaches EOF
338        *  - insertion into the output buffer fails (in this case, the
339        *    character that would have been inserted is not extracted)
340        *  - the next character equals @a delim (in this case, the character
341        *    is not extracted)
342        *  - an exception occurs (and in this case is caught)
343        *
344        * If no characters are stored, failbit is set in the stream's error
345        * state.
346       */
347       __istream_type&
348       get(__streambuf_type& __sb, char_type __delim);
349
350       /**
351        *  @brief  Extraction into another streambuf.
352        *  @param  sb  A streambuf in which to store data.
353        *  @return  *this
354        *
355        *  Returns @c get(sb,widen('\n')).
356       */
357       inline __istream_type&
358       get(__streambuf_type& __sb)
359       { return this->get(__sb, this->widen('\n')); }
360
361       /**
362        *  @brief  String extraction.
363        *  @param  s  A character array in which to store the data.
364        *  @param  n  Maximum number of characters to extract.
365        *  @param  delim  A "stop" character.
366        *  @return  *this
367        *
368        *  Extracts and stores characters into @a s until one of the
369        *  following happens.  Note that these criteria are required to be
370        *  tested in the order listed here, to allow an input line to exactly
371        *  fill the @a s array without setting failbit.
372        *
373        *  -# the input sequence reaches end-of-file, in which case eofbit
374        *     is set in the stream error state
375        *  -# the next character equals @c delim, in which case the character
376        *     is extracted (and therefore counted in @c gcount()) but not stored
377        *  -# @c n-1 characters are stored, in which case failbit is set
378        *     in the stream error state
379        *
380        *  If no characters are extracted, failbit is set.  (An empty line of
381        *  input should therefore not cause failbit to be set.)
382        *
383        *  In any case, a null character is stored in the next location in
384        *  the array.
385       */
386       __istream_type& 
387       getline(char_type* __s, streamsize __n, char_type __delim);
388
389       /**
390        *  @brief  String extraction.
391        *  @param  s  A character array in which to store the data.
392        *  @param  n  Maximum number of characters to extract.
393        *  @return  *this
394        *
395        *  Returns @c getline(s,n,widen('\n')).
396       */
397       inline __istream_type& 
398       getline(char_type* __s, streamsize __n)
399       { return this->getline(__s, __n, this->widen('\n')); }
400
401       /**
402        *  @brief  Discarding characters
403        *  @param  n  Number of characters to discard.
404        *  @param  delim  A "stop" character.
405        *  @return  *this
406        *
407        *  Extracts characters and throws them away until one of the
408        *  following happens:
409        *  - if @a n @c != @c std::numeric_limits<int>::max(), @a n
410        *    characters are extracted
411        *  - the input sequence reaches end-of-file
412        *  - the next character equals @a delim (in this case, the character
413        *    is extracted); note that this condition will never occur if
414        *    @a delim equals @c traits::eof().
415       */
416       __istream_type& 
417       ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
418       
419       /**
420        *  @brief  Looking ahead in the stream
421        *  @return  The next character, or eof().
422        *
423        *  If, after constructing the sentry object, @c good() is false,
424        *  returns @c traits::eof().  Otherwise reads but does not extract
425        *  the next input character.
426       */
427       int_type 
428       peek();
429       
430       /**
431        *  @brief  Extraction without delimiters.
432        *  @param  s  A character array.
433        *  @param  n  Maximum number of characters to store.
434        *  @return  *this
435        *
436        *  If the stream state is @c good(), extracts characters and stores
437        *  them into @a s until one of the following happens:
438        *  - @a n characters are stored
439        *  - the input sequence reaches end-of-file, in which case the error
440        *    state is set to @c failbit|eofbit.
441        *
442        *  @note  This function is not overloaded on signed char and
443        *         unsigned char.
444       */
445       __istream_type& 
446       read(char_type* __s, streamsize __n);
447
448       /**
449        *  @brief  Extraction until the buffer is exhausted, but no more.
450        *  @param  s  A character array.
451        *  @param  n  Maximum number of characters to store.
452        *  @return  The number of characters extracted.
453        *
454        *  Extracts characters and stores them into @a s depending on the
455        *  number of characters remaining in the streambuf's buffer,
456        *  @c rdbuf()->in_avail(), called @c A here:
457        *  - if @c A @c == @c -1, sets eofbit and extracts no characters
458        *  - if @c A @c == @c 0, extracts no characters
459        *  - if @c A @c > @c 0, extracts @c min(A,n)
460        *
461        *  The goal is to empty the current buffer, and to not request any
462        *  more from the external input sequence controlled by the streambuf.
463       */
464       streamsize 
465       readsome(char_type* __s, streamsize __n);
466       
467       /**
468        *  @brief  Unextracting a single character.
469        *  @param  c  The character to push back into the input stream.
470        *  @return  *this
471        *
472        *  If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
473        *
474        *  If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
475        *  the error state.
476        *
477        *  @note  Since no characters are extracted, the next call to
478        *         @c gcount() will return 0, as required by DR 60.
479        *
480        *  @if maint
481        *  FIXME We don't comply with DR 60 here, _M_gcount is untouched.
482        *  @endif
483       */
484       __istream_type& 
485       putback(char_type __c);
486
487       /**
488        *  @brief  Unextracting the previous character.
489        *  @return  *this
490        *
491        *  If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
492        *
493        *  If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
494        *  the error state.
495        *
496        *  @note  Since no characters are extracted, the next call to
497        *         @c gcount() will return 0, as required by DR 60.
498       */
499       __istream_type& 
500       unget();
501
502       /**
503        *  @brief  Synchronizing the stream buffer.
504        *  @return  0 on success, -1 on failure
505        *
506        *  If @c rdbuf() is a null pointer, returns -1.
507        *
508        *  Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
509        *  sets badbit and returns -1.
510        *
511        *  Otherwise, returns 0.
512        *
513        *  @note  This function does not count the number of characters
514        *         extracted, if any, and therefore does not affect the next
515        *         call to @c gcount().
516        *  @if maint
517        *  FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
518        *  @endif
519       */
520       int 
521       sync();
522
523       /**
524        *  @brief  Getting the current read position.
525        *  @return  A file position object.
526        *
527        *  If @c fail() is not false, returns @c pos_type(-1) to indicate
528        *  failure.  Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
529        *
530        *  @note  This function does not count the number of characters
531        *         extracted, if any, and therefore does not affect the next
532        *         call to @c gcount().
533       */
534       pos_type 
535       tellg();
536
537       /**
538        *  @brief  Changing the current read position.
539        *  @param  pos  A file position object.
540        *  @return  *this
541        *
542        *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos).  If
543        *  that function fails, sets failbit.
544        *
545        *  @note  This function does not count the number of characters
546        *         extracted, if any, and therefore does not affect the next
547        *         call to @c gcount().
548        *  @if maint
549        *  FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
550        *  @endif
551       */
552       __istream_type& 
553       seekg(pos_type);
554
555       /**
556        *  @brief  Changing the current read position.
557        *  @param  off  A file offset object.
558        *  @param  dir  The direction in which to seek.
559        *  @return  *this
560        *
561        *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
562        *  If that function fails, sets failbit.
563        *
564        *  @note  This function does not count the number of characters
565        *         extracted, if any, and therefore does not affect the next
566        *         call to @c gcount().
567        *  @if maint
568        *  FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
569        *  @endif
570       */
571       __istream_type& 
572       seekg(off_type, ios_base::seekdir);
573       //@}
574
575     protected:
576       explicit 
577       basic_istream(): _M_gcount(streamsize(0)) { }
578     };
579   
580   /**
581    *  @brief  Performs setup work for input streams.
582    *
583    *  Objects of this class are created before all of the standard
584    *  extractors are run.  It is responsible for "exception-safe prefix and
585    *  suffix operations," although only prefix actions are currently required
586    *  by the standard.  Additional actions may be added by the
587    *  implementation, and we list them in
588    *  http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
589    *  under [27.6] notes.
590   */
591   template<typename _CharT, typename _Traits>
592     class basic_istream<_CharT, _Traits>::sentry
593     {
594     public:
595       /// Easy access to dependant types.
596       typedef _Traits                                   traits_type;
597       typedef basic_streambuf<_CharT, _Traits>          __streambuf_type;
598       typedef basic_istream<_CharT, _Traits>            __istream_type;
599       typedef typename __istream_type::__ctype_type     __ctype_type;
600       typedef typename _Traits::int_type                __int_type;
601
602       /**
603        *  @brief  The constructor performs all the work.
604        *  @param  is  The input stream to guard.
605        *  @param  noskipws  Whether to consume whitespace or not.
606        *
607        *  If the stream state is good (@a is.good() is true), then the
608        *  following actions are performed, otherwise the sentry state is
609        *  false ("not okay") and failbit is set in the stream state.
610        *
611        *  The sentry's preparatory actions are:
612        *
613        *  -# if the stream is tied to an output stream, @c is.tie()->flush()
614        *     is called to synchronize the output sequence
615        *  -# if @a noskipws is false, and @c ios_base::skipws is set in
616        *     @c is.flags(), the sentry extracts and discards whitespace
617        *     characters from the stream.  The currently imbued locale is
618        *     used to determine whether each character is whitespace.
619        *
620        *  If the stream state is still good, then the sentry state becomes
621        *  true ("okay").
622       */
623       explicit 
624       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
625
626       /**
627        *  @brief  Quick status checking.
628        *  @return  The sentry state.
629        *
630        *  For ease of use, sentries may be converted to booleans.  The
631        *  return value is that of the sentry state (true == okay).
632       */
633       operator bool() const { return _M_ok; }
634
635     private:
636       bool _M_ok;
637     };
638
639   // [27.6.1.2.3] character extraction templates
640   //@{
641   /**
642    *  @brief  Character extractors
643    *  @param  in  An input stream.
644    *  @param  c  A character reference.
645    *  @return  in
646    *
647    *  Behaves like one of the formatted arithmetic extractors described in
648    *  std::basic_istream.  After constructing a sentry object with good
649    *  status, this function extracts a character (if one is available) and
650    *  stores it in @a c.  Otherwise, sets failbit in the input stream.
651   */
652   template<typename _CharT, typename _Traits>
653     basic_istream<_CharT, _Traits>&
654     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
655
656   template<class _Traits>
657     basic_istream<char, _Traits>&
658     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
659     { return (__in >> reinterpret_cast<char&>(__c)); }
660
661   template<class _Traits>
662     basic_istream<char, _Traits>&
663     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
664     { return (__in >> reinterpret_cast<char&>(__c)); }
665   //@}
666
667   //@{
668   /**
669    *  @brief  Character string extractors
670    *  @param  in  An input stream.
671    *  @param  s  A pointer to a character array.
672    *  @return  in
673    *
674    *  Behaves like one of the formatted arithmetic extractors described in
675    *  std::basic_istream.  After constructing a sentry object with good
676    *  status, this function extracts up to @c n characters and stores them
677    *  into the array starting at @a s.  @c n is defined as:
678    *
679    *  - if @c width() is greater than zero, @c n is width()
680    *  - otherwise @c n is "the number of elements of the largest array of
681    *    @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
682    *
683    *  Characters are extracted and stored until one of the following happens:
684    *  - @c n-1 characters are stored
685    *  - EOF is reached
686    *  - the next character is whitespace according to the current locale
687    *  - the next character is a null byte (i.e., @c charT() )
688    *
689    *  @c width(0) is then called for the input stream.
690    *
691    *  If no characters are extracted, sets failbit.
692   */
693   template<typename _CharT, typename _Traits>
694     basic_istream<_CharT, _Traits>&
695     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
696   
697   template<class _Traits>
698     basic_istream<char,_Traits>&
699     operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
700     { return (__in >> reinterpret_cast<char*>(__s)); }
701
702   template<class _Traits>
703     basic_istream<char,_Traits>&
704     operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
705     { return (__in >> reinterpret_cast<char*>(__s)); }
706   //@}
707
708   // 27.6.1.5 Template class basic_iostream
709   /**
710    *  @brief  Merging istream and ostream capabilities.
711    *
712    *  This class multiply inherits from the input and output stream classes
713    *  simply to provide a single interface.
714   */
715   template<typename _CharT, typename _Traits>
716     class basic_iostream
717     : public basic_istream<_CharT, _Traits>, 
718       public basic_ostream<_CharT, _Traits>
719     {
720     public:
721 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
722 // 271. basic_iostream missing typedefs
723       // Types (inherited):
724       typedef _CharT                                    char_type;
725       typedef typename _Traits::int_type                int_type;
726       typedef typename _Traits::pos_type                pos_type;
727       typedef typename _Traits::off_type                off_type;
728       typedef _Traits                                   traits_type;
729 #endif
730
731       // Non-standard Types:
732       typedef basic_istream<_CharT, _Traits>            __istream_type;
733       typedef basic_ostream<_CharT, _Traits>            __ostream_type;
734
735       /**
736        *  @brief  Constructor does nothing.
737        *
738        *  Both of the parent classes are initialized with the same
739        *  streambuf pointer passed to this constructor.
740       */
741       explicit 
742       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
743       : __istream_type(), __ostream_type()
744       { this->init(__sb); }
745
746       /**
747        *  @brief  Destructor does nothing.
748       */
749       virtual 
750       ~basic_iostream() { }
751
752     protected:
753       explicit 
754       basic_iostream() : __istream_type(), __ostream_type()
755       { }
756     };
757
758   // [27.6.1.4] standard basic_istream manipulators
759   /**
760    *  @brief  Quick and easy way to eat whitespace
761    *
762    *  This manipulator extracts whitespace characters, stopping when the
763    *  next character is non-whitespace, or when the input sequence is empty.
764    *  If the sequence is empty, @c eofbit is set in the stream, but not
765    *  @c failbit.
766    *
767    *  The current locale is used to distinguish whitespace characters.
768    *
769    *  Example:
770    *  @code
771    *     MyClass   mc;
772    *
773    *     std::cin >> std::ws >> mc;
774    *  @endcode
775    *  will skip leading whitespace before calling operator>> on cin and your
776    *  object.  Note that the same effect can be achieved by creating a
777    *  std::basic_istream::sentry inside your definition of operator>>.
778   */
779   template<typename _CharT, typename _Traits>
780     basic_istream<_CharT, _Traits>& 
781     ws(basic_istream<_CharT, _Traits>& __is);
782 } // namespace std
783
784 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
785 # define export
786 #endif
787 #ifdef  _GLIBCPP_FULLY_COMPLIANT_HEADERS
788 # include <bits/istream.tcc>
789 #endif
790
791 #endif  /* _CPP_ISTREAM */