# istream

Go to the documentation of this file.

    00001 // Input streams -*- C++ -*-
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004
    00004 // Free Software Foundation, Inc.
    00005 //
    00006 // This file is part of the GNU ISO C++ Library.  This library is free
    00007 // software; you can redistribute it and/or modify it under the
    00008 // terms of the GNU General Public License as published by the
    00009 // Free Software Foundation; either version 2, or (at your option)
    00010 // any later version.
    00011
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00015 // GNU General Public License for more details.
    00016
    00017 // You should have received a copy of the GNU General Public License along
    00018 // with this library; see the file COPYING.  If not, write to the Free
    00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    00020 // USA.
    00021
    00022 // As a special exception, you may use this file as part of a free software
    00023 // library without restriction.  Specifically, if other files instantiate
    00024 // templates or use macros or inline functions from this file, or you compile
    00025 // this file and link it with other files to produce an executable, this
    00026 // file does not by itself cause the resulting executable to be covered by
    00027 // the GNU General Public License.  This exception does not however
    00028 // invalidate any other reasons why the executable file might be covered by
    00029 // the GNU General Public License.
    00030
    00031 //
    00032 // ISO C++ 14882: 27.6.1  Input streams
    00033 //
    00034
    00035 /** @file istream
    00036  *  This is a Standard C++ Library header.
    00037  */
    00038
    00039 #ifndef _GLIBCXX_ISTREAM
    00040 #define _GLIBCXX_ISTREAM 1
    00041
    00042 #pragma GCC system_header
    00043
    00044 #include <ios>
    00045 #include <limits> // For numeric_limits
    00046
    00047 namespace std
    00048 {
    00049   // [27.6.1.1] Template class basic_istream
    00050   /**
    00051    *  @brief  Controlling input.
    00052    *
    00053    *  This is the base class for all input streams.  It provides text
    00054    *  formatting of all builtin types, and communicates with any class
    00055    *  derived from basic_streambuf to do the actual input.
    00056   */
    00057   template<typename _CharT, typename _Traits>
    00058     class basic_istream : virtual public basic_ios<_CharT, _Traits>
    00059     {
    00060     public:
    00061       // Types (inherited from basic_ios (27.4.4)):
    00062       typedef _CharT                            char_type;
    00063       typedef typename _Traits::int_type        int_type;
    00064       typedef typename _Traits::pos_type        pos_type;
    00065       typedef typename _Traits::off_type        off_type;
    00066       typedef _Traits                           traits_type;
    00067
    00068       // Non-standard Types:
    00069       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
    00070       typedef basic_ios<_CharT, _Traits>        __ios_type;
    00071       typedef basic_istream<_CharT, _Traits>        __istream_type;
    00072       typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
    00073                             __num_get_type;
    00074       typedef ctype<_CharT>                     __ctype_type;
    00075
    00076       template<typename _CharT2, typename _Traits2>
    00077         friend basic_istream<_CharT2, _Traits2>&
    00078         operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
    00079
    00080       template<typename _CharT2, typename _Traits2>
    00081         friend basic_istream<_CharT2, _Traits2>&
    00082         operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
    00083
    00084     protected:
    00085       // Data Members:
    00086       /**
    00087        *  @if maint
    00088        *  The number of characters extracted in the previous unformatted
    00089        *  function; see gcount().
    00090        *  @endif
    00091       */
    00092       streamsize        _M_gcount;
    00093
    00094     public:
    00095       // [27.6.1.1.1] constructor/destructor
    00096       /**
    00097        *  @brief  Base constructor.
    00098        *
    00099        *  This ctor is almost never called by the user directly, rather from
    00100        *  derived classes' initialization lists, which pass a pointer to
    00101        *  their own stream buffer.
    00102       */
    00103       explicit
    00104       basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
    00105       { this->init(__sb); }
    00106
    00107       /**
    00108        *  @brief  Base destructor.
    00109        *
    00110        *  This does very little apart from providing a virtual base dtor.
    00111       */
    00112       virtual
    00113       ~basic_istream()
    00114       { _M_gcount = streamsize(0); }
    00115
    00116       // [27.6.1.1.2] prefix/suffix
    00117       class sentry;
    00118       friend class sentry;
    00119
    00120       // [27.6.1.2] formatted input
    00121       // [27.6.1.2.3] basic_istream::operator>>
    00122       //@{
    00123       /**
    00124        *  @brief  Interface for manipulators.
    00125        *
    00126        *  Manuipulators such as @c std::ws and @c std::dec use these
    00127        *  functions in constructs like "std::cin >> std::ws".  For more
    00128        *  information, see the iomanip header.
    00129       */
    00130       inline __istream_type&
    00131       operator>>(__istream_type& (*__pf)(__istream_type&));
    00132
    00133       inline __istream_type&
    00134       operator>>(__ios_type& (*__pf)(__ios_type&));
    00135
    00136       inline __istream_type&
    00137       operator>>(ios_base& (*__pf)(ios_base&));
    00138       //@}
    00139
    00140       // [27.6.1.2.2] arithmetic extractors
    00141       /**
    00142        *  @name Arithmetic Extractors
    00143        *
    00144        *  All the @c operator>> functions (aka <em>formatted input
    00145        *  functions</em>) have some common behavior.  Each starts by
    00146        *  constructing a temporary object of type std::basic_istream::sentry
    00147        *  with the second argument (noskipws) set to false.  This has several
    00148        *  effects, concluding with the setting of a status flag; see the
    00149        *  sentry documentation for more.
    00150        *
    00151        *  If the sentry status is good, the function tries to extract
    00152        *  whatever data is appropriate for the type of the argument.
    00153        *
    00154        *  If an exception is thrown during extraction, ios_base::badbit
    00155        *  will be turned on in the stream's error state without causing an
    00156        *  ios_base::failure to be thrown.  The original exception will then
    00157        *  be rethrown.
    00158       */
    00159       //@{
    00160       /**
    00161        *  @brief  Basic arithmetic extractors
    00162        *  @param  A variable of builtin type.
    00163        *  @return  @c *this if successful
    00164        *
    00165        *  These functions use the stream's current locale (specifically, the
    00166        *  @c num_get facet) to parse the input data.
    00167       */
    00168       __istream_type&
    00169       operator>>(bool& __n);
    00170
    00171       __istream_type&
    00172       operator>>(short& __n);
    00173
    00174       __istream_type&
    00175       operator>>(unsigned short& __n);
    00176
    00177       __istream_type&
    00178       operator>>(int& __n);
    00179
    00180       __istream_type&
    00181       operator>>(unsigned int& __n);
    00182
    00183       __istream_type&
    00184       operator>>(long& __n);
    00185
    00186       __istream_type&
    00187       operator>>(unsigned long& __n);
    00188
    00189 #ifdef _GLIBCXX_USE_LONG_LONG
    00190       __istream_type&
    00191       operator>>(long long& __n);
    00192
    00193       __istream_type&
    00194       operator>>(unsigned long long& __n);
    00195 #endif
    00196
    00197       __istream_type&
    00198       operator>>(float& __f);
    00199
    00200       __istream_type&
    00201       operator>>(double& __f);
    00202
    00203       __istream_type&
    00204       operator>>(long double& __f);
    00205
    00206       __istream_type&
    00207       operator>>(void*& __p);
    00208
    00209       /**
    00210        *  @brief  Extracting into another streambuf.
    00211        *  @param  sb  A pointer to a streambuf
    00212        *
    00213        *  This function behaves like one of the basic arithmetic extractors,
    00214        *  in that it also constructs a sentry object and has the same error
    00215        *  handling behavior.
    00216        *
    00217        *  If @a sb is NULL, the stream will set failbit in its error state.
    00218        *
    00219        *  Characters are extracted from this stream and inserted into the
    00220        *  @a sb streambuf until one of the following occurs:
    00221        *
    00222        *  - the input stream reaches end-of-file,
    00223        *  - insertion into the output buffer fails (in this case, the
    00224        *    character that would have been inserted is not extracted), or
    00225        *  - an exception occurs (and in this case is caught)
    00226        *
    00227        *  If the function inserts no characters, failbit is set.
    00228       */
    00229       __istream_type&
    00230       operator>>(__streambuf_type* __sb);
    00231       //@}
    00232
    00233       // [27.6.1.3] unformatted input
    00234       /**
    00235        *  @brief  Character counting
    00236        *  @return  The number of characters extracted by the previous
    00237        *           unformatted input function dispatched for this stream.
    00238       */
    00239       inline streamsize
    00240       gcount() const
    00241       { return _M_gcount; }
    00242
    00243       /**
    00244        *  @name Unformatted Input Functions
    00245        *
    00246        *  All the unformatted input functions have some common behavior.
    00247        *  Each starts by constructing a temporary object of type
    00248        *  std::basic_istream::sentry with the second argument (noskipws)
    00249        *  set to true.  This has several effects, concluding with the
    00250        *  setting of a status flag; see the sentry documentation for more.
    00251        *
    00252        *  If the sentry status is good, the function tries to extract
    00253        *  whatever data is appropriate for the type of the argument.
    00254        *
    00255        *  The number of characters extracted is stored for later retrieval
    00256        *  by gcount().
    00257        *
    00258        *  If an exception is thrown during extraction, ios_base::badbit
    00259        *  will be turned on in the stream's error state without causing an
    00260        *  ios_base::failure to be thrown.  The original exception will then
    00261        *  be rethrown.
    00262       */
    00263       //@{
    00264       /**
    00265        *  @brief  Simple extraction.
    00266        *  @return  A character, or eof().
    00267        *
    00268        *  Tries to extract a character.  If none are available, sets failbit
    00269        *  and returns traits::eof().
    00270       */
    00271       int_type
    00272       get();
    00273
    00274       /**
    00275        *  @brief  Simple extraction.
    00276        *  @param  c  The character in which to store data.
    00277        *  @return  *this
    00278        *
    00279        *  Tries to extract a character and store it in @a c.  If none are
    00280        *  available, sets failbit and returns traits::eof().
    00281        *
    00282        *  @note  This function is not overloaded on signed char and
    00283        *         unsigned char.
    00284       */
    00285       __istream_type&
    00286       get(char_type& __c);
    00287
    00288       /**
    00289        *  @brief  Simple multiple-character extraction.
    00290        *  @param  s  Pointer to an array.
    00291        *  @param  n  Maximum number of characters to store in @a s.
    00292        *  @param  delim  A "stop" character.
    00293        *  @return  *this
    00294        *
    00295        *  Characters are extracted and stored into @a s until one of the
    00296        *  following happens:
    00297        *
    00298        *  - @c n-1 characters are stored
    00299        *  - the input sequence reaches EOF
    00300        *  - the next character equals @a delim, in which case the character
    00301        *    is not extracted
    00302        *
    00303        * If no characters are stored, failbit is set in the stream's error
    00304        * state.
    00305        *
    00306        * In any case, a null character is stored into the next location in
    00307        * the array.
    00308        *
    00309        *  @note  This function is not overloaded on signed char and
    00310        *         unsigned char.
    00311       */
    00312       __istream_type&
    00313       get(char_type* __s, streamsize __n, char_type __delim);
    00314
    00315       /**
    00316        *  @brief  Simple multiple-character extraction.
    00317        *  @param  s  Pointer to an array.
    00318        *  @param  n  Maximum number of characters to store in @a s.
    00319        *  @return  *this
    00320        *
    00321        *  Returns @c get(s,n,widen('\n')).
    00322       */
    00323       inline __istream_type&
    00324       get(char_type* __s, streamsize __n)
    00325       { return this->get(__s, __n, this->widen('\n')); }
    00326
    00327       /**
    00328        *  @brief  Extraction into another streambuf.
    00329        *  @param  sb  A streambuf in which to store data.
    00330        *  @param  delim  A "stop" character.
    00331        *  @return  *this
    00332        *
    00333        *  Characters are extracted and inserted into @a sb until one of the
    00334        *  following happens:
    00335        *
    00336        *  - the input sequence reaches EOF
    00337        *  - insertion into the output buffer fails (in this case, the
    00338        *    character that would have been inserted is not extracted)
    00339        *  - the next character equals @a delim (in this case, the character
    00340        *    is not extracted)
    00341        *  - an exception occurs (and in this case is caught)
    00342        *
    00343        * If no characters are stored, failbit is set in the stream's error
    00344        * state.
    00345       */
    00346       __istream_type&
    00347       get(__streambuf_type& __sb, char_type __delim);
    00348
    00349       /**
    00350        *  @brief  Extraction into another streambuf.
    00351        *  @param  sb  A streambuf in which to store data.
    00352        *  @return  *this
    00353        *
    00354        *  Returns @c get(sb,widen('\n')).
    00355       */
    00356       inline __istream_type&
    00357       get(__streambuf_type& __sb)
    00358       { return this->get(__sb, this->widen('\n')); }
    00359
    00360       /**
    00361        *  @brief  String extraction.
    00362        *  @param  s  A character array in which to store the data.
    00363        *  @param  n  Maximum number of characters to extract.
    00364        *  @param  delim  A "stop" character.
    00365        *  @return  *this
    00366        *
    00367        *  Extracts and stores characters into @a s until one of the
    00368        *  following happens.  Note that these criteria are required to be
    00369        *  tested in the order listed here, to allow an input line to exactly
    00370        *  fill the @a s array without setting failbit.
    00371        *
    00372        *  -# the input sequence reaches end-of-file, in which case eofbit
    00373        *     is set in the stream error state
    00374        *  -# the next character equals @c delim, in which case the character
    00375        *     is extracted (and therefore counted in @c gcount()) but not stored
    00376        *  -# @c n-1 characters are stored, in which case failbit is set
    00377        *     in the stream error state
    00378        *
    00379        *  If no characters are extracted, failbit is set.  (An empty line of
    00380        *  input should therefore not cause failbit to be set.)
    00381        *
    00382        *  In any case, a null character is stored in the next location in
    00383        *  the array.
    00384       */
    00385       __istream_type&
    00386       getline(char_type* __s, streamsize __n, char_type __delim);
    00387
    00388       /**
    00389        *  @brief  String extraction.
    00390        *  @param  s  A character array in which to store the data.
    00391        *  @param  n  Maximum number of characters to extract.
    00392        *  @return  *this
    00393        *
    00394        *  Returns @c getline(s,n,widen('\n')).
    00395       */
    00396       inline __istream_type&
    00397       getline(char_type* __s, streamsize __n)
    00398       { return this->getline(__s, __n, this->widen('\n')); }
    00399
    00400       /**
    00401        *  @brief  Discarding characters
    00402        *  @param  n  Number of characters to discard.
    00403        *  @param  delim  A "stop" character.
    00404        *  @return  *this
    00405        *
    00406        *  Extracts characters and throws them away until one of the
    00407        *  following happens:
    00408        *  - if @a n @c != @c std::numeric_limits<int>::max(), @a n
    00409        *    characters are extracted
    00410        *  - the input sequence reaches end-of-file
    00411        *  - the next character equals @a delim (in this case, the character
    00412        *    is extracted); note that this condition will never occur if
    00413        *    @a delim equals @c traits::eof().
    00414        *
    00415        *  NB: Provide three overloads, instead of the single function
    00416        *  (with defaults) mandated by the Standard: this leads to a
    00417        *  better performing implementation, while still conforming to
    00418        *  the Standard.
    00419       */
    00420       __istream_type&
    00421       ignore();
    00422
    00423       __istream_type&
    00424       ignore(streamsize __n);
    00425
    00426       __istream_type&
    00427       ignore(streamsize __n, int_type __delim);
    00428
    00429       /**
    00430        *  @brief  Looking ahead in the stream
    00431        *  @return  The next character, or eof().
    00432        *
    00433        *  If, after constructing the sentry object, @c good() is false,
    00434        *  returns @c traits::eof().  Otherwise reads but does not extract
    00435        *  the next input character.
    00436       */
    00437       int_type
    00438       peek();
    00439
    00440       /**
    00441        *  @brief  Extraction without delimiters.
    00442        *  @param  s  A character array.
    00443        *  @param  n  Maximum number of characters to store.
    00444        *  @return  *this
    00445        *
    00446        *  If the stream state is @c good(), extracts characters and stores
    00447        *  them into @a s until one of the following happens:
    00448        *  - @a n characters are stored
    00449        *  - the input sequence reaches end-of-file, in which case the error
    00450        *    state is set to @c failbit|eofbit.
    00451        *
    00452        *  @note  This function is not overloaded on signed char and
    00453        *         unsigned char.
    00454       */
    00455       __istream_type&
    00456       read(char_type* __s, streamsize __n);
    00457
    00458       /**
    00459        *  @brief  Extraction until the buffer is exhausted, but no more.
    00460        *  @param  s  A character array.
    00461        *  @param  n  Maximum number of characters to store.
    00462        *  @return  The number of characters extracted.
    00463        *
    00464        *  Extracts characters and stores them into @a s depending on the
    00465        *  number of characters remaining in the streambuf's buffer,
    00466        *  @c rdbuf()->in_avail(), called @c A here:
    00467        *  - if @c A @c == @c -1, sets eofbit and extracts no characters
    00468        *  - if @c A @c == @c 0, extracts no characters
    00469        *  - if @c A @c > @c 0, extracts @c min(A,n)
    00470        *
    00471        *  The goal is to empty the current buffer, and to not request any
    00472        *  more from the external input sequence controlled by the streambuf.
    00473       */
    00474       streamsize
    00475       readsome(char_type* __s, streamsize __n);
    00476
    00477       /**
    00478        *  @brief  Unextracting a single character.
    00479        *  @param  c  The character to push back into the input stream.
    00480        *  @return  *this
    00481        *
    00482        *  If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
    00483        *
    00484        *  If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
    00485        *  the error state.
    00486        *
    00487        *  @note  Since no characters are extracted, the next call to
    00488        *         @c gcount() will return 0, as required by DR 60.
    00489       */
    00490       __istream_type&
    00491       putback(char_type __c);
    00492
    00493       /**
    00494        *  @brief  Unextracting the previous character.
    00495        *  @return  *this
    00496        *
    00497        *  If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
    00498        *
    00499        *  If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
    00500        *  the error state.
    00501        *
    00502        *  @note  Since no characters are extracted, the next call to
    00503        *         @c gcount() will return 0, as required by DR 60.
    00504       */
    00505       __istream_type&
    00506       unget();
    00507
    00508       /**
    00509        *  @brief  Synchronizing the stream buffer.
    00510        *  @return  0 on success, -1 on failure
    00511        *
    00512        *  If @c rdbuf() is a null pointer, returns -1.
    00513        *
    00514        *  Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
    00515        *  sets badbit and returns -1.
    00516        *
    00517        *  Otherwise, returns 0.
    00518        *
    00519        *  @note  This function does not count the number of characters
    00520        *         extracted, if any, and therefore does not affect the next
    00521        *         call to @c gcount().
    00522       */
    00523       int
    00524       sync();
    00525
    00526       /**
    00527        *  @brief  Getting the current read position.
    00528        *  @return  A file position object.
    00529        *
    00530        *  If @c fail() is not false, returns @c pos_type(-1) to indicate
    00531        *  failure.  Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
    00532        *
    00533        *  @note  This function does not count the number of characters
    00534        *         extracted, if any, and therefore does not affect the next
    00535        *         call to @c gcount().
    00536       */
    00537       pos_type
    00538       tellg();
    00539
    00540       /**
    00541        *  @brief  Changing the current read position.
    00542        *  @param  pos  A file position object.
    00543        *  @return  *this
    00544        *
    00545        *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos).  If
    00546        *  that function fails, sets failbit.
    00547        *
    00548        *  @note  This function does not count the number of characters
    00549        *         extracted, if any, and therefore does not affect the next
    00550        *         call to @c gcount().
    00551       */
    00552       __istream_type&
    00553       seekg(pos_type);
    00554
    00555       /**
    00556        *  @brief  Changing the current read position.
    00557        *  @param  off  A file offset object.
    00558        *  @param  dir  The direction in which to seek.
    00559        *  @return  *this
    00560        *
    00561        *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
    00562        *  If that function fails, sets failbit.
    00563        *
    00564        *  @note  This function does not count the number of characters
    00565        *         extracted, if any, and therefore does not affect the next
    00566        *         call to @c gcount().
    00567       */
    00568       __istream_type&
    00569       seekg(off_type, ios_base::seekdir);
    00570       //@}
    00571
    00572     protected:
    00573       explicit
    00574       basic_istream(): _M_gcount(streamsize(0)) { }
    00575     };
    00576
    00577   // Explicit specialization declarations, defined in src/istream.cc.
    00578   template<>
    00579     basic_istream<char>&
    00580     basic_istream<char>::
    00581     getline(char_type* __s, streamsize __n, char_type __delim);
    00582
    00583   template<>
    00584     basic_istream<char>&
    00585     basic_istream<char>::
    00586     ignore(streamsize __n);
    00587
    00588   template<>
    00589     basic_istream<char>&
    00590     basic_istream<char>::
    00591     ignore(streamsize __n, int_type __delim);
    00592
    00593 #ifdef _GLIBCXX_USE_WCHAR_T
    00594   template<>
    00595     basic_istream<wchar_t>&
    00596     basic_istream<wchar_t>::
    00597     getline(char_type* __s, streamsize __n, char_type __delim);
    00598
    00599   template<>
    00600     basic_istream<wchar_t>&
    00601     basic_istream<wchar_t>::
    00602     ignore(streamsize __n);
    00603
    00604   template<>
    00605     basic_istream<wchar_t>&
    00606     basic_istream<wchar_t>::
    00607     ignore(streamsize __n, int_type __delim);
    00608 #endif
    00609
    00610   /**
    00611    *  @brief  Performs setup work for input streams.
    00612    *
    00613    *  Objects of this class are created before all of the standard
    00614    *  extractors are run.  It is responsible for "exception-safe prefix and
    00615    *  suffix operations," although only prefix actions are currently required
    00616    *  by the standard.  Additional actions may be added by the
    00617    *  implementation, and we list them in
    00618    *  http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
    00619    *  under [27.6] notes.
    00620   */
    00621   template<typename _CharT, typename _Traits>
    00622     class basic_istream<_CharT, _Traits>::sentry
    00623     {
    00624     public:
    00625       /// Easy access to dependant types.
    00626       typedef _Traits                   traits_type;
    00627       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
    00628       typedef basic_istream<_CharT, _Traits>        __istream_type;
    00629       typedef typename __istream_type::__ctype_type     __ctype_type;
    00630       typedef typename _Traits::int_type        __int_type;
    00631
    00632       /**
    00633        *  @brief  The constructor performs all the work.
    00634        *  @param  is  The input stream to guard.
    00635        *  @param  noskipws  Whether to consume whitespace or not.
    00636        *
    00637        *  If the stream state is good (@a is.good() is true), then the
    00638        *  following actions are performed, otherwise the sentry state is
    00639        *  false ("not okay") and failbit is set in the stream state.
    00640        *
    00641        *  The sentry's preparatory actions are:
    00642        *
    00643        *  -# if the stream is tied to an output stream, @c is.tie()->flush()
    00644        *     is called to synchronize the output sequence
    00645        *  -# if @a noskipws is false, and @c ios_base::skipws is set in
    00646        *     @c is.flags(), the sentry extracts and discards whitespace
    00647        *     characters from the stream.  The currently imbued locale is
    00648        *     used to determine whether each character is whitespace.
    00649        *
    00650        *  If the stream state is still good, then the sentry state becomes
    00651        *  true ("okay").
    00652       */
    00653       explicit
    00654       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
    00655
    00656       /**
    00657        *  @brief  Quick status checking.
    00658        *  @return  The sentry state.
    00659        *
    00660        *  For ease of use, sentries may be converted to booleans.  The
    00661        *  return value is that of the sentry state (true == okay).
    00662       */
    00663       operator bool() const { return _M_ok; }
    00664
    00665     private:
    00666       bool _M_ok;
    00667     };
    00668
    00669   // [27.6.1.2.3] character extraction templates
    00670   //@{
    00671   /**
    00672    *  @brief  Character extractors
    00673    *  @param  in  An input stream.
    00674    *  @param  c  A character reference.
    00675    *  @return  in
    00676    *
    00677    *  Behaves like one of the formatted arithmetic extractors described in
    00678    *  std::basic_istream.  After constructing a sentry object with good
    00679    *  status, this function extracts a character (if one is available) and
    00680    *  stores it in @a c.  Otherwise, sets failbit in the input stream.
    00681   */
    00682   template<typename _CharT, typename _Traits>
    00683     basic_istream<_CharT, _Traits>&
    00684     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
    00685
    00686   template<class _Traits>
    00687     basic_istream<char, _Traits>&
    00688     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
    00689     { return (__in >> reinterpret_cast<char&>(__c)); }
    00690
    00691   template<class _Traits>
    00692     basic_istream<char, _Traits>&
    00693     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
    00694     { return (__in >> reinterpret_cast<char&>(__c)); }
    00695   //@}
    00696
    00697   //@{
    00698   /**
    00699    *  @brief  Character string extractors
    00700    *  @param  in  An input stream.
    00701    *  @param  s  A pointer to a character array.
    00702    *  @return  in
    00703    *
    00704    *  Behaves like one of the formatted arithmetic extractors described in
    00705    *  std::basic_istream.  After constructing a sentry object with good
    00706    *  status, this function extracts up to @c n characters and stores them
    00707    *  into the array starting at @a s.  @c n is defined as:
    00708    *
    00709    *  - if @c width() is greater than zero, @c n is width()
    00710    *  - otherwise @c n is "the number of elements of the largest array of
    00711    *    @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
    00712    *
    00713    *  Characters are extracted and stored until one of the following happens:
    00714    *  - @c n-1 characters are stored
    00715    *  - EOF is reached
    00716    *  - the next character is whitespace according to the current locale
    00717    *  - the next character is a null byte (i.e., @c charT() )
    00718    *
    00719    *  @c width(0) is then called for the input stream.
    00720    *
    00721    *  If no characters are extracted, sets failbit.
    00722   */
    00723   template<typename _CharT, typename _Traits>
    00724     basic_istream<_CharT, _Traits>&
    00725     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
    00726
    00727   template<class _Traits>
    00728     basic_istream<char, _Traits>&
    00729     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
    00730     { return (__in >> reinterpret_cast<char*>(__s)); }
    00731
    00732   template<class _Traits>
    00733     basic_istream<char, _Traits>&
    00734     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
    00735     { return (__in >> reinterpret_cast<char*>(__s)); }
    00736   //@}
    00737
    00738   // 27.6.1.5 Template class basic_iostream
    00739   /**
    00740    *  @brief  Merging istream and ostream capabilities.
    00741    *
    00742    *  This class multiply inherits from the input and output stream classes
    00743    *  simply to provide a single interface.
    00744   */
    00745   template<typename _CharT, typename _Traits>
    00746     class basic_iostream
    00747     : public basic_istream<_CharT, _Traits>,
    00748       public basic_ostream<_CharT, _Traits>
    00749     {
    00750     public:
    00751       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00752       // 271. basic_iostream missing typedefs
    00753       // Types (inherited):
    00754       typedef _CharT                            char_type;
    00755       typedef typename _Traits::int_type        int_type;
    00756       typedef typename _Traits::pos_type        pos_type;
    00757       typedef typename _Traits::off_type        off_type;
    00758       typedef _Traits                           traits_type;
    00759
    00760       // Non-standard Types:
    00761       typedef basic_istream<_CharT, _Traits>        __istream_type;
    00762       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
    00763
    00764       /**
    00765        *  @brief  Constructor does nothing.
    00766        *
    00767        *  Both of the parent classes are initialized with the same
    00768        *  streambuf pointer passed to this constructor.
    00769       */
    00770       explicit
    00771       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
    00772       : __istream_type(), __ostream_type()
    00773       { this->init(__sb); }
    00774
    00775       /**
    00776        *  @brief  Destructor does nothing.
    00777       */
    00778       virtual
    00779       ~basic_iostream() { }
    00780
    00781     protected:
    00782       explicit
    00783       basic_iostream() : __istream_type(), __ostream_type()
    00784       { }
    00785     };
    00786
    00787   // [27.6.1.4] standard basic_istream manipulators
    00788   /**
    00789    *  @brief  Quick and easy way to eat whitespace
    00790    *
    00791    *  This manipulator extracts whitespace characters, stopping when the
    00792    *  next character is non-whitespace, or when the input sequence is empty.
    00793    *  If the sequence is empty, @c eofbit is set in the stream, but not
    00794    *  @c failbit.
    00795    *
    00796    *  The current locale is used to distinguish whitespace characters.
    00797    *
    00798    *  Example:
    00799    *  @code
    00800    *     MyClass   mc;
    00801    *
    00802    *     std::cin >> std::ws >> mc;
    00803    *  @endcode
    00804    *  will skip leading whitespace before calling operator>> on cin and your
    00805    *  object.  Note that the same effect can be achieved by creating a
    00806    *  std::basic_istream::sentry inside your definition of operator>>.
    00807   */
    00808   template<typename _CharT, typename _Traits>
    00809     basic_istream<_CharT, _Traits>&
    00810     ws(basic_istream<_CharT, _Traits>& __is);
    00811 } // namespace std
    00812
    00813 #ifndef _GLIBCXX_EXPORT_TEMPLATE
    00814 # include <bits/istream.tcc>
    00815 #endif
    00816
    00817 #endif  /* _GLIBCXX_ISTREAM */