OSDN Git Service

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