OSDN Git Service

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