______________________________________________________________________

  27   Input/output library                 [lib.input.output]

  ______________________________________________________________________

1 This clause describes components that C++ programs may use to  perform
  input/output operations.

2 The  following subclauses describe requirements for stream parameters,
  and components  for  forward  declarations  of  iostreams,  predefined
  iostreams  objects,  base  iostreams classes, stream buffering, stream
  formatting and manipulators, string streams, and file streams, as sum­
  marized in Table 1:

                  Table 1--Input/output library summary

    +----------------------------------------------------------------+
    |                    Subclause                        Header(s)  |
    +----------------------------------------------------------------+
    |_lib.iostreams.requirements_ Requirements                       |
    +----------------------------------------------------------------+
    |_lib.iostream.forward_ Forward declarations         <iosfwd>    |
    +----------------------------------------------------------------+
    |_lib.iostream.objects_ Standard iostream objects    <iostream>  |
    +----------------------------------------------------------------+
    |_lib.iostreams.base_ Iostreams base classes         <ios>       |
    +----------------------------------------------------------------+
    |_lib.stream.buffers_ Stream buffers                 <streambuf> |
    +----------------------------------------------------------------+
    |                                                    <istream>   |
    |_lib.iostream.format_ Formatting and manipulators   <ostream>   |
    |                                                    <iomanip>   |
    +----------------------------------------------------------------+
    |_lib.string.streams_ String streams                 <sstream>   |
    |                                                    <cstdlib>   |
    +----------------------------------------------------------------+
    |                                                    <cstream>   |
    |_lib.file.streams_ File streams                     <fstream>   |
    |                                                    <cstdio>    |
    |                                                    <cwchar>    |
    +----------------------------------------------------------------+

  27.1  Iostreams requirements              [lib.iostreams.requirements]

  27.1.1  Definitions                        [lib.iostreams.definitions]

1 Additional definitions:

  --character  In this clause, the term ``character'' means the general­
    ized element of text data.  Each text data consist of a sequence  of
    character.   So  the  term does not only means the char type object,
    and the wchar_t type object, but also any sort of classes which pro­
    vides the definitions specified in (_lib.string.char.traits_).

  --character  container  type  Character container type is a class or a
    type which represents a character.  It is used for one of  the  tem­
    plate parameter of the template iostream classes.

  --template iostream classes The template iostream classes are the tem­
    plate classes which takes two template parameters: charT and traits.
    The  class,  charT, represents the character container class and the
    class, traits, represents the traits structure  which  provides  the
    definition  of the functionality necessary to implement the template
    iostream classes.

  --narrow-oriented  iostream  classes  The   narrow-oriented   iostream
    classes  are  the versions of the template iostream classes special­
    ized with the character  container  class,  char.   The  traditional
    iostream  classes  are  regarded  as  the  narrow-oriented  iostream
    classes (_lib.narrow.stream.objects_).

  --wide-oriented iostream classes The  wide-oriented  iostream  classes
    are  the  versions of the template iostream classes specialized with
    the character container class, wchar_t  (_lib.wide.stream.objects_).

  --repositional  streams and arbitrary-positional streams There are two
    types of stream:  repositional and arbitrary-positional.

  +-------                 BEGIN BOX 1                -------+
  There are also non-positional streams in which no seeking is possible.
  +-------                  END BOX 1                 -------+

2 With  a repositional stream, we can seek to only the position where we
  previously  encountered.   On  the  other  hand,  with  an  arbitrary-
  positionalstream,  we  can  seek  to  any integral position within the
  length of the stream.

3 For a stream buffer which is corresponding to  a  repositional  stream
  (but  not  an arbitrary-positional stream), all we can do is either to
  fetch the current position of the stream buffer or to specify the pre­
  vious position which we have already fetched from the stream buffer.

4 Every arbitrary-positional stream is repositional.

5 If  a  repositional stream returns a POS_T object, and some arithmetic
  operations  (  operator+=,  operator-,  operator+=,  operator-=)   are
  applied,  the behavior of the stream after restoring the position with
  the modified POS_T object is undefined.  It means that a POS_T  object
  whose  parent  stream  is  repositional shall not apply any arithmetic
  operations.

6 It is not ensured that in case the validity of a certain POS_T  object
  is  broken,  the error shall be informed.  Or there is no way to check
  the validity of a certain POS_T object.

  --Invalid POS_T value The stream operations whose return type is POS_T
    may  return POS_T((OFF_T)(-1)) as signal to some error occurs.  This
    return value is called the  invalid  POS_T  value.   The  conversion
    POS_T((OFF_T)(-1))  constructs  the  invalid  POS_T  value, which is
    available only for comparing to the  return  value  of  such  member
    functions.

  27.1.2  Type requirements                  [lib.iostreams.type.reqmts]

1 There are several types and functions needed for implementing the tem­
  plate iostream classes.  Some of these types and functions  depend  on
  the  definition  of  the  character container type.  The collection of
  these functions describes the behavior which the implementation of the
  template iostream class expects to the character container class.

  27.1.2.1  Type CHAR_T                           [lib.iostreams.char.t]

1 Those who provide a character container type as the template parameter
  have to provide all of these functions as well as the container  class
  itself.  The collection of these functions can be regarded as the col­
  lection of the common definitions for the implementation of the  char­
  acter container class.

2 No  special  definition/declaration  is provided here.  The base class
  (or  struct),  string_char_traits  provides  the  definitions   common
  between the template string classes and the template iostream classes.

3 Convertible to type INT_T.

  27.1.2.2  Type INT_T                             [lib.iostreams.int.t]

1 Another character container type which can also  hold  an  end-of-file
  value.   It  is  used as the return type of some of the iostream class
  member functions.  If CHAR_T is either char or wchar_t, INT_T shall be
  int or wint_t, respectively.

  27.1.2.3  Type OFF_T                             [lib.iostreams.off.t]

1 A type that can represent offsets to positional information.1)  It  is
  _________________________
  1)  It is usually a synonym for one if the signed basic integral types
  whose representation at least as many bits as type long.

  used to represent:

  --a  signed  displacement,  measured  in  characters, from a specified
    position within a sequence.

  --an absolute position within a sequence.

2 The value OFF_T(-1) can be used as an error indicator.

3 If an OFF_T object has a value other than the  parent  stream  returns
  (for  example, assigned an arbitrary integer), the value may not apply
  to any streams.

4 Convertible to type POS_T.2) But no validity of  the  resulting  POS_T
  value is ensured, whether or not the OFF_T value is valid.

  27.1.2.4  Type POS_T                             [lib.iostreams.pos.t]

1 An  implementation-defined type for seek operations which describes an
  object that can store all the information necessary to  reposition  to
  the position.

2 The  type POS_T describes an object that can store all the information
  necessary to restore an arbitrary sequence to a previous stream  posi­
  tion and conversion state.3)

3 A  class  or  built-in type P satisfies the requirements of a position
  type, and a class or built-in type O satisfies the requirements of  an
  offset  type if the following expressions are valid, as shown in Table
  2.

4 In the following table,

  --P refers to type POS_T,

  --p and q refer to an values of type POS_T,

  --O refers to type OFF_T,

  --o refers to a value of type OFF_T, and

  --i refers to a value of type int.

  _________________________
  2) An implementation may use the same type for both OFF_T and POS_T.
  3)  The  conversion state is used for sequences that translate between
  wide-character and generalized multibyte  encoding,  as  described  in
  Amendment 1 to the C Standard.

                    Table 2--Position type requirements

  +--------------------------------------------------------------------------------+
  |expression       return type       operational           assertion/note         |
  |                                    semantics          pre/post-condition       |
  +--------------------------------------------------------------------------------+
  |P(i)                                             p == P(i)                      |
  |                                                 note: a destructor is assumed. |
  +--------------------------------------------------------------------------------+
  |P p(i);                                                                         |
  |P p = i;                                         post: p == P(i).               |
  +--------------------------------------------------------------------------------+
  |P(o)         POS_T                               converts from offset           |
  +--------------------------------------------------------------------------------+
  |O(p)         OFF_T                               converts to offset             |
  +--------------------------------------------------------------------------------+
  |p == q       convertible to bool                 == is an equivalence relation  |
  +--------------------------------------------------------------------------------+
  |p != q       convertible to bool   !(p==q)                                      |
  +--------------------------------------------------------------------------------+
  |q = p + o    POS_T                 + offset      q-o == p                       |
  |p += o                                                                          |
  +--------------------------------------------------------------------------------+
  |q = p - o    POS_T                 - offset      q+o == p                       |
  |p -= o                                                                          |
  +--------------------------------------------------------------------------------+
  |o = p - q    OFF_T                 distance      q+o == p                       |
  +--------------------------------------------------------------------------------+

  27.2  Forward declarations                      [lib.iostream.forward]

  Header <iosfwd> synopsis

  namespace std {
    template<class charT> class basic_ios;
    template<class charT> class basic_istream;
    template<class charT> class basic_ostream;

    typedef basic_ios<char>     ios;
    typedef basic_ios<wchar_t> wios;

    typedef basic_istream<char>     istream;
    typedef basic_istream<wchar_t> wistream;

    typedef basic_ostream<char>     ostream;
    typedef basic_ostream<wchar_t> wostream;
  }

1 The template class basic_ios<charT,traits> serves as a base class  for
  the          classes          basic_istream<charT,traits>          and
  basic_ostream<charT,traits>.

2 The class ios is an instance of the template class basic_ios, special­
  ized by the type char.

3 The  class  wios is a version of the template class basic_ios special­
  ized by the type wchar_t.

  27.3  Standard iostream objects                 [lib.iostream.objects]

  Header <iostream> synopsis

  #include <fstream>

  namespace std {
    extern ifstream cin;
    extern ofstream cout;
    extern ofstream cerr;
    extern ofstream clog;

    extern wifstream win;
    extern wofstream wout;
    extern wofstream werr;
    extern wofstream wlog;
  }

1 The header <iostream> declares objects that associate objects with the
  standard  C streams provided for by the functions declared in <cstdio>
  (_lib.c.files_).

2 Mixing operations on corresponding wide- and narrow-character  streams
  follows  the  same  semantics  as mixing such operations on FILE s, as
  specified in Amendment 1 of the ISO C standard.

  +-------                 BEGIN BOX 2                -------+
  ISSUE: These objects need to be constructed  and  associations  estab­
  lished before dynamic initialization of file scope variables is begun.
  +-------                  END BOX 2                 -------+

  The objects are constructed, and the associations are established, the
  first  time  an  object of class basic_ios<charT,traits>::Init is con­
  structed.  The objects are not destroyed during program execution.4)

  27.3.1  Narrow stream objects              [lib.narrow.stream.objects]

  27.3.1.1  Object cin                                         [lib.cin]

  ifstream cin;

  _________________________
  4) Constructors and destructors for static objects  can  access  these
  objects  to read input from stdin or write output to stdout or stderr.

1 The object cin controls input from an unbuffered stream buffer associ­
  ated with the object stdin, declared in <cstdio>.

2 After the object cin is initialized, cin.tie() returns cout.

  27.3.1.2  Object cout                                       [lib.cout]

  ofstream cout;

1 The object cout controls output to an unbuffered stream buffer associ­
  ated with the object stdout, declared in <cstdio> (_lib.c.files_).

  27.3.1.3  Object cerr                                       [lib.cerr]

  ofstream cerr;

1 The object cerr controls output to an unbuffered stream buffer associ­
  ated with the object stderr, declared in <cstdio> (_lib.c.files_).

2 After  the  object  cerr  is  initialized,  cerr.flags()  & unitbuf is
  nonzero.

  27.3.1.4  Object clog                                       [lib.clog]

  ofstream clog;

1 The object clog controls output to a stream buffer associated with the
  object stderr, declared in <cstdio> (_lib.c.files_).

  +-------                 BEGIN BOX 3                -------+
  ISSUE: The destination of clog ought to be implementation defined.
  +-------                  END BOX 3                 -------+

  27.3.2  Wide stream objects                  [lib.wide.stream.objects]

1
  27.3.2.1  Object win                                         [lib.win]

  wifstream win;

1 The object win controls input from an unbuffered stream buffer associ­
  ated with the object stdin, declared in <cstdio>.

2 After the object win is initialized, win.tie() returns wout.

  27.3.2.2  Object wout                                       [lib.wout]

  wofstream wout;

1 The object wout controls output to an unbuffered stream buffer associ­
  ated with the object stdout, declared in <cstdio> (_lib.c.files_).

  27.3.2.3  Object werr                                       [lib.werr]

  wofstream werr;

1 The object werr controls output to an unbuffered stream buffer associ­
  ated with the object stderr, declared in <cstdio> (_lib.c.files_).

2 After the object  werr  is  initialized,  werr.flags()  &  unitbuf  is
  nonzero.

  27.3.2.4  Object wlog                                       [lib.wlog]

  wofstream wlog;

1 The object wlog controls output to a stream buffer associated with the
  object stderr, declared in <cstdio> (_lib.c.files_).

  +-------                 BEGIN BOX 4                -------+
  ISSUE: The destination of wlog ought to be implementation defined.
  +-------                  END BOX 4                 -------+

  27.4  Iostreams base classes                      [lib.iostreams.base]

  Header <ios> synopsis

  namespace std {
    typedef OFF_T  streamoff;
    typedef OFF_T wstreamoff;
    typedef INT_T streamsize;

    template <class charT> struct ios_traits<charT>;
    struct ios_traits<char>;
    struct ios_traits<wchar_t>;

    class ios_base;
    template<class charT, class traits = ios_traits<charT> >
      class basic_ios;
    typedef basic_ios<char>     ios;
    typedef basic_ios<wchar_t> wios;

  // _lib.std.ios.manip_, manipulators:
    ios_base& boolalpha  (ios_base& str);
    ios_base& noboolalpha(ios_base& str);
    ios_base& showbase   (ios_base& str);
    ios_base& noshowbase (ios_base& str);
    ios_base& showpoint  (ios_base& str);
    ios_base& noshowpoint(ios_base& str);
    ios_base& showpos    (ios_base& str);
    ios_base& noshowpos  (ios_base& str);
    ios_base& skipws     (ios_base& str);
    ios_base& noskipws   (ios_base& str);
    ios_base& uppercase  (ios_base& str);
    ios_base& nouppercase(ios_base& str);
  // adjustfield:
    ios_base& internal   (ios_base& str);
    ios_base& left       (ios_base& str);
    ios_base& right      (ios_base& str);
  // basefield:
    ios_base& dec        (ios_base& str);
    ios_base& hex        (ios_base& str);
    ios_base& oct        (ios_base& str);
  // floatfield:
    ios_base& fixed      (ios_base& str);
    ios_base& scientific (ios_base& str);
  }

  27.4.1  Types                                       [lib.stream.types]

  27.4.1.1  Type streamoff                               [lib.streamoff]

  typedef OFF_T streamoff;

1 The type streamoff is an implementation-defined  type  that  satisfies
  the requirements of type OFF_T(_lib.iostreams.off.t_).

  27.4.1.2  Type wstreamoff                             [lib.wstreamoff]

  typedef OFF_T wstreamoff;

1 The  type  wstreamoff is an implementation-defined type that satisfies
  the requirements of type OFF_T(_lib.iostreams.off.t_).

  27.4.1.3  Type streampos                               [lib.streampos]

  typedef POS_T streampos;

1 The type streampos is an implementation-defined  type  that  satisfies
  the requirements of type POS_T(_lib.iostreams.pos.t_).

  27.4.1.4   Type wstreampos                            [lib.wstreampos]

  typedef POS_T wstreampos;

1 The  type  streampos  is an implementation-defined type that satisfies
  the requirements of type POS_T(_lib.iostreams.pos.t_).

  27.4.1.5  Type streamsize                             [lib.streamsize]

  typedef INT_T streamsize;

1 The type streamsize is a synonym for one of the signed basic  integral
  types.   It  is used to represent the number of characters transferred
  in an I/O operation, or the size of I/O buffers.5)

  27.4.2  Template struct ios_traits                    [lib.ios.traits]
  namespace std {
    template <class charT> struct ios_traits<charT> {
      typedef charT char_type;
      typedef INT_T int_type;
      typedef POS_T pos_type;
      typedef OFF_T off_type;
      typedef INT_T state_type;
      static char_type  to_char_type(int_type);
      static int_type   to_int_type (char_type);
      static bool       eq_char_type(char_type, char_type);
      static bool       eq_int_type (int_type, int_type);
      static int_type   eof();
      static int_type   not_eof(char_type c);
      static bool       is_eof (int_type);
      static char_type  newline();
      static bool       is_whitespace(ctype<char_type> ctype, char_type c);
      static char_type  eos();
      static size_t     length(const char_type* s);
      static char_type* copy(char_type* dst, const char_type* src, size_t n) ;
    };
  }

1 The template struct ios_traits<charT> is a traits  class  which  main­
  tains  the  definitions of the types and functions necessary to imple­
  ment the template iostream classes.  The template parameter charT rep­
  resents the character container type and each specialized version pro­
  vides the default definitions corresponding to the specialized charac­
  ter container type.
  _________________________
  5) streamsize is used in most places where ISO  C  would  use  size_t.
  Most  of  the  uses  of  streamsize  could  use size_t, except for the
  strstreambuf constructors, which require negative values.   It  should
  probably  be  the  signed  type corresponding to size_t (which is what
  Posix.2 calls ssize_t).

2 An  implementation  may  provide  the following two specializations of
  ios_traits:

  struct ios_traits<char>
  struct ios_traits<wchar_t>;

  27.4.2.1  Member functions                    [lib.ios.traits.members]

  27.4.2.1.1                         [lib.ios.char.traits::to.char.type]
       ios_traits::to_char_type

  char_type to_char_type(int_type c);

  Effects:
    Converts a valid character value represented in the int_type to  the
    corresponding  char_type  value.  If c is the end-of-file value, the
    return value is unspecified.

  27.4.2.1.2                          [lib.ios.char.traits::to.int.type]
       ios_traits::to_int_type

  int_type to_int_type(char_type c);

  Effects:
    Converts a valid character value represented in the char_type to the
    corresponding int_type value.

  27.4.2.1.3                         [lib.ios.char.traits::eq.char.type]
       ios_traits::eq_char_type

  bool eq_char_type(char_type c1, char_type c2);

  Returns:
    true if c1 and c2 represent the same character.

  27.4.2.1.4                          [lib.ios.char.traits::eq.int.type]
       ios_traits::eq_int_type

  bool eq_int_type(int_type c1, int_type c2);

  Returns:
    true if c1 and c2 represent the same character.

  27.4.2.1.5  ios_traits::eof                 [lib.ios.char.traits::eof]

  int_type eof();

  Returns:
    an  int_type value which represents the end-of-file.  It is returned
    by several functions to indicate end-of-file state  (no  more  input
    from  an  input  sequence  or  no more output permitted to an output
    sequence), or to indicate an invalid return value.

  27.4.2.1.6  ios_traits::not_eof         [lib.ios.char.traits::not.eof]

  int_type not_eof(char_type c);

  +-------                 BEGIN BOX 5                -------+
  Should the argument type be int_type?
  +-------                  END BOX 5                 -------+

  Returns:
    a value other than the end-of-file, even if c==eof().
  Notes:
    It is used in basic_streambuf<charT,traits>::overflow().
  Returns:
    int_type(c) if c!=eof().

  27.4.2.1.7  ios_traits::is_eof           [lib.ios.char.traits::is.eof]

  bool is_eof(int_type c);

  Returns:
    true if c represents the end-of-file.

  27.4.2.1.8  ios_traits::newline         [lib.ios.char.traits::newline]

  char_type newline();

  Returns:
    a character value which represent the newline character of the basic
    character set.
  Notes:
    It      appears      as      the      default      parameter      of
    basic_istream<charT,traits>::getline().

  27.4.2.1.9                        [lib.ios.char.traits::is.whitespace]
       ios_traits::is_whitespace

  bool is_whitespace(char_type c, ctype<char_type> ctype);

  Returns:
    true if c represents one of the white space characters.  The default
    definition is as if it returns ctype .isspace(c).

1 An  implementation of the template iostream classes may use all of the
  above static member functions in addition to the following three func­
  tions provided from the base struct string_char_traits<CHAR_T>.

  27.4.2.1.10  ios_traits::eos                [lib.ios.char.traits::eos]

  char_type eos();

  Returns:
    The  null  character  which  is  used  for  the  terminator  of null

    terminated character strings.  The default constructor for the char­
    acter container type provides the value.

  27.4.2.1.11  ios_traits::length          [lib.ios.char.traits::length]

  size_t length(const char_type* s);

  Effects:
    Determines  the length of a null terminated character string pointed
    to by s.

  27.4.2.1.12  ios_traits::copy              [lib.ios.char.traits::copy]

  char_type* copy(char_type* dest, const char_type* src, size_t n);

  Effects:
    Copies n characters from the object  pointed  to  by  src  into  the
    object  pointed  to by dest.  If copying takes place between objects
    that overlap, the behavior is undefined.

  27.4.3  Class ios_base                                  [lib.ios.base]
  namespace std {
    class ios_base {
      class failure;
      typedef T1 fmtflags;
      static const fmtflags boolalpha;
      static const fmtflags dec;
      static const fmtflags fixed;
      static const fmtflags hex;
      static const fmtflags internal;
      static const fmtflags left;
      static const fmtflags oct;
      static const fmtflags right;
      static const fmtflags scientific;
      static const fmtflags showbase;
      static const fmtflags showpoint;
      static const fmtflags showpos;
      static const fmtflags skipws;
      static const fmtflags unitbuf;
      static const fmtflags uppercase;
      static const fmtflags adjustfield;
      static const fmtflags basefield;
      static const fmtflags floatfield;
      typedef T2 iostate;
      static const iostate badbit;
      static const iostate eofbit;
      static const iostate failbit;
      static const iostate goodbit;

      typedef T3 openmode;
      static const openmode app;
      static const openmode ate;
      static const openmode binary;
      static const openmode in;
      static const openmode out;
      static const openmode trunc;
      typedef T4 seekdir;
      static const seekdir beg;
      static const seekdir cur;
      static const seekdir end;
      class Init;
      operator bool() const
      bool operator!() const
      ios_type& copyfmt(const ios_type& rhs);
      iostate rdstate() const;
      void clear(iostate state = goodbit);
      void setstate(iostate state);
      bool good() const;
      bool eof()  const;
      bool fail() const;
      bool bad()  const;
      iostate exceptions() const;
      void exceptions(iostate except);
      fmtflags flags() const;
      fmtflags flags(fmtflags fmtfl);
      fmtflags setf(fmtflags fmtfl);
      fmtflags setf(fmtflags fmtfl, fmtflags mask);
      void unsetf(fmtflags mask);
      int_type fill() const;
      int_type fill(int_type ch);
      int precision() const;
      int precision(int prec);
      int width() const;
      int width(int wide);
      locale imbue(const locale& loc);
      locale getloc() const;
      static int xalloc();
      long&  iword(int index);
      void*& pword(int index);
  protected:      // ?
      ios_base();
    private:
  //  static int index;   exposition only
  //  int* iarray;        exposition only
  //  void** parray;      exposition only
    };
  }

  +-------                 BEGIN BOX 6                -------+
  ISSUE: fill can't work in the  non-template  base  class.   Specifying
  fill character.  It is represented as int_type.
  +-------                  END BOX 6                 -------+

1 ios_base defines several member types:

  --a class failure derived from exception;

  --a class Init;

  --three bitmask types, fmtflags, iostate, and openmode;

  --an enumerated type, seekdir.

2 It maintains several kinds of data:

  --state information that reflects the integrity of the stream buffer;

  --control  information that influences how to interpret (format) input
    sequences and how to generate (format) output sequences;

  --additional information that is stored by the program for its private
    use.

  +-------                 BEGIN BOX 7                -------+
  For the sake of exposition, the maintained data is presented here as:

  --static  int index, specifies the next available unique index for the
    integer or pointer arrays maintained for the private use of the pro­
    gram, initialized to an unspecified value;

  --int*  iarray,  points  to  the  first element of an arbitrary-length
    integer array maintained for the private use of the program;

  --void** parray, points to the first element  of  an  arbitrary-length
    pointer array maintained for the private use of the program.
  +-------                  END BOX 7                 -------+

  27.4.3.1  Types                                        [lib.ios.types]

  27.4.3.1.1  Class ios_base::failure                 [lib.ios::failure]

  namespace std {
    class ios_base::failure : public exception {
    public:
      failure(const string& what = message);
      virtual ~failure();
  //  virtual string what() const;        inherited
    };
  }

1 The  class failure defines the base class for the types of all objects
  thrown as exceptions, by functions in the iostreams library, to report
  errors detected during stream buffer operations.

  27.4.3.1.1.1  ios_base::failure           [lib.ios.base::failure.cons]
       constructor

  failure(const string& what = message);

  Effects:
    Constructs an object of class failure, initializing the  base  class
    with exception(what).

1 The string message is an implementation-defined default value.

  27.4.3.1.2  Type ios_base::fmtflags                [lib.ios::fmtflags]

  typedef T1 fmtflags;

1 The  type  fmtflags  is a bitmask type (_lib.bitmask.types_).  Setting
  its elements has the effects indicated in Table 3:

                        Table 3--fmtflags effects

  +---------------------------------------------------------------------+
  |    Element                          Effect(s) if set                |
  +---------------------------------------------------------------------+
  |   boolalpha             insert and extract bool type  in  alpha­    |
  |                         betic format                                |
  |   dec                   converts  integer input or generates in­    |
  |                         teger output in decimal base                |
  |   fixed                 generate floating-point output in fixed-    |
  |                         point notation;                             |
  |   hex                   converts  integer input or generates in­    |
  |                         teger output in hexadecimal base;           |
  |   internal              adds fill characters at a designated in­    |
  |                         ternal  point  in certain generated out­    |
  |                         put;                                        |
  |   left                  adds fill characters on the  left  (ini­    |
  |                         tial  positions)  of  certain  generated    |
  |                         output;                                     |
  |   oct                   converts integer input or generates  in­    |
  |                         teger output in octal base;                 |
  |   right                 adds fill characters on the right (final    |
  |                         positions) of certain generated output;     |
  |   scientific            generates floating-point output in  sci­    |
  |                         entific notation;                           |
  |   showbase              generates a prefix indicating the numer­    |
  |                         ic base of generated integer output;        |
  |   showpoint             generates a decimal-point character  un­    |
  |                         conditionally   in  generated  floating-    |
  |                         point output;                               |
  |   showpos               generates a + sign in non-negative  gen­    |
  |                         erated numeric output;                      |
  |   skipws                skips leading white space before certain    |
  |                         input operations;                           |
  |   unitbuf               flushes output after each output  opera­    |
  |                         tion;                                       |
  |   uppercase             replaces  certain lowercase letters with    |
  |                         their uppercase equivalents in generated    |
  |                         output.                                     |
  +---------------------------------------------------------------------+

2 Type fmtflags also defines the constants indicated in Table 4:

                       Table 4--fmtflags constants

                 +--------------------------------------+
                 | Constant        Allowable values     |
                 +--------------------------------------+
                 |adjustfield   left | right | internal |
                 |basefield     dec | oct | hex         |
                 |floatfield    scientific | fixed      |
                 +--------------------------------------+

  27.4.3.1.3  Type ios_base::iostate                  [lib.ios::iostate]

  typedef T2 iostate;

1 The type iostate is a bitmask type (_lib.bitmask.types_) that contains
  the elements indicated in Table 5:

                         Table 5--iostate effects

  +---------------------------------------------------------------------+
  |    Element                         Effect(s) if set                 |
  +---------------------------------------------------------------------+
  |    badbit              indicates a loss of integrity in an  in­     |
  |                        put  or  output sequence (such as an ir­     |
  |                        recoverable read error from a file);         |
  |    eofbit              indicates  that   an   input   operation     |
  |                        reached the end of an input sequence;        |
  |    failbit             indicates that an input operation failed     |
  |                        to read the expected characters, or that     |
  |                        an  output  operation failed to generate     |
  |                        the desired characters.                      |
  +---------------------------------------------------------------------+

2 Type iostate also defines the constant:

  --goodbit, the value zero.

  27.4.3.1.4  Type ios_base::openmode                [lib.ios::openmode]

  typedef T3 openmode;

1 The type openmode is a bitmask type  (_lib.bitmask.types_).   It  con­
  tains the elements indicated in Table 6:

                        Table 6--openmode effects

  +---------------------------------------------------------------------+
  |    Element                         Effect(s) if set                 |
  +---------------------------------------------------------------------+
  |    app                 seek to end-of-file before each write to     |
  |                        the file                                     |
  |    ate                 open a file and seek to end-of-file im­      |
  |                        mediately after opening the file             |
  |    binary              perform input and output in binary mode      |
  |                        (as opposed to text mode)                    |
  |    in                  open a file for input                        |
  |    out                 open a file for output                       |
  |    trunc               truncate an existing file when opening       |
  |                        it                                           |
  +---------------------------------------------------------------------+

  27.4.3.1.5  Type ios_base::seekdir                  [lib.ios::seekdir]

  typedef T4 seekdir;

1 The  type  seekdir is an enumerated type (_lib.enumerated.types_) that
  contains the elements indicated in Table 7:

                         Table 7--seekdir effects

  +---------------------------------------------------------------------+
  |    Element                             Meaning                      |
  +---------------------------------------------------------------------+
  |    beg                 request a seek (positioning for subse­       |
  |                        quent input or output within a sequence)     |
  |                        relative to the beginning of the stream      |
  |    cur                 request a seek relative to the current       |
  |                        position within the sequence                 |
  |    end                 request a seek relative to the current       |
  |                        end of the sequence                          |
  +---------------------------------------------------------------------+

  27.4.3.1.6  Class ios_base::Init                       [lib.ios::Init]

  namespace std {
    class ios_base::Init {
    public:
      Init();
     ~Init();
    private:
  //  static int init_cnt;        exposition only
    };
  }

1 The class Init describes an object whose construction ensures the con­
  struction  of  the  four objects declared in <iostream> that associate
  file stream buffers with the standard C streams provided  for  by  the
  functions declared in <cstdio> (_lib.c.files_).

  +-------                 BEGIN BOX 8                -------+
  For the sake of exposition, the maintained data is presented here as:

  --static int init_cnt, counts the number of constructor and destructor
    calls for class Init, initialized to zero.
  +-------                  END BOX 8                 -------+

  27.4.3.1.6.1  ios_base::Init                 [lib.ios.base::init.cons]
       constructor

  Init();

  Effects:
    Constructs  an object of class Init.  If init_cnt is zero, the func­
    tion stores the value one in init_cnt, then constructs and  initial­
    izes   the   objects   cin   (_lib.cin_),  cout  (_lib.cout_),  cerr
    (_lib.cerr_), clog (_lib.clog_), win (_lib.win_), wout (_lib.wout_),
    werr (_lib.werr_), and wlog (_lib.wlog_).  In any case, the function
    then adds one to the value stored in init_cnt.

  27.4.3.1.6.2  ios_base::Init destructor       [lib.ios.base::init.des]

  ~Init();

  Effects:
    Destroys an object of class Init.  The function subtracts  one  from
    the  value  stored in init_cnt and, if the resulting stored value is
    one, calls cout.flush(), cerr.flush(), and clog.flush().

  27.4.3.2  Member functions                           [lib.ios.members]

  27.4.3.2.1  ios_base::operator bool           [lib.ios::operator.bool]

  operator bool() const

  Returns:
    fail() | bad().

  27.4.3.2.2  ios_base::operator!                   [lib.ios::operator!]

  bool operator!() const

  Returns:
    if fail() | bad().

  27.4.3.2.3  ios_base::copyfmt                       [lib.ios::copyfmt]

  ios_base<charT,traits>& copyfmt(const ios_base<charT,traits>& rhs);

  Effects:
    Assigns to the member objects  of  *this  the  corresponding  member
    objects of rhs, except that:

  --sb and rdstate() are left unchanged;

  --exceptions() is altered last by calling exception(rhs.except).

  --The  contents of arrays pointed at by pword and iword are copied not
    the pointers themselves.6)

1 If any newly stored pointer values in *this point  at  objects  stored
  outside  the  object  rhs, and those objects are destroyed when rhs is
  destroyed, the newly stored pointer values are  altered  to  point  at
  newly constructed copies of the objects.
  Returns:
    *this.

  27.4.3.2.4  ios_base::rdstate                       [lib.ios::rdstate]

  iostate rdstate() const;

  Returns:
    The control state of the stream buffer.

  27.4.3.2.5  ios_base::clear(iostate)        [lib.ios::clear.basic.ios]

  void clear(iostate state = goodbit);

  Postcondition:
    state  == rdstate().
  Effects:
    If  sb is a null pointer, the function sets badbit in rdstate().  If
    rdstate() & exceptions() is zero, returns.  Otherwise, the  function
    throws  an  object  fail of class failure, constructed with argument
  _________________________
  6) This suggests an infinite amount of copying, but the implementation
  can  keep track of the maximum element of the arrays that is non-zero.

    values that are implementation-defined.

  27.4.3.2.6                               [lib.ios::setstate.basic.ios]
       ios_base::setstate(iostate)

  void setstate(iostate state);

  Effects:
    Calls clear(rdstate() | state).

  27.4.3.2.7  ios_base::good                             [lib.ios::good]

  bool good() const;

  Returns:
    rdstate() == 0

  27.4.3.2.8  ios_base::eof                               [lib.ios::eof]

  bool eof() const;

  Returns:
    true if eofbit is set in rdstate().

  27.4.3.2.9  ios_base::fail                             [lib.ios::fail]

  bool fail() const;

  Returns:
    true if failbit or badbit is set in rdstate().7)

  27.4.3.2.10  ios_base::bad                              [lib.ios::bad]

  bool bad() const;

  Returns:
    true if badbit is set in rdstate().

  27.4.3.2.11  ios_base::exceptions                [lib.ios::exceptions]

  iostate exceptions() const;

  Returns:
    A  mask  that determines what elements set in rdstate() cause excep­
    tions to be thrown.

    void exceptions(iostate except);

  Postcondition:
    except  == exceptions().
  _________________________
  7) Checking badbit also for fail() is historical practice.

  Effects:
    Calls clear(rdstate()).

  27.4.3.2.12  ios_base::flags                          [lib.ios::flags]

  fmtflags flags() const;

  Returns:
    The format control information for both input and output.

    fmtflags flags(fmtflags fmtfl);

  Postcondition:
    fmtfl  == flags().
  Returns:
    The previous value of flags().

  27.4.3.2.13  ios_base::setf(fmtflags)                  [lib.ios::setf]

  fmtflags setf(fmtflags fmtfl);

  Effects:
    Sets fmtfl in flags().
  Returns:
    The previous value of flags().

    fmtflags setf(fmtflags fmtfl, fmtflags mask);

  Effects:
    Clears mask in flags(), sets fmtfl & mask in flags().
  Returns:
    The previous value of flags().

  27.4.3.2.14  ios_base::unsetf(fmtflags)              [lib.ios::unsetf]

  void unsetf(fmtflags mask);

  Effects:
    Clears mask in flags().

  27.4.3.2.15  basic_ios::fill                           [lib.ios::fill]

  int_type fill() const;

  Returns:
    The character to use to pad (fill) an output conversion to the spec­
    ified field width.

    int_type fill(int_type fillch);

  Postcondition:
    fillch  == fill().

  Returns:
    The previous value of fill().

  27.4.3.2.16  ios_base::precision                  [lib.ios::precision]

  int precision() const;

  Returns:
    The precision (number of digits after the decimal point) to generate
    on certain output conversions.

    int precision(int prec);

  Postcondition:
    prec  == precision().
  Returns:
    The previous value of precision().

  27.4.3.2.17  ios_base::width                          [lib.ios::width]

  int width() const;

  Returns:
    The field width (number of characters) to generate on certain output
    conversions.

    int width(int wide);

  Postcondition:
    wide  == width().
  Returns:
    The previous value of width().

  27.4.3.2.18  ios_base::imbue                          [lib.ios::imbue]

  locale imbue(const locale loc);

  Postcondition:
    loc  == getloc().
  Notes:
    In  case  the member pointer sb of the basic_streambuf<charT,traits>
    has already initialized, the function also imbues the object pointed
    to by sb.
  Returns:
    The previous value of getloc().

  27.4.3.2.19  ios_base::getloc                        [lib.ios::getloc]

  locale getloc() const;

  Returns:
    The  classic  C  locale  if  no  locale has been imbued.  Otherwise,
    returns the locale in which to perform  locale-dependent  input  and

    output operations.

  27.4.3.2.20  ios_base::xalloc                        [lib.ios::xalloc]

  static int xalloc();

  Returns:
    index ++.

  27.4.3.2.21  ios_base::iword                          [lib.ios::iword]

  long& iword(int idx);

  Effects:
    If  iarray  is a null pointer, allocates an array of int of unspeci­
    fied size and stores a pointer to its first element in iarray.   The
    function then extends the array pointed at by iarray as necessary to
    include the element iarray[idx].  Each newly  allocated  element  of
    the array is initialized to zero.
  Returns:
    iarray[idx].
  Notes:
    After  a subsequent call to iword(int) for the same object, the ear­
    lier return value may no longer be valid.8)

  27.4.3.2.22  ios_base::pword                          [lib.ios::pword]

  void* & pword(int idx);

  Effects:
    If parray is a null pointer, allocates an array of pointers to  void
    of  unspecified  size  and  stores a pointer to its first element in
    parray.  The function then extends the array pointed at by parray as
    necessary  to include the element parray[idx].  Each newly allocated
    element of the array is initialized to a null pointer.
  Returns:
    parray[idx].
  Notes:
    After a subsequent call to pword(int) for the same object, the  ear­
    lier return value may no longer be valid.

  27.4.3.2.23  ios_base constructor                  [lib.ios.base.cons]

  ios_base();

  Effects:
    Constructs  an object of class ios_base, assigning initial values to
    its member objects by calling init(0).
  _________________________
  8) An implementation is free  to  implement  both  the  integer  array
  pointed  at  by  iarray  and the pointer array pointed at by parray as
  sparse data structures, possibly with a one-element cache for each.

  27.4.3.2.24  ios_base::init                       [lib.ios.base::init]

  void init(basic_streambuf<charT,traits>* sb);

  Effects:
    The postconditions of this function are indicated in Table 8:

                           Table 8--init effects

         +--------------------------------------------------------+
         |  Element                       Value                   |
         +--------------------------------------------------------+
         |rdstate()      goodbit if sb is  not  a  null  pointer, |
         |               otherwise badbit.                        |
         |exceptions()   goodbit                                  |
         |flags()        skipws | dec                             |
         |width()        zero                                     |
         |precision()    6                                        |
         |fill()         the space character                      |
         |getloc()       new  locale(),  which  means the default |
         |               value is the current global locale;9)    |
         |index          ???                                      |
         |iarray         a null pointer                           |
         |parray         a null pointer                           |
         +--------------------------------------------------------+

  +-------                 BEGIN BOX 9                -------+
  Note: the default locale value shall be  global  but  not  transparent
  because  the  locality  of the stream buffer will be unchanged between
  its lifetime.
  +-------                  END BOX 9                 -------+

  27.4.4  Template class basic_ios                             [lib.ios]
  namespace std {
    template<class charT, class traits = ios_traits<charT> >
    class basic_ios : public ios_base {
      typedef basic_ios<charT,traits> ios_type;
    public:
  // Added for consistency:
      typedef INT_T            streamsize;
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }

  _________________________
  9) Usually, classic().

      basic_ios(basic_streambuf<charT,traits>* sb);
      virtual ~basic_ios();
      basic_ostream<charT,traits>* tie() const;
      basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
      basic_streambuf<charT,traits>* rdbuf() const;
      basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
    protected:
        basic_ios();
        void init(basic_streambuf<charT,traits>* sb);
    };
  }

  +-------                BEGIN BOX 10                -------+
  Note:   template   parameter   coupling    between    basic_ios    and
  basic_streambuf:  Both  basic_ios and basic_streambuf corresponding to
  it should take the same template parameter  <charT,traits>.   We  need
  not    allow    to   make   a   couple   of   basic_ios<wchar_t>   and
  basic_streambuf<char>.
  +-------                 END BOX 10                 -------+

  27.4.4.1  basic_ios constructors               [lib.basic.ios.sb.cons]

  basic_ios(basic_streambuf<charT,traits>* sb);

  Effects:
    Constructs an object of class basic_ios, assigning initial values to
    its member objects by calling init(sb).

    basic_ios();

  Effects:
    Constructs an object of class basic_ios,

  +-------                BEGIN BOX 11                -------+
  TBS
  +-------                 END BOX 11                 -------+

  void init(basic_streambuf<charT,traits>* sb);

  +-------                BEGIN BOX 12                -------+
  TBS
  +-------                 END BOX 12                 -------+

  27.4.4.2  Member functions                     [lib.basic.ios.members]

  27.4.4.2.1  basic_ios::tie                              [lib.ios::tie]

  basic_ostream<charT,traits>* tie() const;

  Returns:
    An  output  sequence  that  is  tied to (synchronized with) an input
    sequence controlled by the stream buffer.

    basic_ostream<charT,traits>*
      tie(basic_ostream<charT,traits>* tiestr);

  Postcondition:
    tiestr  == tie().
  Returns:
    The previous value of tie().

  27.4.4.2.2  basic_ios::rdbuf                          [lib.ios::rdbuf]

  basic_streambuf<charT,traits>* rdbuf() const;

  Returns:
    The streambuf associated with the stream.

    basic_streambuf<charT,traits>*
      rdbuf(basic_streambuf<charT,traits>* sb);

  Postcondition:
    sb  == rdbuf().
  Effects:
    Calls clear().

  +-------                BEGIN BOX 13                -------+
  Note: need to modify so as to describe the occurence of imbueing  get­
  loc()::codecvt into the argument stream buffer.
  +-------                 END BOX 13                 -------+

  Returns:
    The previous value of rdbuf().

  27.4.5  ios_base manipulators                      [lib.std.ios.manip]

  27.4.5.1  fmtflags manipulators                   [lib.fmtflags.manip]

  ios_base& boolalpha(ios_base& str);

  Effects:
    Calls str.setf(ios_base::boolalpha).
  Returns:
    str.10)

    ios_base& noboolalpha(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::boolalpha).
  Returns:
    str.

    ios_base& showbase(ios_base& str);

  Effects:
    Calls str.setf(ios_base::showbase).
  Returns:
    str.

    ios_base& noshowbase(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::showbase).
  Returns:
    str.

    ios_base& showpoint(ios_base& str);

  Effects:
    Calls str.setf(ios_base::showpoint).
  Returns:
    str.

    ios_base& noshowpoint(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::showpoint).
  Returns:
    str.

    ios_base& showpos(ios_base& str);

  Effects:
    Calls str.setf(ios_base::showpos).
  Returns:
    str.

    ios_base& noshowpos(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::showpos).
  Returns:
    str.

    ios_base& skipws(ios_base& str);

  Effects:
    Calls str.setf(ios_base::skipws).
  Returns:
    str.

    ios_base& noskipws(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::skipws).
  Returns:
    str.

    ios_base& uppercase(ios_base& str);

  Effects:
    Calls str.setf(ios_base::uppercase).
  Returns:
    str.

    ios_base& nouppercase(ios_base& str);

  Effects:
    Calls str.unsetf(ios_base::uppercase).
  Returns:
    str.

  27.4.5.2  adjustfield manipulators             [lib.adjustfield.manip]

  ios_base& internal(ios_base& str);

  Effects:
    Calls str.setf(ios_base::internal,ios_base::adjustfield)
  Returns:
    str.

    ios_base& left(ios_base& str);

  Effects:
    Calls str.setf(ios_base::left,ios_base::adjustfield)
  Returns:
    str.

    ios_base& right(ios_base& str);

  Effects:
    Calls str.setf(ios_base::right,ios_base::adjustfield)
  Returns:
    str.

  27.4.5.3  basefield manipulators                 [lib.basefield.manip]

  ios_base& dec(ios_base& str);

  Effects:
    Calls str.setf(ios_base::dec,ios_base::basefield)
  Returns:
    str.
  _________________________
  10)  The  function signature dec(ios_base&) can be called by the func­

    ios_base& hex(ios_base& str);

  Effects:
    Calls str.setf(ios_base::hex,ios_base::basefield)
  Returns:
    str.

    ios_base& oct(ios_base& str);

  Effects:
    Calls str.setf(ios_base::oct,ios_base::basefield)
  Returns:
    str.

  27.4.5.4  floatfield manipulators               [lib.floatfield.manip]

  ios_base& fixed(ios_base& str);

  Effects:
    Calls str.setf(ios_base::fixed,ios_base::floatfield)
  Returns:
    str.

    ios_base& scientific(ios_base& str);

  Effects:
    Calls str.setf(ios_base::scientific,ios_base::floatfield)
  Returns:
    str.

  27.5  Stream buffers                              [lib.stream.buffers]

  Header <streambuf> synopsis

  namespace std {
    template<class charT, class traits = ios_traits<charT> >
      class basic_streambuf;
    typedef basic_streambuf<char>     streambuf;
    typedef basic_streambuf<wchar_t> wstreambuf;
  }

1 The header <streambuf> defines types that control input from and  out­
  put to character sequences.

  _________________________
  tion   signature   basic_ostream&    stream::operator<<(basic_ostream&
  (*)(basic_ostream&))  to permit expressions of the form cout << dec to
  change the format flags stored in cout.

  27.5.1  Stream buffer requirements               [lib.streambuf.reqts]

  27.5.2  Template class                                 [lib.streambuf]
       basic_streambuf<charT,traits>
  namespace std {
    template<class charT, class traits = ios_traits<charT> >
    class basic_streambuf {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
  // In order to simplify descriptions and as a convenience for programmers:
      typedef basic_ios<char> ios;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
   public:
      virtual ~basic_streambuf();
      pos_type pubseekoff(off_type off,
                          basic_ios<charT,traits>::seekdir way,
                          basic_ios<charT,traits>::openmode which
                              = basic_ios<charT,traits>::in
                              | basic_ios<charT,traits>::out);
      pos_type pubseekpos(pos_type sp,
                          basic_ios<charT,traits>::openmode which
                              = basic_ios<charT,traits>::in
                              | basic_ios<charT,traits>::out);
      basic_streambuf<char_type,traits>*
               pubsetbuf(char_type* s, streamsize n);
      int      in_avail();
      int      pubsync();
      int_type sbumpc();
      int_type sgetc();
      int      sgetn(char_type* s, streamsize n);
      int_type snextc();
      int_type sputbackc(char_type c);
      int      sungetc();
      int      sputc(int c);
      int_type sputn(const char_type* s, streamsize n);

    protected:
      basic_streambuf();
      char_type* eback() const;
      char_type* gptr() const;
      char_type* egptr() const;
      void       gbump(int n);
      void       setg(char_type* gbeg,
                      char_type* gnext,
                      char_type* gend);
      char_type* pbase() const;
      char_type* pptr() const;
      char_type* epptr() const;
      void       pbump(int n);
      void       setp(char_type* pbeg,
                      char_type* pend);
      virtual int_type overflow (int_type c = eof());
      virtual int_type pbackfail(int_type c = eof());
      virtual int      showmany();
      virtual int_type underflow();
      virtual int_type uflow();
      virtual streamsize xsgetn(char_type* s, streamsize n);
      virtual streamsize xsputn(const char_type* s, streamsize n);
      virtual pos_type seekoff(off_type off,
                               basic_ios<charT,traits>::seekdir way,
                               basic_ios<charT,traits>::openmode which = in | out);
      virtual pos_type seekpos(pos_type sp,
                               basic_ios<charT,traits>::openmode which = in | out);
      virtual basic_streambuf<char_type,traits>*
                setbuf(char_type* s, streamsize n);
      virtual int sync();
    };
  }

1 The class template basic_streambuf<charT,traits> serves as an abstract
  base class for deriving various stream buffers whose objects each con­
  trol two character sequences:

  --a character input sequence;

  --a character output sequence.

2 The  class  streambuf  is  an  instantiation  of  the  template  class
  basic_streambuf specialized by the type char.

3 The  class  wstreambuf  is  an  instantiation  of  the  template class
  basic_streambuf specialized by the type wchar_t.

4 Stream buffers can impose various constraints on  the  sequences  they
  control.  Some constraints are:

  --The controlled input sequence can be not readable.

  --The controlled output sequence can be not writable.

  --The  controlled  sequences  can  be  associated with the contents of
    other representations for  character  sequences,  such  as  external
    files.

  --The  controlled  sequences can support operations directlyto or from
    associated sequences.

  --The controlled sequences can impose limitations on how  the  program
    can read characters from a sequence, write characters to a sequence,
    put characters back into an input  sequence,  or  alter  the  stream
    position.

5 Each  sequence  is characterized by three pointers which, if non-null,
  all point into the same charT array object.  The array  object  repre­
  sents, at any moment, a (sub)sequence of characters from the sequence.
  Operations performed on a sequence alter the values  stored  in  these
  pointers,  perform  reads  and  writes  directly to or from associated
  sequences, and alter ``the stream position'' and conversion  state  as
  needed  to maintain this subsequence relationship.  The three pointers
  are:

  --the beginning pointer,  or  lowest  element  address  in  the  array
    (called xbeg here);

  --the  next  pointer, or next element address that is a current candi­
    date for reading or writing (called xnext here);

  --the end pointer, or first element address  beyond  the  end  of  the
    array (called xend here).

6 The  following  semantic constraints shall always apply for any set of
  three pointers for a sequence, using the pointer names  given  immedi­
  ately above:

  --If  xnext  is  not  a null pointer, then xbeg and xend shall also be
    non-null pointers into the same charT array, as described above.

  --If xnext is not a null pointer  and  xnext  <  xend  for  an  output
    sequence,  then a write position is available.  In this case, *xnext
    shall be assignable as the next element to  write  (to  put,  or  to
    store a character value, into the sequence).

  --If  xnext  is  not  a  null  pointer  and  xbeg < xnext for an input
    sequence, then a putback  position  is  available.   In  this  case,
    xnext[-1]  shall  have  a  defined value and is the next (preceding)
    element to store a  character  that  is  put  back  into  the  input
    sequence.

  --If  xnext  is  not  a  null  pointer  and  xnext < xend for an input
    sequence, then a read position is available.  In this  case,  *xnext
    shall  have a defined value and is the next element to read (to get,
    or to obtain a character value, from the sequence).

  27.5.2.1  basic_streambuf constructors      [lib.basic.streambuf.cons]

  basic_streambuf();

  Effects:
    Constructs  an  object  of  class  basic_streambuf<charT,traits> and
    initializes:11)

  --all its pointer member objects to null pointers,

  --the getloc() member object to the return value of global().
  Notes:
    Once the getloc() member is initialized its locale-dependent  behav­
    ior does not change until the next imbueing of the locale.

  27.5.2.2  Member functions                     [lib.streambuf.members]

  27.5.2.2.1                                 [lib.streambuf::pubseekoff]
       basic_streambuf::pubseekoff

  pos_type pubseekoff(off_type off,
                      basic_ios<charT,traits>::seekdir way,
                      basic_ios<charT,traits>::openmode which
      = basic_ios<charT,traits>::in | basic_ios<charT,traits>::out);

  Returns:
    seekoff(off,way,which).

  27.5.2.2.2                                 [lib.streambuf::pubseekpos]
       basic_streambuf::pubseekpos

  pos_type pubseekpos(pos_type sp,
        basic_ios<charT,traits>::openmode which
      = basic_ios<charT,traits>::in | basic_ios<charT,traits>::out);

  Returns:
    seekpos(sp,which).

  27.5.2.2.3  basic_streambuf::pubsetbuf      [lib.streambuf::pubsetbuf]

  basic_streambuf<char_type,traits>*
  setbuf(char_type* s, streamsize n);

  Returns:
    setbuf(s,n).

  _________________________
  11) The default constructor is protected for class basic_streambuf  to
  assure  that  only  objects for classes derived from this class may be
  constructed.

  27.5.2.2.4  basic_streambuf::in_avail        [lib.streambuf::in.avail]

  int in_avail();

  Returns:
    If the input sequence read position is not available, returns  show­
    many().  Otherwise, returns egptr() - gptr().

  27.5.2.2.5  basic_streambuf::pubsync          [lib.streambuf::pubsync]

  int pubsync();

  Returns:
    sync().

  27.5.2.2.6  basic_streambuf::sbumpc            [lib.streambuf::sbumpc]

  int_type sbumpc();

  Returns:
    If  the  input  sequence  read  position  is  not available, returns
    uflow().  Otherwise, returns char_type(*gptr()) and  increments  the
    next pointer for the input sequence.

  27.5.2.2.7  basic_streambuf::sgetc              [lib.streambuf::sgetc]

  int_type sgetc();

  Returns:
    If the input sequence read position is not available, returns under­
    flow().  Otherwise, returns char_type(*gptr()).

  27.5.2.2.8  basic_streambuf::sgetn              [lib.streambuf::sgetn]

  int sgetn(char_type* s, streamsize n);

  Returns:
    xsgetn(s,n).

  27.5.2.2.9  basic_streambuf::snextc            [lib.streambuf::snextc]

  int_type snextc();

  Effects:
    Calls sbumpc() and, if that function returns eof(),  returns  eof().
    Otherwise, returns sgetc().
  Notes:
    Uses traits::eof().

  27.5.2.2.10                                 [lib.streambuf::sputbackc]
       basic_streambuf::sputbackc

  int_type sputbackc(char_type c);

  Returns:
    If the input sequence putback position is not available, or if c  !=
    gptr()[-1],  returns  pbackfail(c).   Otherwise, decrements the next
    pointer for the input sequence and returns *gptr().

  27.5.2.2.11  basic_streambuf::sungetc         [lib.streambuf::sungetc]

  int sungetc();

  Returns:
    If the input sequence putback position  is  not  available,  returns
    pbackfail().   Otherwise,  decrements the next pointer for the input
    sequence and returns *gptr().

  27.5.2.2.12  basic_streambuf::sputc             [lib.streambuf::sputc]

  int sputc(int c);

  Returns
    If the output sequence write  position  is  not  available,  returns
    overflow(c).  Otherwise, stores c at the next pointer for the output
    sequence, increments the pointer, and returns *pptr().

  27.5.2.2.13  basic_streambuf::sputn             [lib.streambuf::sputn]

  int_type sputn(const char_type* s, streamsize n);

  Returns:
    xsputn(s,n).

  27.5.2.2.14  basic_streambuf::eback             [lib.streambuf::eback]

  char_type* eback() const;

  Returns:
    The beginning pointer for the input sequence.

  27.5.2.2.15  basic_streambuf::gptr               [lib.streambuf::gptr]

  char_type* gptr() const;

  Returns:
    The next pointer for the input sequence.

  27.5.2.2.16  basic_streambuf::egptr             [lib.streambuf::egptr]

  char_type* egptr() const;

  Returns:
    The end pointer for the output sequence.

  27.5.2.2.17  basic_streambuf::gbump             [lib.streambuf::gbump]

  void gbump(int n);

  Effects:
    Advances the next pointer for the input sequence by n.

  27.5.2.2.18  basic_streambuf::setg               [lib.streambuf::setg]

  void setg(char_type* gbeg,
     char_type* gnext,
     char_type* gend);

  Postconditions:
    gbeg  == eback(), gnext  == gptr(), and gend  == egptr().

  27.5.2.2.19  basic_streambuf::pbase             [lib.streambuf::pbase]

  char_type* pbase() const;

  Returns:
    The beginning pointer for the output sequence.

  27.5.2.2.20  basic_streambuf::pptr               [lib.streambuf::pptr]

  char_type* pptr() const;

  Returns:
    The next pointer for the output sequence.

  27.5.2.2.21  basic_streambuf::epptr             [lib.streambuf::epptr]

  char_type* epptr() const;

  Returns:
    The end pointer for the output sequence.

  27.5.2.2.22  basic_streambuf::pbump             [lib.streambuf::pbump]

  void pbump(int n);

  Effects:
    Advances the next pointer for the output sequence by n.

  27.5.2.2.23  basic_streambuf::setp               [lib.streambuf::setp]

  void setp(char_type* pbeg, char_type* pend);

  Postconditions:
    pbeg  == pbase(), pbeg  == pptr(), and pend  == epptr().

  27.5.2.2.24  basic_streambuf::overflow       [lib.streambuf::overflow]

  virtual int_type overflow(int_type c = eof());

  Effects:
    Consumes some initial subsequence of the characters of  the  pending
    sequence.  The pending sequence is defined as the concatenation of

  a)if  pbase()  is  NULL  then  the  empty sequence otherwise, pptr() -
    pbase() characters beginning at pbase().

  b)if c == eof() then the empty sequence otherwise, the  sequence  con­
    sisting of c.
  Notes:
    The  member functions sputc() and sputn() call this function in case
    that no room can be found in the put buffer enough to accomodate the
    argument character sequence.

1 Every  overriding  definition  of this virtual function shall obey the
  following constraints:

  1)The effect  of  consuming  a  character  on  the  associated  output
    sequence is specified12)

  2)Let r be the number of characters in the pending sequence  not  con­
    sumed.   If  r  is  non-zero  then pbase() and pptr() must be set so
    that: pptr() - pbase() == r and the r characters starting at pbase()
    are  the  associated output stream.  In case r  is zero (all charac­
    ters of the pending sequence have been consumed) then either pbase()
    is  set to NULL, or pbase() and pptr() are both set to the same non-
    NULL value.

  3)The function may fail if either  appending  some  character  to  the
    associated  output  stream  fails  or  if  it is unable to establish
    pbase() and pptr() according to the above rules.
  Returns:
    eof() or throws an exception if the function fails.
    Otherwise,  returns  some  value  other  than  eof()   to   indicate
    success.13)
  _________________________
  12)  That  is,  for  each  class  derived  from  an  instance  of  ba­
  sic_streambuf in this clause, a specification of how consume a charac­
  ter  effects the associated output sequence is given.  There is no re­
  quirement on a program-defined class.
  13) Typically, overflow returns c to indicate success.

  Default behavior:
    Returns eof().

  27.5.2.2.25                                 [lib.streambuf::pbackfail]
       basic_streambuf::pbackfail

  virtual int_type pbackfail(int c = eof());

1 The public functions of basic_streambuf call this  virtual  only  when
  gptr()  is  null,  gptr()==eback(),  or *gptr()!=c.  Other calls shall
  also satisfy that constraint.

2 The   pending   sequence   is   defined   as   for    underflow    (in
  _lib.streambuf::underflow_) with the modifications that

  --If  c==eof()  then  the  input  sequence  is backed up one character
    before the pending sequence is determined.

  --If c!=eof() then c is prepended.   Whether  the  input  sequence  is
    backed up or modified in any other way is unspecified.

3 On return, the constraints of gptr(), eback(), and pptr() are the same
  as for underflow (in _lib.streambuf::underflow_)
  Returns:
    eof() to indicate failure.  Failure  may  occur  because  the  input
    sequence  could  not  be  backed up, or if for some other reason the
    pointers could not be set consistent with the  constraints.   pback­
    fail is called only when put back has really failed.
    Returns some value other than eof() to indicate success.
  Default behavior:
    Returns eof().

  27.5.2.2.26                                  [lib.streambuf::showmany]
       basic_streambuf::showmany14)

  virtual int showmany();

  Returns:
    a count of the guaranteed number of characters that can be read from
    the  input  sequence  before a call to uflow()or underflow() returns
    eof().  A positive return value of indicates that the next such call
    will not return eof().15)
  Default behavior:
    Returns zero.

  _________________________
  14) The morphemes of showmany are "es-how-manyS, not "show-many".
  15)  The  next such call might fail by throwing an exception.  The in­
  tention is that the next call will return ``immediately.''

  27.5.2.2.27                                 [lib.streambuf::underflow]
       basic_streambuf::underflow

  virtual int_type underflow();

1 The public members of basic_streambuf call this virtual only if gptr()
  is null or gptr() >= egptr()
  Returns:
    the first character of the pending sequence,  if  possible,  without
    moving the input sequence position past it.  If the pending sequence
    is null then the function fails.

2 The pending sequence of characters is defined as the concatenation of:

  a)If  gptr() is non- NULL, then the egptr() - gptr() characters start­
    ing at gptr(), otherwise the empty sequence.

  b)Some sequence (possibly empty) of characters  read  from  the  input
    sequence.

3 The result character is

  a)If  the  pending  sequence  is non-empty, the first character of the
    sequence.

  b)If the pending sequence empty then the next character that would  be
    read from the input sequence.

4 The backup sequence is defined as the concatenation of:

  a)If eback() is null then empty,

  b)Otherwise the gptr() - eback() characters beginning at eback().

5 The function sets up the gptr() and egptr() satisfying one of:

  a)If  the  pending  sequence  is  non-empty,  egptr()  is non-null and
    egptr() - gptr() characters starting at gptr() are the characters in
    the pending sequence

  b)If  the  pending  sequence is empty, either gptr() is null or gptr()
    and egptr() are set to the same non- NULL pointer.

6 If eback() and gptr() are non-null  then  the  function  is  not  con­
  strained  as  to their contents, but the ``usual backup condition'' is
  that either:

  a)If the backup sequence contains at least gptr()  -  eback()  charac­
    ters, then the gptr() - eback() characters starting at eback() agree
    with the last gptr() - eback() characters of the backup sequence.

  b)Or the n characters starting at gptr() - n  agree  with  the  backup

    sequence (where n is the length of the backup sequence)
  Returns:
    eof() to indicate failure.
  Default behavior:
    Returns eof().

  27.5.2.2.28  basic_streambuf::uflow             [lib.streambuf::uflow]

  virtual int_type uflow();

1 The     constraints     are     the     same    as    for    underflow
  (_lib.streambuf::underflow_)  except  that  the  result  character  is
  transfered  from  the pending sequence to the backup sequence, and the
  pending sequence may not be empty before the transfer.
  Default behavior:
    Calls underflow(eof()).  If underflow returns eof(), returns  eof().
    Otherwise, does gbump(-1) and returns *gptr().
  Returns:
    not_eof(c).

  27.5.2.2.29  basic_streambuf::xsgetn           [lib.streambuf::xsgetn]

  virtual streamsize xsgetn(char_type* s, streamsize n);

  Effects:
    Assigns up to n characters to successive elements of the array whose
    first element is designated by s.  The characters assigned are  read
    from  the  input  sequence  as  if  by  repeated  calls to sbumpc().
    Assigning stops when either n characters have  been  assigned  or  a
    call to sbumpc() would return eof().
  Returns:
    The number of characters assigned.16)

  27.5.2.2.30  basic_streambuf::xsputn           [lib.streambuf::xsputn]

  virtual streamsize xsputn(const char_type* s, streamsize n);

1 Writes  up  to  n  characters to the output sequence as if by repeated
  calls to sputc(c).  The characters written are obtained  from  succes­
  sive  elements  of  the  array whose first element is designated by s.
  Writing stops when either n characters have been written or a call  to
  sputc(c) would return eof().
  Returns:
    The number of characters written.

  _________________________
  16)  Classes  derived  from basic_streambuf can provide more efficient
  ways to implement xsgetn and xsputn by overriding these definitions in
  the base class.

  27.5.2.2.31  basic_streambuf::seekoff         [lib.streambuf::seekoff]

  virtual pos_type seekoff(off_type off,
  ic_ios<charT,traits>::seekdir way,
  ic_ios<charT,traits>::openmode which
   = basic_ios<charT,traits>::in | basic_ios<charT,traits>::out);

  Effects:
    Alters  the  stream  positions  within one or more of the controlled
    sequences in a way that is defined separately for each class derived
    from   basic_streambuf  in  this  clause  (_lib.stringbuf::seekoff_,
    _lib.filebuf::seekoff_).
  Default behavior:
    Returns an object of class pos_type that stores  an  invalid  stream
    position (_lib.iostreams.definitions_).

  27.5.2.2.32  basic_streambuf::seekpos         [lib.streambuf::seekpos]

  virtual pos_type seekpos(pos_type sp,
  ic_ios<charT,traits>::openmode which = in | out);

  Effects:
    Alters  the  stream  positions  within one or more of the controlled
    sequences in a way that is defined separately for each class derived
    from   basic_streambuf  in  this  clause  (_lib.stringbuf::seekpos_,
    _lib.filebuf::seekpos_).
  Default behavior:
    Returns an object of class pos_type that stores  an  invalid  stream
    position.

  27.5.2.2.33  basic_streambuf::setbuf           [lib.streambuf::setbuf]

  virtual basic_streambuf*
  buf(char_type* s, streamsize n);

  Effects:
    Performs  an  operation  that  is  defined separately for each class
    derived      from      basic_streambuf      in      this      clause
    (_lib.stringbuf::setbuf_, _lib.filebuf::setbuf_).
  Default behavior:
    Returns this.

  27.5.2.2.34  basic_streambuf::sync               [lib.streambuf::sync]

  virtual int sync();

  Effects:
    Synchronizes  the controlled sequences with the arrays.  That is, if
    pbase() is non-null the characters between pbase()  and  pptr()  are
    written  to  the controlled sequence, and if gptr() is non-null, the
    characters between gptr() and egptr()  are  restored  to  the  input
    sequence.  The pointers may then be reset as appropriate.

  Returns:
    -1  on  failure.   What  constitutes  failure  is determined by each
    derived class (_lib.filebuf::sync_).
  Default behavior:
    Returns zero.

  27.6  Formatting and manipulators                [lib.iostream.format]

  Header <istream> synopsis

  namespace std {
    template <class charT, class traits = ios_traits<charT> >
      class basic_istream;
    typedef basic_istream<char>     istream;
    typedef basic_istream<wchar_t> wistream;

    template<class charT, class traits>
      basic_istream<charT,traits>& ws(basic_istream<charT,traits>& is);
  }

  Header <ostream> synopsis

  namespace std {
    template <class charT, class traits = ioc_traits<charT> >
      class basic_ostream;
    typedef basic_ostream<char>     ostream;
    typedef basic_ostream<wchar_t> wostream;

    template<class charT, class traits>
      basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
    template<class charT, class traits>
      basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
    template<class charT, class traits>
      basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
  }

  Header <iomanip> synopsis

  #include <istream>
  #include <ostream>

  namespace std {
      typedef ? smanip;

      smanip resetiosflags(ios_base::fmtflags mask);
      smanip setiosflags  (ios_base::fmtflags mask);
      smanip setbase(int base);
      smanip setfill(int c);
      smanip setprecision(int n);
      smanip setw(int n);
  }

1 The header  <iomanip>  defines  three  template  classes  and  several
  related  functions  that use these template classes to provide extrac­
  tors and inserters that alter information maintained by class ios_base
  and  its  derived  classes.  It also defines several instantiations of
  these template classes and functions.

  27.6.1  Input streams                              [lib.input.streams]

1 The header <istream> defines a type and a function signature that con­
  trol input from a stream buffer.

  27.6.1.1  Template class basic_istream                   [lib.istream]
  namespace std {
    template <class charT, class traits = ios_traits<charT> >
    class basic_istream : virtual public basic_ios<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    private:
  // for abbreviation:
      typedef basic_istream<char_type,traits> istream_type;
      typedef basic_ios<charT,traits> ios_type;
    public:
      basic_istream(basic_streambuf<charT,traits>* sb);
      virtual ~basic_istream();
      bool ipfx(bool noskipws = 0);
      void isfx();
      istream_type& operator>>(istream_type& (*pf)(istream_type&))
      istream_type& operator>>(ios_type& (*pf)(ios_type&))
      istream_type& operator>>(char_type* s);
      istream_type& operator>>(char_type& c);
      istream_type& operator>>(bool& n);
      istream_type& operator>>(short& n);
      istream_type& operator>>(unsigned short& n);
      istream_type& operator>>(int& n);
      istream_type& operator>>(unsigned int& n);
      istream_type& operator>>(long& n);
      istream_type& operator>>(unsigned long& n);
      istream_type& operator>>(float& f);
      istream_type& operator>>(double& f);
      istream_type& operator>>(long double& f);
      istream_type& operator>>(void*& p);
      istream_type& operator>>(basic_streambuf<char_type,traits>& sb);
      int_type get();
      istream_type& get(char_type* s, streamsize n,
                        char_type delim = newline());
      istream_type& get(char_type& c);
      istream_type& get(basic_streambuf<char_type,traits>& sb,
                        char_type delim = newline());

      istream_type& getline(char_type* s, streamsize n,
                            char_type delim = newline());
      istream_type& ignore(streamsize n = 1, int_type delim = eof());
      istream_type& read(char_type* s, streamsize n);
      int readsome(char_type* s, int n);
      int peek();
      istream_type& putback(char_type c);
      istream_type& unget();
      streamsize gcount() const;
      int sync();
    };
  }

1 The class basic_istream defines a number of member function signatures
  that assist in reading and  interpreting  input  from  sequences  con­
  trolled by a stream buffer.

2 Two  groups of member function signatures share common properties: the
  formatted input functions (or extractors) and  the  unformatted  input
  functions.   Both  groups  of input functions are described as if they
  obtain  (or  extract)  input  characters  by  calling  sb.sbumpc()  or
  sb.sgetc().   They may use other public members of istream except that
  they do not invoke any virtual members of sb except uflow().

3 If sb.sbumpc() or sb.sgetc() returns eof(), then the  input  function,
  except  as  explicitly noted otherwise, completes its actions and does
  setstate(eofbit) before returning.

4 If one of these called functions  throws  an  exception,  then  unless
  explicitly  noted  otherwise the input function calls setstate(badbit)
  and if badbit is on in sb.exception() rethrows the  exception  without
  completing its actions.

  27.6.1.2  basic_istream constructors          [lib.basic.istream.cons]

  basic_istream(basic_streambuf<charT,traits>* sb);

  Effects:
    Constructs  an object of class basic_istream, assigning initial val­
    ues to the base class by calling basic_ios::init(sb).
  Postcondition:
    gcount() == 0

    virtual ~basic_istream();

  Effects:
    Destroys an object of class basic_istream.
  Notes:
    Does not perform any operations of rdbuf().

  27.6.1.3  Member functions                       [lib.istream.members]

  27.6.1.3.1  basic_istream::ipfx                    [lib.istream::ipfx]

  bool ipfx(bool noskipws = 0);

  Effects:
    If good() is true, prepares  for  formatted  or  unformatted  input.
    First,   if  tie()  is  not  a  null  pointer,  the  function  calls
    tie()->flush() to synchronize the output sequence with  any  associ­
    ated external C stream.17) If noskipws is zero and flags() &  skipws
    is  nonzero,  the  function  extracts and discards each character as
    long as the next available input character c is a whitespace charac­
    ter.
  Notes:
    The  function  basic_istream<charT,traits>::ipfx() uses the function
    bool  traits::is_whitespace(charT,  const  locale*)  in  the  traits
    structure  to  determine whether the next input character is whites­
    pace or not.

1 To decide if the character c is a whitespace character,  the  function
  performs as if it executes the following code fragment:
    ctype<charT> ctype = getloc().use<ctype<charT> >();
    if (traits::is_whitespace (c, ctype)!=0)
   // c is a whitespace character.
  Returns:
    If,  after  any  preparation  is  completed, good() is true, returns
    true.  Otherwise, it calls setstate(failbit) and returns false.18)

2 A typical implementation of the ipfx() function may be as follows:
  template <class charT, class traits = ios_traits<charT> >
  int basic_istream<charT,traits>::ipfx() {
      ...
  // skipping whitespace according to a constraint function,
  // is_whitespace
      intT c;
      typedef ctype<charT> ctype_type;
      ctype_type& ctype = getloc().use<ctype_type>();
      while ((c = rdbuf()->snextc()) != eof()) {
        if (!traits::is_whitespace (c,ctype)==0) {
          rdbuf()->sputbackc (c);
          break;
        }
      }
      ...
   }

  _________________________
  17) The call tie()->flush() does not necessarily occur if the function
  can determine that no synchronization is necessary.
  18) The functions ipfx(int) and isfx() can also perform additional im­
  plementation-dependent operations.

3 In  case  we use ios_traits<char> or ios_traits<wchar_t>, the behavior
  of  the  constraint  function  traits::is_whitespace()  is  as  if  it
  invokes:
     ctype<charT>& ctype = getloc().use<ctype<charT> >();
     ctype.is(ctype<charT>::SPACE, c);
  otherwise,  the  behavior  of  the function traits::is_whitespace() is
  unspecified.

4 Those who want to  use  locale-independent  whitespace  predicate  can
  specify  their  definition of is_whitespace in their new ios_traits as
  follows:
  struct my_traits : public ios_traits<char> {
      typedef my_char_traits char_traits;
  };
  struct my_char_traits : public ios_traits<char> {
      static bool is_whitespace (char c, const ctype<charT>& ctype) {
      ....(my own implementation)...
      }
  };

  27.6.1.3.2  basic_istream::isfx                    [lib.istream::isfx]

  void isfx();

  Effects:

  +-------                BEGIN BOX 14                -------+
  TBS
  +-------                 END BOX 14                 -------+

  27.6.1.3.3  basic_istream::sync                    [lib.istream::sync]

  int sync();

  Effects:
    If rdbuf() is a  null  pointer,  returns  eof().   Otherwise,  calls
    rdbuf()->pubsync()  and,  if that function returns eof(), calls set­
    state(badbit) and returns eof().  Otherwise, returns zero.

  27.6.1.4  Formatted input functions            [lib.istream.formatted]

  27.6.1.4.1  Common requirements         [lib.istream.formatted.reqmts]

1 Each formatted input function begins execution by calling ipfx().   If
  that  function  returns  true,  the  function  endeavors to obtain the
  requested input.  In any case, the formatted input  function  ends  by
  calling isfx(), then returns *this

2 Some  formatted input functions endeavor to obtain the requested input
  by parsing characters extracted from the  input  sequence,  converting
  the  result  to a value of some scalar data type, and storing the con­
  verted value in an object of that scalar data type.

3 The numeric conversion  behaviors  of  the  following  extractors  are
  locale-dependent.

  operator>>(short& val);
  operator>>(unsigned short& val);
  operator>>(int& val);
  operator>>(unsigned int& val);
  operator>>(long& val);
  operator>>(unsigned long& val);
  operator>>(float& val);
  operator>>(double& val);
  operator>>(long double& val);

  As  in  the  case  of  the  inserters,  these extractors depend on the
  locale's num_get<> (_lib.locale.num.get_) object  to  perform  parsing
  the  input  stream data.  The conversion occurs as if it performed the
  following code fragment:
    HOLDTYPE tmp;
    num_get<charT>& fmt = loc.use< num_get<charT> >();
    fmt.get (iter, *this, loc, tmp);
    if ((val = (TYPE)tmp) != tmp)
    // set fail bit...
  In the above fragment, loc  stands  for  the  private  member  of  the
  basic_ios  class,  TYPE  stands  for  the  type of the argument of the
  extractor, and HOLDTYPE is as follows;

  --for short, int and long, HOLDTYPE is long;

  --for unsigned short, unsigned int  and  unsigned  long,  HOLDTYPE  is
    unsigned long.

  --for float, double, HOLDTYPE is double.

  --for long double, HOLDTYPE is long double.

4 The  first  argument  provides an object of the istream_iterator class
  which is an iterator pointed to an input stream.  It bypasses istreams
  and uses streambufs directly.  Class locale relies on this type as its
  interface to istream, since the flexibility  it  has  been  abstracted
  away from direct dependence on istream.

5 In  case the converting result is a value of either an integral type (
  short, unsigned short, int, unsigned int, long, unsigned  long)  or  a
  float type ( float, double, long double), performing to parse and con­
  vert the result depend on the imbued locale object.  So  the  behavior
  of  the above type extractors are locale-dependent.  The imbued locale
  object uses an  istreambuf_iterator  to  access  the  input  character
  sequence.

6 The behavior of such functions is described in terms of the conversion
  specification  for  an  equivalent  call  to  the function fscanf()19)
  _________________________
  19) The signature fscanf(FILE*, const  char*,  ...)   is  declared  in

  operating with the global locale set to getloc(), with  the  following
  alterations:

  --The  formatted  input  function  extracts  characters  from a stream
    buffer, rather than reading them from an input file.20)

  --If  flags() & skipws is zero, the function does not skip any leading
    white space.  In that case, if the next  input  character  is  white
    space, the scan fails.

  --If  the converted data value cannot be represented as a value of the
    specified scalar data type, a scan failure occurs.

  +-------                BEGIN BOX 15                -------+
  Can the current num_put/num_get facet handle basefield  specification?
  Needs more discussion.
  +-------                 END BOX 15                 -------+

7 If  the  scan fails for any reason, the formatted input function calls
  setstate(failbit).

8 For conversion to an integral type other than a  character  type,  the
  function  determines the integral conversion specifier as indicated in
  Table 9:

                       Table 9--Integer conversions

            +------------------------------------------------+
            |           State               stdio equivalent |
            +------------------------------------------------+
            |(flags() & basefield) == oct          %o        |
            +------------------------------------------------+
            |(flags() & basefield) == hex          %x        |
            |(flags() & uppercase) != 0            %X        |
            +------------------------------------------------+
            |(flags() & basefield) == 0            %i        |
            +------------------------------------------------+
            |Otherwise,                                      |
            +------------------------------------------------+
            |signed integral type                  %d        |
            +------------------------------------------------+
            |unsigned integral type                %u        |
            +------------------------------------------------+

  +-------                BEGIN BOX 16                -------+
  _________________________
  <cstdio> (_lib.c.files_)
  20) The stream buffer can, of course,  be  associated  with  an  input
  file, but it need not be.

  Is this table clear with regards to %x vs.  %X?
  +-------                 END BOX 16                 -------+

  27.6.1.4.2  basic_istream::operator>>        [lib.istream::extractors]

  istream_type& operator>>(istream_type& (*pf)(istream_type&))

  Returns:
    pf(*this).21)

    istream_type& operator>>(ios_type& (*pf)(ios_type&))

  Effects:
    Calls pf(*this), then returns *this.22)

    istream_type& operator>>(char_type* s);

  Effects:
    Extracts characters and stores them into successive locations of  an
    array whose first element is  designated  by  s.23)  If  width()  is
    greater  than  zero,  the  maximum  number of characters stored n is
    width(); otherwise it is numeric_limits<int>::max()  (_lib.limits_).

1 Characters are extracted and stored until any of the following occurs:

  --n  - 1 characters are stored;

  --end-of-file occurs on the input sequence;

  --traits::is_whitespace(c,ctype) is nonzero  for  the  next  available
    input  character  c.  In the above code fragment, the argument ctype
    is acquired by getloc().use<ctype<charT> >().

2 If the function stores no characters, it calls setstate(failbit).   In
  any  case,  it  then  stores a null character into the next successive
  location of the array and calls width(0).
  Returns:
    *this.

    istream_type& operator>>(char_type& c);

  Effects:
    Extracts a character, if one is available, and stores it in c.  Oth­
    erwise, the function calls setstate(failbit).
  _________________________
  21)  See,  for  example,  the  function  signature  ws(basic_istream&)
  (_lib.basic.istream.manip_).
  22)      See,      for     example,     the     function     signature
  dec(basic_ios<charT,traits>&) (_lib.basefiled.manip_).
  23) Note that this function is not overloaded on types signed char and
  unsigned char.

  Returns:
    *this.

    istream_type& operator>>(bool& n);

  Effects:
    Converts  a signed short integer, if one is available, and stores it
    in x.
  Returns:
    *this.
  Notes:
    Behaves as if:
        if (flags() & ios::boolalpha) {
          getloc().extract(*this, n);
        } else {
          int x;
          *this >> x;
          if (x == 0)
            n = false;
          else if (x == 1)
            n = true;
          else
            ; // indicate failure
        }
        return *this;

3 Locale extraction ( getloc().extract()) of  the  string  is  something
  like:
    istream i;
    string bool_false = ...; // locale dependent
    string bool_true  = ...;
    string s;
    i >> s;
    if (s == bool_false)
      n = false;
    else if (s == bool_true)
      n = true;
    else
      ; // indicate failure

4 The strings for the default locale are false and true.

  istream_type& operator>>(short& n);

  Effects:
    Converts  a signed short integer, if one is available, and stores it
    in n.
  Returns:
    *this.

    istream_type& operator>>(unsigned short& n);

  Effects:
    Converts an unsigned short integer, if one is available, and  stores
    it in n.
  Returns:
    *this.

    istream_type& operator>>(int& n);

  Effects:
    Converts  a signed integer, if one is available, and stores it in n.
  Returns:
    *this.

    istream_type& operator>>(unsigned int& n);

  Effects:
    Converts an unsigned integer, if one is available, and stores it  in
    n.
  Returns:
    *this.

    istream_type& operator>>(long& n);

  Effects:
    Converts  a  signed long integer, if one is available, and stores it
    in n.
  Returns:
    *this.

    istream_type& operator>>(unsigned long& n);

  Effects:
    Converts an unsigned long integer, if one is available,  and  stores
    it in n.
  Returns:
    *this.

    istream_type& operator>>(float& f);

  Effects:
    Converts a float, if one is available, and stores it in f.
  Returns:
    *this.

    istream_type& operator>>(double& f);

  Effects:
    Converts a double, if one is available, and stores it in f.
  Returns:
    *this.

    istream_type& operator>>(long double& f);

  Effects:
    Converts a long double, if one is available, and stores it in f.
  Returns:
    *this.

    istream_type& operator>>(void*& p);

  Effects:
    Converts a pointer to void, if one is available, and stores it in p.
  Returns:
    *this.

    istream_type& operator>>(basic_streambuf<charT,traits>& sb);

  Effects:
    Extracts characters from  *this  and  inserts  them  in  the  output
    sequence  controlled  by  rdbuf().   Characters  are  extracted  and
    inserted until any of the following occurs:

  --end-of-file occurs on the input sequence;

  --inserting in the output sequence fails (in which case the  character
    to be inserted is not extracted);

  --an  exception  occurs (in which case the exception is caught).  set­
    state(badbit) is not called

5 If the function inserts no characters, it calls setstate(failbit).  If
  failure was due to catching an exception thrown while extracting char­
  acters   from   rdbuf()   and   failbit   is   on   in    exceptions()
  (_lib.ios::exceptions_), then the caught exception is rethrown.
  Returns:
    *this.

  27.6.1.5  Unformatted input functions        [lib.istream.unformatted]

1 Each  unformatted  input function begins execution by calling ipfx(1).
  If that function returns nonzero, the function  endeavors  to  extract
  the  requested  input.   It  also  counts  the  number  of  characters
  extracted.  In any case, the unformatted input function ends by  stor­
  ing  the  count  in a member object and calling isfx(), then returning
  the value specified for the unformatted input function.

  27.6.1.5.1  basic_istream::get                      [lib.istream::get]

  int get();

  Effects:
    Extracts a character c, if one  is  available.   The  function  then
    returns  (unsigned  char)c.   Otherwise,  the  function  calls  set­
    state(failbit) and then returns eof().

    istream_type& get(char_type*  s, streamsize n,
                      char_type delim = newline());

  Effects:
    Extracts characters and stores them into successive locations of  an
    array whose first element is  designated  by  s.24)  Characters  are
    extracted and stored until any of the following occurs:

  --n - 1 characters are stored;

  --end-of-file occurs on the input sequence (in which case the function
    calls setstate(eofbit));

  --c == delim for the next available input character c (in which case c
    is not extracted).

1 If  the function stores no characters, it calls setstate(failbit).  In
  any case, it then stores a null character  into  the  next  successive
  location of the array.
  Returns:
    *this.

    istream_type& get(char_type& c);

  Effects:
    Extracts a character, if one is available, and assigns it  to  c.25)
    Otherwise, the function calls setstate(failbit).
  Returns:
    *this.

    istream_type& get(basic_streambuf<char_type,traits>& sb,
                      char_type delim = newline());

  Effects:
    Extracts  characters  and  inserts  them in the output sequence con­
    trolled by rdbuf().  Characters are extracted and inserted until any
    of the following occurs:

  --end-of-file occurs on the input sequence;

  --inserting  in the output sequence fails (in which case the character
    to be inserted is not extracted);

  --c == delim for the next available input character c (in which case c
    is not extracted);

  --an  exception occurs (in which case, the exception is caught but not
  _________________________
  24) Note that this function is not overloaded on types signed char and
  unsigned char.
  25)  Note that this function is not overloaded on types signed charand
  unsigned char.

    rethrown).

2 If the function inserts no characters, it calls setstate(failbit).
  Returns:
    *this.

  27.6.1.5.2  basic_istream::getline              [lib.istream::getline]

  istream_type& getline(char_type* s, streamsize n,
                        char_type delim = newline());

  Effects:
    Extracts characters and stores them into successive locations of  an
    array whose first element is  designated  by  s.26)  Characters  are
    extracted and stored until one of the following occurs:

  1)end-of-file occurs on the input sequence (in which case the function
    calls setstate(eofbit));

  2)c == delim for the next available input character c (in  which  case
    the input character is extracted but not stored);27)

  3)n - 1 characters are stored (in which case the function  calls  set­
    state(failbit)).

1 These conditions are tested in the order shown.28)

2 If the function extracts no characters, it calls setstate(failbit).29)

3 In  any case, it then stores a null character into the next successive
  location of the array.
  Returns:
    *this.

4 Example:

  _________________________
  26) Note that this function is not overloaded on types signed char and
  unsigned char.
  27) Since the final input character is ``extracted,'' it is counted in
  the gcount(), even though it is not stored.
  28)  This allows an input line which exactly fills the buffer, without
  setting failbit.  This is different behavior than the historical  AT&T
  implementation.
  29) This implies an empty input line will not cause failbit to be set.

    #include <iostream>
    using namespace std;
    const int line_buffer_size = 100;
    int main()
    {
      char buffer[line_buffer_size];
      int line_number = 0;
      while (cin.getline(buffer, line_buffer_size) || cin.gcount()) {
        int count = cin.gcount();
        if (cin.eof())
          cout << "Partial final line";   // cin.fail() is false
        else if (cin.fail()) {
          cout << "Partial long line";
          cin.clear(cin.rdstate() & ~ios::failbit);
        } else {
          count--;        // Don't include '\n' in count
          cout << "Line " << ++line_number;
        }
        cout << " (" << count << " chars): " << buffer << endl;
      }
    }

  27.6.1.5.3  basic_istream::ignore                [lib.istream::ignore]

  istream_type& ignore(int n = 1, int_type delim = eof());

  Effects:
    Extracts characters and discards  them.   Characters  are  extracted
    until any of the following occurs:

  --if n  != numeric_limits<int>::max() (_lib.limits_), n characters are
    extracted

  --end-of-file occurs on the input sequence (in which case the function
    calls setstate(eofbit));

  --c == delim for the next available input character c (in which case c
    is extracted).

1 The last condition will never occur if delim  == eof().
  Returns:
    *this.

  27.6.1.5.4  basic_istream::read                    [lib.istream::read]

  istream_type& read(char_type* s, streamsize n);

  Effects:
    Extracts characters and stores them into successive locations of  an
    array whose first element is  designated  by  s.30)  Characters  are
  _________________________
  30) Note that this function is not overloaded on types signed char and
  unsigned char.

    extracted and stored until either of the following occurs:

  --n characters are stored;

  --end-of-file occurs on the input sequence (in which case the function
    calls setstate(failbit)).
  Returns:
    *this.

  27.6.1.5.5  basic_istream::readsome            [lib.istream::readsome]

  int readsome(char_type* s, int n);

  Effects:
    Extracts characters and stores them into successive locations of  an
    array  whose  first  element is designated by s.  The function first
    determines navail, the value returned  by  calling  in_avail().   If
    navail is 1, the function calls setstate(eofbit) and returns zero.

1 Otherwise, the function determines the number of characters to extract
  m as the smaller of n and navail, and returns read(s, m).

  27.6.1.5.6  basic_istream::peek                    [lib.istream::peek]

  int peek();

  Returns:
    eof() if good() is false.  Otherwise, returns rdbuf()->sgetc().

  27.6.1.5.7  basic_istream::putback              [lib.istream::putback]

  istream_type& putback(char_type c);

  Effects:
    Calls rdbuf->sputbackc(c).  If that function  returns  eof(),  calls
    setstate(badbit).
  Returns:
    *this.

  27.6.1.5.8  basic_istream::unget                  [lib.istream::unget]

  istream_type& unget();

  Effects:
    Calls  rdbuf->sungetc().  If that function returns eof(), calls set­
    state(badbit).
  Returns:
    *this.

  27.6.1.5.9  basic_istream::gcount                [lib.istream::gcount]

  streamsize gcount() const;

  Returns:
    The number of characters extracted by  the  last  unformatted  input
    member function called for the object.

  27.6.1.6  Standard basic_istream             [lib.basic.istream.manip]
       manipulators

  namespace std {
    template<class charT, class traits>
      basic_istream<charT,traits>& ws(basic_istream<charT,traits>& is);
  }

  Effects:
    Saves a copy of is.fmtflags, then clears is .skipws in is  .flags().
    Then  calls  is  .ipfx() and is .isfx(), and restores is .flags() to
    its saved value.31)
  Returns:
    is.

  27.6.2  Output streams                            [lib.output.streams]

1 The  header  <ostream>  defines a type and several function signatures
  that control output to a stream buffer.

  27.6.2.1  Template class basic_ostream                   [lib.ostream]
  namespace std {
    template <class charT, class traits = ioc_traits<charT> >
    class basic_ostream : virtual public basic_ios<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    private:
      typedef basic_ostream<charT,traits> ostream_type;
    public:
      basic_ostream(basic_streambuf<char_type,traits>* sb);
      virtual ~basic_ostream();
      bool opfx();
      void osfx();

  _________________________
  31) The effect of cin >> ws is to skip any white space  in  the  input
  sequence controlled by cin.

      ostream_type& operator<<(ostream_type& (*pf)(ostream_type&));
      ostream_type& operator<<(ios_type& (*pf)(ios_type&));
      ostream_type& operator<<(const char_type* s);
      ostream_type& operator<<(char_type c);
      ostream_type& operator<<(bool n);
      ostream_type& operator<<(short n);
      ostream_type& operator<<(unsigned short n);
      ostream_type& operator<<(int n);
      ostream_type& operator<<(unsigned int n);
      ostream_type& operator<<(long n);
      ostream_type& operator<<(unsigned long n);
      ostream_type& operator<<(float f);
      ostream_type& operator<<(double f);
      ostream_type& operator<<(long double f);
      ostream_type& operator<<(void* p);
      ostream_type& operator<<(basic_streambuf<char_type,traits>& sb);
      int put(char_type c);
      ostream_type& write(const char_type* s, streamsize n);
      ostream_type& flush();
    };
  }

1 The class basic_ostream defines a number of member function signatures
  that  assist in formatting and writing output to output sequences con­
  trolled by a stream buffer.

2 Two groups of member function signatures share common properties:  the
  formatted  output  functions (or inserters) and the unformatted output
  functions.  Both groups of output functions generate (or insert)  out­
  put  characters  by  actions equivalent to calling rdbuf().sputc(int).
  They may use other public members of basic_ostream except that they do
  not  invoke  any  tuals  members  of  rdbuf() except overflow.  If the
  called function throws an exception, the output  function  calls  set­
  state(badbit)  and if badbit is on in exceptions() rethrows the excep­
  tion.

  27.6.2.2  basic_ostream constructors       [lib.basic.ostream.sb.cons]

  basic_ostream(basic_streambuf<charT,traits>* sb);

  Effects:
    Constructs an object of class basic_ostream, assigning initial  val­
    ues  to the base class by calling basic_ios<charT,traits>::init(sb).

    virtual ~basic_ostream();

  Effects:
    Destroys an object of class basic_ostream.
  Notes:
    Does not perform any operations on rdbuf().

  27.6.2.3  Member functions                 [lib.basic.ostream.members]

  27.6.2.3.1  basic_ostream::opfx                    [lib.ostream::opfx]

  bool opfx();

1 If good() is nonzero, prepares for formatted  or  unformatted  output.
  If tie() is not a null pointer, calls tie()->flush().32)

  +-------                BEGIN BOX 17                -------+
  Note: Need to append the locale dependency on appropriate  extractors.
  +-------                 END BOX 17                 -------+

  Returns:
    good().33)

  27.6.2.3.2  basic_ostream::osfx                    [lib.ostream::osfx]

  void osfx();

1 If flags() & unitbuf is nonzero, calls flush().

  27.6.2.3.3  basic_ostream::flush                  [lib.ostream::flush]

  basic_ostream& flush();

1 If rdbuf() is not a null pointer, calls rdbuf()->pubsync().   If  that
  function returns eof(), calls setstate(badbit).
  Returns:
    *this.

  27.6.2.4  Formatted output functions           [lib.ostream.formatted]

  27.6.2.4.1  Common requirements         [lib.ostream.formatted.reqmts]

1 Each formatted output function begins execution by calling opfx().  If
  that function returns nonzero, the function endeavors to generate  the
  requested  output.  In any case, the formatted output function ends by
  calling osfx(), then returning the value specified for  the  formatted
  output function.

2 The  numeric  conversion  behaviors  of  the  following  inserters are
  locale-dependent:

  _________________________
  32) The call tie()->flush() does not necessarily occur if the function
  can determine that no synchronization is necessary.
  33)  The  function signatures opfx() and osfx() can also perform addi­
  tional implementation-dependent operations.

    operator<<(short val);
    operator<<(unsigned short val);
    operator<<(int val);
    operator<<(unsigned int val);
    operator<<(long val);
    operator<<(unsigned long val);
    operator<<(float val);
    operator<<(double val);
    operator<<(long double val);

3 The classes num_get<> and num_put<>  handle  locale-dependent  numeric
  formatting  and  parsing.   The  above  inserter  functions refers the
  imbued locale value to utilize these numeric formatting functionality.
  The formatting conversion occurs as if it performed the following code
  fragment:
    num_put<charT>& fmt = loc.use< num_put<charT> >();
    fmt.put (ostreambuf_iterator(*this), *this, loc, val);
  In the above fragment, loc  stands  for  the  private  member  of  the
  basic_ios  class  which  maintains the imbued localeobject.  The first
  argument provides an object of the ostreambuf_iterator class which  is
  an  iterator for ostream class.  It bypasses ostreams and uses stream­
  bufs directly.  Class locale relies on these types as its interface to
  iostreams,  since  for  flexibility  it  has been abstracted away from
  direct dependence on ostream.

4 Some formatted output functions endeavor  to  generate  the  requested
  output  by  converting  a  value from some scalar or NTBS type to text
  form and inserting the converted text in the output sequence.

  +-------                BEGIN BOX 18                -------+
  Needs work:  NTBS.
  +-------                 END BOX 18                 -------+

  The behavior of such functions is described in terms of the conversion
  specification for an equivalent call to the function fprintf,34) oper­
  ating  with  the  global  locale  set  to getloc(), with the following
  alterations:

  --The formatted output function inserts characters in a stream buffer,
    rather than writing them to an output file.35)

  --The formatted output function uses the fill  character  returned  by
    fill() as the padding character (rather than the space character for
    left or right padding, or 0 for internal padding).

5 If the operation fails for any reason, the formatted  output  function
  calls setstate(badbit).
  _________________________
  34)  The  signature fprintf(FILE*, const char_type*, ...)  is declared
  in <cstdio> (_lib.c.files_).
  35)  The  stream  buffer  can, of course, be associated with an output
  file, but it need not be.

6 For  conversion from an integral type other than a character type, the
  function determines the integral conversion specifier as indicated  in
  Table 10:

                      Table 10--Integer conversions

            +------------------------------------------------+
            |           State               stdio equivalent |
            +------------------------------------------------+
            |(flags() & basefield) == oct          %o        |
            +------------------------------------------------+
            |(flags() & basefield) == hex          %x        |
            |(flags() & uppercase) != 0            %X        |
            +------------------------------------------------+
            |Otherwise,                                      |
            +------------------------------------------------+
            |signed integral type                  %d        |
            +------------------------------------------------+
            |unsigned integral type                %u        |
            +------------------------------------------------+

  +-------                BEGIN BOX 19                -------+
  Is this table clear with regards to %x vs.  %X?
  +-------                 END BOX 19                 -------+

7 For conversion from a floating-point type, the function determines the
  floating-point conversion specifier as indicated in Table 11:

  +-------                BEGIN BOX 20                -------+
  Can the current num_put/num_get facet handle basefield  specification?
  Needs more discussion.
  +-------                 END BOX 20                 -------+

                   Table 11--Floating-point conversions

        +--------------------------------------------------------+
        |               State                   stdio equivalent |
        +--------------------------------------------------------+
        |(flags() & floatfield) == fixed               %f        |
        +--------------------------------------------------------+
        |(flags() & floatfield) == scientific          %e        |
        |(flags() & uppercase) != 0                    %E        |
        +--------------------------------------------------------+
        |Otherwise,                                              |
        +--------------------------------------------------------+
        |                                              %g        |
        |(flags() & uppercase) != 0                    %G        |
        +--------------------------------------------------------+

  +-------                BEGIN BOX 21                -------+
  Is this table clear with regards to %e vs.  %E?
  +-------                 END BOX 21                 -------+

8 The  conversion  specifier  has  the  following  additional qualifiers
  prepended as indicated in Table 12:

                   Table 12--Floating-point conversions

  +----------------------------------------------------------------------+
  |       Type(s)                    State              stdio equivalent |
  +----------------------------------------------------------------------+
  |an integral type oth­   (flags() & showpos)   != 0          +         |
  |er than a character     (flags() & showbase)  != 0          #         |
  |type                                                                  |
  +----------------------------------------------------------------------+
  |a floating-point type   (flags() & showpos)   != 0          +         |
  |                        (flags() & showpoint) != 0          #         |
  +----------------------------------------------------------------------+

  --For any conversion, if width() is nonzero, then  a  field  width  is
    specified in the conversion specification.  The value is width().

  --For  conversion  from  a  floating-point type, if flags() & fixed is
    nonzero or if precision() is greater than zero, then a precision  is
    specified  in  the  conversion  specification.   The value is preci­
    sion().

9 Moreover, for any conversion, padding with the fill character returned
  by fill() behaves as follows:

  --If  (flags()  &  adjustfield)  == right, no flag is prepended to the
    conversion  specification,  indicating  right   justification   (any
    padding  occurs before the converted text).  A fill character occurs
    wherever fprintf generates a space character as padding.

  --If (flags() & adjustfield) == internal, the flag 0 is  prepended  to
    the conversion specification, indicating internal justification (any
    padding occurs within the converted text).  A fill character  occurs
    wherever fprintf generates a 0 as padding.36)

10Otherwise, the flag - is prepended to  the  conversion  specification,
  indicating  left justification (any padding occurs after the converted
  text).  A fill character occurs wherever fprintf()  would  generate  a
  space character as padding.

11Unless  explicitly  stated  otherwise  for a particular inserter, each
  formatted output function calls width(0) after determining  the  field
  width.

  27.6.2.4.2  basic_ostream::operator<<          [lib.ostream.inserters]

  ostream_type& operator<<(ostream_type& (*pf)(ostream_type&))

  Returns:
    pf(*this).37)

    ostream_type& operator<<(ios_type& (*pf)(ios_type&))

  Effects:
    Calls (*(basic_ios<charT,traits>*)pf)(*this).
  Returns:
    *this.38)

    ostream_type& operator<<(const char_type* s);

  Effects:
    Converts the NTBS s with the conversion specifier s.
  Returns:
    *this.

    ostream_type& operator<<(char_type c);

  Effects:
    Converts the char_type c with the conversion specifier c and a field
    width     of     zero.39)     The     stored     field    width    (
  _________________________
  36) The conversion specification #o generates a leading 0 which is not
  a padding character.
  37)  See,  for  example,  the  function signature endl(basic_ostream&)
  (_lib.basic.ostream.manip_) .
  38)  See,  for  example,   the   function   signature   dec(ios_base&)
  (_lib.basefield.manip_).
  39) Note that this function is not overloaded on types signed char and

    basic_ios<charT,traits>::width()) is not set to zero.
  Returns:
    *this.

    ostream_type& operator<<(bool n);

1 Behaves as if:
    {
      if (flags() & ios::boolalpha) {
        getloc().insert(*this, n);
      } else {
        *this << int(n);
      }
    }
  Returns:
    *this.

    ostream_type& operator<<(short n);

  Effects:
    Converts the signed short integer n  with  the  integral  conversion
    specifier preceded by h.
  Returns:
    *this.

    ostream_type& operator<<(unsigned short n);

  Effects:
    Converts  the  unsigned short integer n with the integral conversion
    specifier preceded by h.
  Returns:
    *this.

    ostream_type& operator<<(int n);

  Effects:
    Converts the signed integer n with the  integral  conversion  speci­
    fier.
  Returns:
    *this.

    ostream_type& operator<<(unsigned int n);

  Effects:
    Converts  the unsigned integer n with the integral conversion speci­
    fier.
  Returns:
    *this.

  _________________________
  unsigned char.

    ostream_type& operator<<(long n);

  Effects:
    Converts the signed long integer  n  with  the  integral  conversion
    specifier preceded by l.
  Returns:
    *this.

    ostream_type& operator<<(unsigned long n);

  Effects:
    Converts  the  unsigned  long integer n with the integral conversion
    specifier preceded by l.
  Returns:
    *this.

    ostream_type& operator<<(float f);

  Effects:
    Converts the float f with the floating-point conversion specifier.
  Returns:
    *this.

    ostream_type& operator<<(double f);

  Effects:
    Converts the double f with the floating-point conversion  specifier.
  Returns:
    *this.

    ostream_type& operator<<(long double f);

  Effects:
    Converts the long double f with the floating-point conversion speci­
    fier preceded by L.
  Returns:
    *this.

    ostream_type& operator<<(void* p);

  Effects:
    Converts the pointer to void p with the conversion specifier p.
  Returns:
    *this.

    ostream_type& operator<<(basic_streambuf<charT,traits>& sb);

2 Gets characters from rdbuf() and inserts them  in  *this.   Characters
  are read from rdbuf() and inserted until any of the following occurs:

  --end-of-file occurs on the input sequence;

  --inserting  in the output sequence fails (in which case the character
    to be inserted is not extracted); LI an exception occurs while  get­
    ting  a  character  from  rdbuf()  (in  which case, the exception is
    rethrown).

3 If the function inserts no characters or  if  it  stopped  because  an
  exception  was  thrown  while  extracting  a  character, it calls set­
  state(failbit).  If an exception was thrown while extracting a charac­
  ter  and  failbit  is  on  in  exceptions()  the  caught  exception is
  rethrown.
  Returns:
    *this.

  27.6.2.5  Unformatted output functions       [lib.ostream.unformatted]

1 Each unformatted output function begins execution by  calling  opfx().
  If  that  function returns nonzero, the function endeavors to generate
  the requested output.  In any case, the  unformatted  output  function
  ends  by  calling  osfx(),  then returning the value specified for the
  unformatted output function.

  27.6.2.5.1  basic_ostream::put                      [lib.ostream::put]

  int put(char_type c);

  Effects:
    Inserts  the  character  c,  if  possible.40) Then returns (unsigned
    char)c.

1 Otherwise, calls setstate(badbit) and returns eof().

  27.6.2.5.2  basic_ostream::write                  [lib.ostream::write]

  basic_ostream& write(const char_type* s, streamsize n);

  Effects:
    Obtains characters to insert from successive locations of  an  array
    whose first element is designated by s.41) Characters  are  inserted
    until either of the following occurs:

  --n characters are inserted;

  --inserting  in  the output sequence fails (in which case the function
    calls setstate(badbit)).
  Returns:
    *this.

  _________________________
  40) Note that this function is not overloaded on types signed char and
  unsigned char.
  41) Note that this function is not overloaded on types signed char and
  unsigned char.

  27.6.2.6  Standard basic_ostream             [lib.basic.ostream.manip]
       manipulators

  27.6.2.6.1  endl                                            [lib.endl]

  namespace std {
    template<class charT, class traits>
      basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
  }

  Effects:
    Calls os .put(traits::newline()), then os .flush().
  Returns:
    os.42)

  27.6.2.6.2  ends                                            [lib.ends]

  namespce std {
    template<class charT, class traits>
      basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
  }

  Effects:
    Calls os .put(traits::eos()).
  Returns:
    os.43)

  27.6.2.6.3  flush                                          [lib.flush]

  namespace std {
    template<class charT, class traits>
      basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
  }

  Effects:
    Calls os .flush().
  Returns:
    os.

  27.6.3  Standard manipulators                          [lib.std.manip]

  _________________________
  42)  The effect of executing cout << endl is to insert a newline char­
  acter in the output sequence controlled by cout, then  synchronize  it
  with any external file with which it might be associated.
  43)  The effect of executing ostr  << ends is to insert a null charac­
  ter in the output sequence controlled by ostr.  If ostr is  an  object
  of  class basic_strstreambuf, the null character can terminate an NTBS
  constructed in an array object.

  27.6.3.1  Type smanip                                     [lib.smanip]

1 The type smanip is an implementation-defined function type (_dcl.fct_)
  returned by the standard manipulators.

  27.6.3.2  resetiosflags                            [lib.resetiosflags]

  smanip resetiosflags(ios_base::fmtflags mask);

  Returns:
    smanip(f, mask), where f can be defined as:44)
        template<class charT, class traits>
          ios_base& f(ios_base& str,
                            ios_base::fmtflags mask)
          { // reset specified flags
            str.setf(ios_base::fmtflags(0), mask);
            return str;
          }

  27.6.3.3  setiosflags                                [lib.setiosflags]

  smanip setiosflags(ios_base::fmtflags mask);

  Returns:
    smanip(f,mask), where f can be defined as:
          ios_base& f(ios_base& str,
                            ios_base::fmtflags mask)
          { // set specified flags
            str.setf(mask);
            return str;
          }

  27.6.3.4  setbase                                        [lib.setbase]

  smanip setbase(int base);

  Returns:
    smanip(f, base), where f can be defined as:

  _________________________
  44)  The  expression  cin  >>  resetiosflags(ios_base::skipws)  clears
  ios_base::skipws in the format flags stored in the istream object  cin
  (the  same  as  cin >> noskipws), and the expression cout << resetios­
  flags(ios_base::showbase)  clears  ios_base::showbase  in  the  format
  flags  stored  in the ostream object cout (the same as cout << noshow­
  base).

          ios_base& f(ios_base& str, int base)
          { // set basefield
            str.setf(n ==  8 ? ios_base::oct :
                                     n == 10 ? ios_base::dec :
                                     n == 16 ? ios_base::hex :
                                     ios_base::fmtflags(0),
                                     ios_base::basefield);
            return str;
          }

  27.6.3.5  setfill                                        [lib.setfill]

  smanip setfill(int c);

  Returns:
    smanip(f, c), where f can be defined as:
          ios_base& f(ios_base& str, int c)
          { // set fill character
            str.fill(c);
            return str;
          }

  27.6.3.6  setprecision                              [lib.setprecision]

  smanip setprecision(int n);

  Returns:
    smanip(f, n), where f can be defined as:
          ios_base& f(ios_base& str, int n)
          { // set precision
            str.precision(n);
            return str;
          }

  27.6.3.7  setw                                              [lib.setw]

  smanip setw(int n);

  Returns:
    smanip(f, n), where f can be defined as:
          ios_base& f(ios_base& str, int n)
          { // set width
            str.width(n);
            return str;
          }

  27.7  String-based streams                        [lib.string.streams]

  Header <sstream> synopsis

  #include <streambuf>
  #include <istream>
  #include <ostream>

  namespace std {
    template <class charT, class traits = int_charT_traits<charT> >
      class basic_stringbuf;
    typedef basic_stringbuf<char>     stringbuf;
    typedef basic_stringbuf<wchar_t> wstringbuf;

    template <class charT, class traits = ios_traits<charT> >
      class basic_istringstream;
    typedef basic_istringstream<char>     istringstream;
    typedef basic_istringstream<wchar_t> wistringstream;

    template <class charT, class traits = ios_traits<charT> >
      class basic_ostringstream;
    typedef basic_ostringstream<char>     ostringstream;
    typedef basic_ostringstream<wchar_t> wostringstream;
  }

                   Table 12--Header <cstdlib> synopsis

                          +---------------------+
                          |Type      Name(s)    |
                          +---------------------+
                          |Functions:           |
                          |       atoi   strtod |
                          |       atol   strtol |
                          +---------------------+

1
  SEE ALSO: ISO C subclause 7.10.1.

2 The header <sstream> defines three types that associate stream buffers
  with objects of class string, as described in clause _lib.string_.

  27.7.1  Template class basic_stringbuf                 [lib.stringbuf]
  namespace std {
    template <class charT, class traits = int_charT_traits<charT> >
    class basic_stringbuf : public basic_streambuf<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }

    public:
      basic_stringbuf(ios_base::openmode which
                          = ios_base::in
                          | ios_base::out);
      basic_stringbuf(const basic_string<char_type>& str,
                      ios_base::openmode which
                          = ios_base::in
                          | ios_base::out);
      virtual ~basic_stringbuf();
      basic_string<char_type> str() const;
      void str(const basic_string<char_type>& s);
    protected:
  //  virtual int_type   overflow (int_type c = eof());   inherited
  //  virtual int_type   pbackfail(int_type c = eof());   inherited
  //  virtual int        showmany();      inherited
  //  virtual int_type   underflow();     inherited
  //  virtual int_type   uflow();         inherited
  //  virtual streamsize xsgetn(char_type* s, streamsize n);      inherited
  //  virtual streamsize xsputn(const char_type* s, streamsize n);        inherited
  //  virtual pos_type   seekoff(off_type off,
  //                             ios_base::seekdir way,
  //                             ios_base::openmode which
  //                               = ios_base::in
  //                               | ios_base::out);      inherited
  //  virtual pos_type   seekpos(pos_type sp,
  //                             ios_base::openmode which
  //                               = ios_base::in
  //                               | ios_base::out);      inherited
  //  virtual basic_streambuf<char_type,traits>*
  //                     setbuf(char_type* s, streamsize n);      inherited
  //  virtual int sync();         inherited
    private:
  //  ios_base::openmode mode;    exposition only
    };
  }

  +-------                BEGIN BOX 22                -------+
  Note: same charT type string can be fed.
  +-------                 END BOX 22                 -------+

1 The class basic_stringbuf is derived from basic_streambuf to associate
  possibly the input sequence and possibly the output  sequence  with  a
  sequence  of  arbitrary  characters.   The sequence can be initialized
  from, or made available as, an object of class basic_string.

  +-------                BEGIN BOX 23                -------+
  For the sake of exposition, the maintained data is presented here as:

  --ios_base::openmode mode, has in set if the  input  sequence  can  be
    read, and out set if the output sequence can be written.

2 For the sake of exposition, the stored character sequence is described
  here as an array object.
  +-------                 END BOX 23                 -------+

  +-------                BEGIN BOX 24                -------+
  The descriptions of the virtuals in this class need to be brought into
  agreement with the new descriptions of the generic protocols.  As part
  of that we have

  //
  //  string             data ; exposition only

  +-------                 END BOX 24                 -------+

  27.7.1.1  basic_stringbuf                   [lib.basic.stringbuf.cons]
       constructors

  basic_stringbuf(ios_base::openmode which = ios_base::in
                  ios_base::out);

  Effects:
    Constructs an object of class basic_stringbuf, initializing the base
    class with basic_streambuf(), and initializing mode with which.  The
    function allocates no array object.

    basic_stringbuf(const basic_string<char_type>& str,
                    ios_base::openmode which = ios_base::in
                    ios_base::out);

  Effects:
    Constructs an object of class basic_stringbuf, initializing the base
    class with basic_streambuf(), and initializing mode with which.
  Notes:
    If str .length() is nonzero, the function allocates an array  object
    x  whose  length n is str .length() and whose elements x[I] are ini­
    tialized to str[I].  If which  & basic_ios::in is nonzero, the func­
    tion executes: setg(x,x,x+n);
    If  which    &  basic_ios::out  is  nonzero,  the function executes:
    setp(x,x+n);

  27.7.1.2  Member functions                     [lib.stringbuf.members]

  27.7.1.2.1  basic_stringbuf::str                  [lib.stringbuf::str]

  basic_string<char_type> str() const;

  Returns:
    The return value of this function are indicated in Table 13:

                        Table 13--str return values

  +------------------------------------------------------------------------+
  |      Condition                          Return Value                   |
  +------------------------------------------------------------------------+
  (mode & basic_ios::in) basic_string<char_type>(eback(),egptr() - eback())|
  != 0 and (gptr() != 0)                                                   |
  +------------------------------------------------------------------------+
  (mode & basic_ios::out)basic_string<char_type>(pbase(),pptr - pbase())   |
  != 0 and (pptr() != 0                                                    |
  +------------------------------------------------------------------------+
  |Otherwise              basic_string<char_type>()                         |
  +------------------------------------------------------------------------+

    void str(const basic_string<char_type>& s);

  Effects:
    If s.length() is zero, executes:
        setg(0, 0, 0);
        setp(0, 0);
    and frees storage for any associated array object.   Otherwise,  the
    function  allocates an array object x whose length n is str.length()
    and whose elements x[I] are  initialized  to  str[I].   If  which  &
    ios_base::in  != 0, the function executes: setg(x,x,x+n); If which &
    ios_base::out != 0, the function executes: setp(x,x+n);

  27.7.1.2.2  basic_stringbuf::overflow        [lib.stringbuf::overflow]

  //  virtual int_type overflow(int_type c = eof());    inherited

  Effects:
    Appends the character designated by c to  the  output  sequence,  if
    possible, in one of two ways:

  --If c != eof() and if either the output sequence has a write position
    available or the function  makes  a  write  position  available  (as
    described below), the function calls sputc(c).
    Signals success by returning c.

  --If c == eof(), there is no character to append.
    Signals success by returning a value other than eof().
  Notes:
    The  function can alter the number of write positions available as a
    result of any call.
  Returns:
    eof() to indicate failure.

1 The function can make a write  position  available  only  if  (mode  &
  ios_base::out) != 0.  To make a write position available, the function
  reallocates (or initially allocates) an array object with a sufficient

  number of elements to hold the current array object (if any), plus one
  additional write position.  If (mode & ios_base::in) != 0,  the  func­
  tion  alters  the  read end pointer egptr() to point just past the new
  write position (as does the write end pointer epptr()).

  27.7.1.2.3  basic_stringbuf::pbackfail      [lib.stringbuf::pbackfail]

  //  virtual int_type pbackfail(int_type c = eof());    inherited

  +-------                BEGIN BOX 25                -------+
  Check vs. _lib.streambuf::pbackfail_ and _lib.filebuf::pbackfail_
  +-------                 END BOX 25                 -------+

  Effects:
    Puts  back  the  character designated by c to the input sequence, if
    possible, in one of three ways:

  --If c != eof(), if the input sequence has a putback  position  avail­
    able, and if char_type(c) == char_type(gptr()[-1]), assigns gptr() -
    1 to gptr().
    Returns: c.

  --If c != eof(), if the input sequence has a putback  position  avail­
    able,  and  if  mode  &  ios_base::out  is  nonzero,  assigns  c  to
    *--gptr().
    Returns: char_type(c).

  --If c == eof() and if the  input  sequence  has  a  putback  position
    available, assigns gptr() - 1 to gptr().
    Returns: char_type(c).
  Returns:
    eof() to indicate failure.
  Notes:
    If  the  function  can succeed in more than one of these ways, it is
    unspecified which way is chosen.

  27.7.1.2.4  basic_stringbuf::underflow      [lib.stringbuf::underflow]

  //  virtual int_type underflow();    inherited

  Returns:
    If  the  input  sequence  has  a  read  position  available, returns
    char_type(*gptr()).
    Otherwise, returns eof().

  27.7.1.2.5  basic_stringbuf::seekoff          [lib.stringbuf::seekoff]

  //  virtual pos_type seekoff(off_type off, ios_base::seekdir way,
  //                           ios_base::openmode which
  //                               = ios_base::in | ios_base::out);    inherited

  +-------                BEGIN BOX 26                -------+
  Check vs. _lib.filebuf::seekpos_
  +-------                 END BOX 26                 -------+

  Effects:
    Alters the stream position within one of the  controlled  sequences,
    if possible, as indicated in Table 14:

                       Table 14--seekoff positioning

  +----------------------------------------------------------------------------+
  |        Conditions                              Result                      |
  +----------------------------------------------------------------------------+
  (which & basic_ios::in) != 0positions the input sequence                     |
  +----------------------------------------------------------------------------+
  (which& basic_ios::out) != 0positions the output sequence                    |
  +----------------------------------------------------------------------------+
  |Otherwise,                                                                   |
  (which & (basic_ios::in |   positions both the input and the output sequences|
  basic_ios::out)) == (ba­                                                     |
  sic_ios::in | ba­                                                            |
  sic_ios::out))                                                               |
  |and way == either ba­                                                        |
  sic_ios::beg or ba­                                                          |
  sic_ios::end                                                                 |
  +----------------------------------------------------------------------------+
  Otherwise,                  the positioning operation fails.                 |
  +----------------------------------------------------------------------------+

1 For a sequence to be  positioned,  if  its  next  pointer  is  a  null
  pointer,  the  positioning  operation  fails.  Otherwise, the function
  determines newoff as indicated in Table 15:

                         Table 15--newoff values

        +---------------------------------------------------------+
        |      Condition                   newoff Value           |
        +---------------------------------------------------------+
        |way == basic_ios::beg    0                               |
        +---------------------------------------------------------+
        |way == basic_ios::cur    the next pointer minus the be­  |
        |                         ginning pointer (xnext - xbeg). |
        +---------------------------------------------------------+
        |way == basic_ios::end    the end pointer minus the be­   |
        |                         ginning pointer (xend - xbeg)   |
        +---------------------------------------------------------+
        |If (newoff + off) < 0,   the positioning operation fails |
        |or (xend - xbeg) <                                       |
        |(newoff + off)                                           |
        +---------------------------------------------------------+

2 Otherwise, the function assigns xbeg  +  newoff  +  off  to  the  next
  pointer xnext.
  Returns:
    pos_type(newoff),  constructed  from the resultant offset newoff (of
    type off_type), that stores the resultant stream position, if possi­
    ble.   If  the  positioning  operation  fails, or if the constructed
    object cannot represent the resultant stream  position,  the  object
    stores an invalid stream position.

  27.7.1.2.6  basic_stringbuf::seekpos          [lib.stringbuf::seekpos]

  //  virtual pos_type seekpos(pos_type sp,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);    inherited

  +-------                BEGIN BOX 27                -------+
  Check vs. _lib.filebuf::seekpos_
  +-------                 END BOX 27                 -------+

  Effects:
    Alters  the  stream position within one of the controlled sequences,
    if possible, to correspond to the stream position stored in  sp  (as
    described below).

  --If (which & basic_ios::in)  != 0, positions the input sequence.

  --If (which & basic_ios::out) != 0, positions the output sequence.

  --If  the  function positions neither sequence, the positioning opera­
    tion fails.

1 For a sequence to be  positioned,  if  its  next  pointer  is  a  null
  pointer,  the  positioning  operation  fails.  Otherwise, the function
  determines newoff from sp.offset():

  --If newoff is an invalid stream position, has a  negative  value,  or
    has  a  value  greater than (xend - xbeg), the positioning operation
    fails.

  --Otherwise, the function adds newoff to the  beginning  pointer  xbeg
    and stores the result in the next pointer xnext.
  Returns:
    pos_type(newoff),  constructed  from the resultant offset newoff (of
    type off_type), that stores the resultant stream position, if possi­
    ble.   If  the  positioning  operation  fails, or if the constructed
    object cannot represent the resultant stream  position,  the  object
    stores an invalid stream position.

  27.7.1.2.7  basic_stringbuf::setbuf            [lib.stringbuf::setbuf]

  //  virtual basic_streambuf<charT,traits>*
  //      setbuf(char_type* s, streamsize n);    inherited

  Effects:
    Performs  an  operation  that  is  defined separately for each class
    derived from basic_stringbuf<charT,traits>.
  Default behavior:
    The    same    as    for    basic_streambuf<charT,traits>::     set­
    buf(char_type*,streamsize).

  27.7.2  Template class basic_istringstream         [lib.istringstream]
  namespace std {
    template <class charT, class traits = ios_traits<charT> >
    class basic_istringstream : public basic_istream<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    public:
      basic_istringstream(ios_base::openmode which
                              = ios_base::in);
      basic_istringstream(const basic_string<charT>& str,
                          ios_base::openmode which
                              = ios_base::in);
      virtual ~basic_istringstream();
      basic_stringbuf<charT,traits>* rdbuf() const;
      basic_string<charT> str() const;
      void str(const basic_string<charT>& s);
    };
  }

1 The   class   basic_istringstream<charT,traits>  is  a  derivative  of
  basic_istream<charT,traits> that assists in the reading of objects  of
  class  basic_stringbuf<charT,traits>.   It  supplies a basic_stringbuf
  object to control the associated array object.

  27.7.2.1  basic_istringstream         [lib.basic.istringstream.m.cons]
       constructors

  basic_istringstream(ios_base::openmode which
     = ios_base::in);

  Effects:
    Constructs  an  object  of  class basic_istringstream<charT,traits>,
    initializing the base class with basic_istream<charT,traits>(&sb).

    basic_istringstream(const basic_string<charT>& str,
                        ios_base::openmode which = ios_base::in);

  Effects:
    Constructs an  object  of  class  basic_istringstream<charT,traits>,
    initializing the base class with basic_istream<charT,traits>(&sb).

  27.7.2.2  Member functions                 [lib.istringstream.members]

  27.7.2.2.1  basic_istringstream::rdbuf      [lib.istringstream::rdbuf]

  basic_stringbuf<charT,traits>* rdbuf() const;

  Returns:
    dynamic_cast<basic_stringbuf<charT,traits>*>
    (basic_istream<harT,traits>::rdbuf()).

  27.7.2.2.2  basic_istringstream::str          [lib.istringstream::str]

  basic_string<charT> str() const;

  Returns:
    rdbuf().str().

    void str(const basic_string<charT>& s);

  Effects:
    Calls rdbuf().str(s).

  27.7.2.3  Class basic_ostringstream                [lib.ostringstream]

  namespace std {
    template <class charT, class traits = ios_traits<charT> >
    class basic_ostringstream : public basic_ostream<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    public:
      basic_ostringstream(ios_base::openmode which
                              = ios_base::out);
      basic_ostringstream(const basic_string<charT>& str,
                          ios_base::openmode which
                              = ios_base::out);
      virtual ~basic_ostringstream();
      basic_stringbuf<charT,traits>* rdbuf() const;
      basic_string<charT> str() const;
      void str(const basic_string<charT>& s);
    };
  }

1 The   class   basic_ostringstream<charT,traits>  is  a  derivative  of
  basic_ostream<charT,traits> that assists in the writing of objects  of
  class  basic_stringbuf<charT,traits>.   It  supplies a basic_stringbuf
  object to control the associated array object.

  27.7.2.4  basic_ostringstream           [lib.basic.ostringstream.cons]
       constructors

  basic_ostringstream(ios_base::openmode which
     = ios_base::out);

  Effects:
    Constructs  an object of class basic_ostringstream, initializing the
    base class with basic_ostream(&sb).

    basic_ostringstream(const basic_string<charT>& str,
                        ios_base::openmode which = ios_base::out);

  Effects:
    Constructs an  object  of  class  basic_ostringstream<charT,traits>,
    initializing the base class with basic_ostream<charT,traits>(&sb).

  27.7.2.5  Member functions                 [lib.ostringstream.members]

  27.7.2.5.1  basic_ostringstream::rdbuf      [lib.ostringstream::rdbuf]

  basic_stringbuf<charT,traits>* rdbuf() const;

  Returns:
    dynamic_cast<basic_stringbuf<charT,tratis>*>

    (basic_ostream<charT,traits>::rdbuf()).

  27.7.2.5.2  basic_ostringstream::str          [lib.ostringstream::str]

  basic_string<charT> str() const;

  Returns:
    rdbuf().str().

    void str(const basic_string<charT>& s);

  Effects:
    Calls rdbuf().str(s).

  27.8  File-based streams                            [lib.file.streams]

1 Headers: <cstream> and <fstream> (Table 16):

  +-------                BEGIN BOX 28                -------+
  ISSUE: Disposition of <cstream> and convbuf (next 10.5 pages) TBD.
  +-------                 END BOX 28                 -------+

                   Table 16--Header <cstream> synopsis

  +-----------------------------------------------------------------------+
  |      Type                               Name(s)                       |
  +-----------------------------------------------------------------------+
  |Template class:     basic_convbuf                                      |
  +-----------------------------------------------------------------------+
  |Template structs:   conv_traits            ios_conv_traits             |
  +-----------------------------------------------------------------------+
  |Structs:            conv_traits<wchar_t>   ios_conv_traits<wstreampos> |
  +-----------------------------------------------------------------------+

  27.8.1  Multi-byte conversions                     [lib.conv.fstreams]

1 The  header  <cstream> defines one type, basic_convbuf that associates
  its internal stream buffers holding a sequence of characters with  the
  external source/sink stream representing a sequence of another type of
  characters.

  --Conversion There is a bidirectional conversion between the  external
    source/sink stream and character sequences held in the basic_convbuf
    class object.

  --uchar_type:  underlaid  character  container   type   The   external
    source/sink stream can be regarded as a sequence of a character con­
    tainer type, which may be different to charT.   The  character  con­
    tainer  type on the external source/sink stream is called the under­
    laid character container type, or uchar_type.

  --Encoding rule Performing the conversion from a uchar_type  character
    sequences to the corresponding character sequence, the basic_convbuf
    may parse the uchar_type sequence to extract the corresponding char­
    acter  represented  on the uchar_type sequence.  The rule how a cer­
    tain character is to be represented  on  a  sequence  of  uchar_type
    characters  is  called  the encoding rule.  The basic_convbuf can be
    regarded as having a (virtual) conversion machine  which  obeys  the
    encoding rule to parse uchar_type sequences.

  --Conversion  state The conversion machine has its internal state cor­
    responding to a certain position of the external source/sink stream.
    If the basic_convbuf stops the conversion to resume later, it has to
    save its internal state, so a class or a type is prepared for saving
    the  state onto it so that an user of the basic_convbuf class object
    can handle it.  The class (or the type)  is  called  the  conversion
    state.

  --

  +-------                BEGIN BOX 29                -------+
  Multibyte  character  I/O support The basic_convbuf can support multi­
  byte character file I/O operations.  Provided that the code conversion
  functions  between  multibyte  characters and wide characters are pre­
  pared, we may specify the conversion state, and the  conversion  func­
  tions in the ios_conv_traits so that the basic_convbuf can handle this
  multibyte characters.
  +-------                 END BOX 29                 -------+

  27.8.1.1  Template class conv_traits                 [lib.conv.traits]

  template <class charT> struct conv_traits {}

  struct conv_traits<wchar_t> {
      typedef ios_traits<wchar_t>   char_traits;
      typedef ios_traits<wstreampos> pos_traits;
      typedef ios_conv_traits<state_t>   conv_traits;
  };

1 The template struct conv_traits<charT> is a  traits  classwhich  main­
  tains  the  definitions of the types and functions necessary to imple­
  ment the template class basic_convbuf.  The template  parameter  charT
  reprsents the character container type and each specialized version of
  conv_traits provides the default definitions corresponding to the spe­
  cialized character container type.

2 The  conv_traits<charT>  declaration  has  three  members, ios_traits,
  ios_traits, and ios_conv_traits.

3 Although the former two of them are same as in the  ios_traits<charT>,
  the  last  traits, ios_conv_traits<charT> provides all the definitions

  about types and functions necessary to perform conversion.

  27.8.1.2  Template class ios_conv_traits         [lib.ios.conv.traits]

  template <class stateT> struct ios_conv_traits {};

1 As is the other traits structs, there is no definition in the declara­
  tion  of the template struct, ios_conv_traits.  All of the definitions
  related to the conversion and  necessary  to  implement  basic_convbuf
  class     shall     be     provided    in    a    template    version,
  ios_conv_traits<STATE_T> specialized for a conversion state STATE_T.

  27.8.1.2.1  Struct                       [lib.ios.conv.traits.state.t]
       ios_conv_traits<STATE_T>
  struct ios_conv_traits<STATE_T> {
      typedef CHAR_T  char_type;
      typedef STATE_T conv_state;
      typedef UPOS_T  conv_upos;
      typedef UCHAR_T uchar_type;
      typedef POS_T   pos_type;
      typedef OFF_T   off_type;
      typedef codecnv<uchar_type,char_type,conv_state> codecvt_in;
      typedef codecnv<char_type,uchar_type,conv_state> codecvt_out;
      result convin(codecvt_in*, conv_state&,
              const uchar_type*, const uchar_type*, const uchar_type*&,
              char_type*, char_typeT*, char_type*&);
      result convout(codecvt_out*, conv_state&,
              const char_type*, const char_type*, const char_type*&,
              uchar_type*, uchar_type*, uchar_type*&);
      pos_type   get_pos(conv_state&, conv_upos&);
      off_type   get_off(conv_state&, conv_upos&);
      conv_state get_posstate pos_type&);
      conv_state get_offstate(off_type&);
      conv_upos  get_posupos (pos_type&);
      conv_upos  get_offupos (off_type&);
  };

1 A  specialized version of the struct ios_conv_traits<STATE_T>is neces­
  sary to use the basic_convbufclass.  In order to construct a  special­
  ized  version  of the struct, the following set of types and functions
  shall be provided.

  --CHAR_T : is the character container type which shall be same as  the
    template parameter of the class, conv_traits.

  --STATE_T  :  is  the  conversion  state  type which also the template
    parameter type of this traits.   It  is  the  parsing/tracing  state
    which the function, convin and convout are taken.

  --Every  type of conversion states have a state, called initial state,
    which corresponds to the state beginning to parse  a  new  sequence.
    The    constructor,    STATE_T::STATE_T()   or   STATE_T::STATE_T(0)

    constructs the initial state.

  --UCHAR_T : is the underlaid character container type for the external
    source/sink stream handled by the basic_convbuf.

  --UPOS_T  :  is  the  repositional  information  type for the external
    source/sink stream.  It is used  to  implement  the  seekpos/seekoff
    member functions in the basic_convbuf.

  --POS_T : is the repositional information which the basic_convbuf sup­
    ports for the client of the object.  It shall be  the  same  as  the
    template  parameter  type  of  the  struct  ios_traits  in  the same
    conv_traits.

  --OFF_T : is an integral type which is used as the repositional infor­
    mation which the basic_convbufsupports.

  27.8.1.2.1.1  convin             [lib.ios.conv.traits.state.t::convin]

  result
  vin(codecvt_in* ccvt, conv_state& stat,
      const uchar_type* from, const uchar_type* from_end,
      const uchar_type*& from_next,
      char_type* to, char_typeT* to_limit, char_type*& to_next);

1 The  conversion  state designated by stat represents the parsing state
  on the underlaid source sequence.  According to the  conversion  state
  designated  by  stat, it begins to parse the source character sequence
  whose begining and end position designated by  from  and  from_end  to
  convert them.  It stores the result sequence (if any) into the succes­
  sive location of an array pointed to by to and to_limit.  The  conver­
  sion stops when either of the following occurs:

  1)parses  all of the underlaid character sequences and stores the last
    character into the destination array.

  2)fills all of the destination array and no more room to store.

  3)encounters an invalid underlaid character in the source sequence.

2 In case (1), it returns ok.  In case (2), it returns partial.  In case
  (3), it returns error.

3 In all cases it leaves the from_next and to_next pointers pointing one
  beyond the last character successfully converted and leaves  the  con­
  version state onto the stat for the next time conversion.  If case (3)
  occurs, the conversion state on the stat becomes undefined value.   No
  more conversion with the value is available.

4 If  the locale-dependent conversion functions are needed, the nconver­
  sion function which the codecvt facet object, ccnv provides is  avail­
  able as the following invokation:

  ccnv.convert(stat, from, from_end, from_next, to, to_limit, to_next);

5 The  default conversion function depends on the locale_codecvt facets.
  Users can customize the encoding scheme by specifying their  own  con­
  version functions in a new conv_traits class.

  27.8.1.2.1.2  convout           [lib.ios.conv.traits.state.t::convout]

  result convout(codecvt_out* ccvt, conv_state&,
              const char_type from*, const char_type* from_end,
              const char_type*& from_next.,
              uchar_type*, uchar_type*, uchar_type*&);

1 The  conversion  state designated by stat represents the parsing state
  on the underlaid destination  sequence.   It  begins  to  convert  the
  source  character  sequence whose begining and end position designated
  by from and from_end.  According to the conversion state designated by
  stat, it stores the result destination underlaid chracter sequence (if
  any) into the successive location of an array pointed  to  by  to  and
  to_limit.  The conversion stops when either of the following occurs:

  1)consumes  all  of the source character sequences and stores the last
    underlaid character into the destination array.

  2)fills all of the destination array and no more room to store.

  3)encounters an invalid character in the source sequence.

2 In case (1), it returns ok.  In case (2), it returns partial.  In case
  (3), it returns error.

3 In all cases it leaves the from_next and to_next pointers pointing one
  beyond the last character successfully converted and leaves  the  con­
  version state onto the stat for the next time conversion.  If case (3)
  occurs, the conversion state on the stat becomes undefined value.   No
  more conversion with the value is available.

4 If  the  locale-dependent conversion functions are needed, the conver­
  sion function which the codecvt facet object, ccnv provides is  avail­
  able as the following invocation;

  ccnv.convert(stat, from, from_end, from_next, to, to_limit, to_next);

5 The  default  conversion  function  is  depends  on the locale_codecvt
  facets.  Users can customize the encoding scheme by  specifying  their
  own conversion functions in a new conv_traits class.

  27.8.1.2.1.3  get_pos and       [lib.ios.conv.traits.state.t::get.pos]
       get_off

  pos_type get_pos(conv_state& stat, conv_upos& upos);
  off_type get_off(conv_state&, conv_upos&);

  Effects:
    Constructs the pos_type object or off_type object from  the  conver­
    sion  state, stat and the repositional information for the underlaid
    stream, upos and returns it.  These are  used  to  make  the  return
    value  of  the basic_convbuf::seekpos/seekoff protected member func­
    tion.

  27.8.1.2.1.4              [lib.ios.conv.traits.state.t::get.pos.state]
       get_posstate
       and
       get_offstate

  conv_state get_posstate(pos_type& pos);
  conv_state get_offstate(off_type& off);

1 Extract the conversion state held by the repositional information, pos
  or off.  These are used to reset the conversion  state  maintained  in
  the basic_convbuf class object when the basic_convbuf::seetpos/seekoff
  functions are performed.

  27.8.1.2.1.5               [lib.ios.conv.traits.state.t::get.pos.upos]
       ios_conv_traits<STATE_T>::get_posupos
       and get_offupos

  conv_upos  get_posupos(pos_type&);
  conv_upos  get_offupos(off_type&);

1 Extract the repositioning information for the  underlaid  stream  from
  the  repositioning information on the basic_convbuf stream.  These are
  used in the basic_convbuf::seekpos/seekoff protected member  functions
  to reposition the external source/sink stream.

  27.8.1.2.2  Struct                    [lib.ios.conv.traits.wstreampos]
       ios_conv_traits<wstreampos>
  struct ios_conv_traits<wstreampos> {
      typedef wchar_t char_type;
      typedef STATE_T conv_state;
      typedef UPOS_T  conv_upos;
      typedef char    uchar_type;
      typedef wstreampos pos_type;
      typedef wstreamoff off_type;
      typedef codecnv<char,wchar_t,STATE_T> codecnv_in;
      typedef codecnv<wchar_t,char,STATE_T> codecnv_out;

      result convin(codecvt_in* ccvt, conv_state& stat,
             const char *from, const char* from_end, const char*& from_next,
             wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) {
              return ccvt->convert (stat, from, from_end, from_next,
                   to, to_limit, to_next);
          }
      result convout(codecvt_out* ccvt, conv_state& stat,
             const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next,
             char* to, char* to_limit, char* to_next) {
              return ccvt->convert (stat, from, from_end, from_next,
                   to, to_limit, to_next);
          }
      pos_type   get_pos(conv_state&, conv_upos&);
      off_type   get_off(conv_state&, conv_upos&);
      conv_state get_posstate(pos_type&);
      conv_state get_offstate(off_type&);
      conv_upos  get_posupos (pos_type&);
      conv_upos  get_offupos (off_type&);
  };

1 The  specialized  version  of  the struct, ios_conv_traits<wstreampos>
  supports the wide-oriented  basic_convbuf  class  and  the  conversion
  between  wide  characters  and  multibyte  characters as the underlaid
  character sequence.  The types, STATE_T and UPOS_T are implementation-
  defined  types.   The  behavior  of the conversion functions depend on
  those of the locale object.

2 The encoding rule  of  the  multibyte  characters  is  implementation-
  defined.

  27.8.1.3  Template class basic_convbuf             [lib.basic.convbuf]
  template <class charT, class traits = conv_traits<charT> >
  class basic_convbuf : public basic_streambuf<charT,traits> {
  public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
  private:
      typedef traits::conv_traits::conv_state state_type;
      typedef traits::conv_traits::conv_upos upos_type ;
  public:
      basic_convbuf();
      virtual ~basic_convbuf();

  protected:
  //  virtual int_type overflow (int_type c = eof());     inherited
  //  virtual int_type pbackfail(int_type c = eof());     inherited
  //  virtual int_type underflow();                                       inherited
  //  virtual int_type uflow();                                           inherited
  //  virtual streamsize xsgetn(charT* s, streamsize n);          inherited
  //  virtual streamsize xsputn(const charT* s, streamsize n);    inherited
  //  virtual pos_type seekoff(off_type, ios_base::seekdir way,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);        inherited
  //  virtual pos_type seekpos(pos_type  sp, ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);        inherited
  //  virtual basic_streambuf<charT,traits>*
  //                   setbuf(charT* s, streamsize n);    inherited
  //  virtual int sync();         inherited
  private:
  //  state_type state;   exposition only
  };

1 The   template   class  basic_convbuf<charT,traits>  is  derived  from
  basic_streambuf<charT,traits> to associate the character sequences and
  the underlaid character sequences.  It performs the conversion between
  these two types of chracter sequences.

2 For the sake of exposition, the basic_convbuf maintains the conversion
  state  to  restart the conversion to read/write the character sequence
  from/to the underlaid stream.

  27.8.1.3.1  basic_convbuf  constructor        [lib.basic.convbuf.cons]

  basic_convbuf();

  Effects:
    Constructs an object of template class  basic_convbuf<charT,traits>,
    initializing  the  base  class with basic_streambuf<charT,traits>(),
    and initializing;

  --state with state_type(0) as to specify initial state.

  27.8.1.3.2  basic_convbuf  destructor          [lib.basic.convbuf.des]

  virtual ~basic_convbuf();

  Effects:
    Destroys an object of class basic_convbuf<charT,traits>.

  27.8.1.3.3  basic_convbuf::overflow       [lib.basic.convbuf.overflow]

  virtual int_type overflow(int_type c = eof());

  Effects:
    Behaves  the  same  as   basic_streambuf<charT,traits>::overflow(c),
    except that the behavior of ``consuming a character'' is as follows:

  --(1) Converting the characters to  be  consumed  into  the  underlaid
    character sequence with the function traits::conv_traits::convout().

  --(2) The result underlaid character sequence is appended to the asso­
    ciated output stream.

  27.8.1.3.4                              [lib.basic.convbuf::pbackfail]
       basic_convbuf::pbackfail

  virtual int_type pbackfail(int_type c);

  Effects:
    Puts back the character designated by c to the  input  sequence,  if
    possible, in one of three ways:

  +-------                BEGIN BOX 30                -------+
  Because  the parsing on the underlaid character sequence generally can
  only go advance or most of parsing machined cannot go  back,  some  of
  the   basic_convbuf   implementations  cannot  ``put  back  characters
  directly to the associated input sequence.''  So the behaviors related
  to putting back the associated input stream are removed.
  +-------                 END BOX 30                 -------+

  --If  c  != eof(), if either the input sequence has a putback position
    available or the function makes a putback position available, and if
    (charT)c  ==  (charT)gptr()[-1],  assigns  gptr()  -  1  to  gptr().
    Returns (charT)c.

  --If c != eof(), if either the input sequence has a  putback  position
    available or the function makes a putback position available, and if
    the function is permitted to assign to the putback position, assigns
    c to *--gptr().  Returns (charT)c.

  --If  c  == eof() and if either the input sequence has a putback posi­
    tion available or the function makes a putback  posotion  available,
    assigns gptr() - 1 to gptr().  Returns (charT)c.
  Returns:
    eof() to signal the failure.
  Notes:

1 The  function  does  not  put  back  a character directly to the input
  sequence.

2 If the function can succeed in more than one  of  these  ways,  it  is
  unspecified which way is chosen.  The function can alter the number of
  putback positions available as a result of any call.

3 Default behavior:  returns traits::eof().

  27.8.1.3.5                              [lib.basic.convbuf::underflow]
       basic_convbuf::underflow

  //  virtual int_type underflow();    inherited

  Returns:
    the  first  character  of the pending sequence, if possible, without
    moving the stream position past it.  If the pending sequence is null
    then the function fails.

1 The pending sequence of characters is defined as the concatenation of:

  a)If gptr() is non- NULL, then the egptr() - gptr() characters  start­
    ing at gptr(), otherwise the empty sequence.

  b)Some  sequence  (possibly  empty)  of characters read from the input
    stream.

  --These underlaid character sequence shall be converted by  the  func­
    tion traits::conv_traits::convin() before concatinating to construct
    the pending sequence.  In case that  there  remains  some  underlaid
    characters  which  cannot  be  converted  to any more characters, we
    treat it empty as the subsequence (b).

2 The result character is the first character of the  pending  sequence,
  if any.  The backup sequence is defined as the concatenation of:

  a)If  eback()  is non- NULL then empty, otherwise the gptr() - eback()
    characters beginning at eback().

  b)the result character.

3 The function sets up gptr() and egptr() satisfying:

  a)In case the pending sequence has more than one character the egptr()
    -  gptr()  characters  starting  at gptr() are the characters in the
    pending sequence after the result character.

  b)If the pending sequence has exactly one character, then  gptr()  and
    egptr()  may  be  NULL  or  may  both  be  set to the same non- NULL
    pointer.

4 If eback() and gptr() are non- NULL then  the  function  is  not  con­
  strained as to their contents, but the ``unusual backup condition'' is
  that either:

  a)If the backup sequence contains at least gptr()  -  eback()  charac­
    ters, then the gptr() - eback() characters starting at eback() agree
    with the last gptr() - eback() characters of the backup sequence.

  b)Or the n characters starting a gptr() -  n  agree  with  the  backup

    sequence (where n is the length of the backup sequence)
  Returns:
    eof() to indicate failure.

5 Default behavior:  returns traits::eof().

  27.8.1.3.6  basic_convbuf::seekoff              [lib.convbuf::seekoff]

  //  virtual pos_type seekoff(off_type off, ios_base::seekdir way,
  //      ios_base::openmode which
  //        = ios_base::in | ios_base::out);    inherited

  Effects:
    Behaves                  the                 same                 as
    basic_streambuf<charT,traits>::seekoff(off,way,which),  except  that
    the behavior ``alters the stream position'' means that:

  --(a)  altering the underlaid character stream position which they get
    with         the         return         value         of         the
    traits::conv_traits::get_posupos(off_type&); and,

  --(b)  restoring the current conversion state by resetting the member,
    state      with      the       return       value       of       the
    traits::conv_traits::get_offstate(off_type&).

  27.8.1.3.7  basic_convbuf::seekpos              [lib.convbuf::seekpos]

  //  virtual pos_type seekpos(pos_type sp,
  //      ios_base::openmode which
  //        = ios_base::in | ios_base::out);    inherited

1 At  first  do sync() to clear up the get buffer, and alters the stream
  position, as follows:

  --(a) altering the underlaid character stream position  by  which  the
    function, traits::conv_traits::get_posupos(pos), returns.  and,

  --(b)  restoring  the  member,  state  with  the  return  value of the
    traits::conv_traits::get_posstate(pos).
  Returns:
    pos_type, newpos, constructed from the resultant upos and  state  if
    both (a) and (b) are successfully terminated.

2 If either or both (a) or/and (b) fail(s), or if the constructed object
  cannot represent the resultant stream position, the object  stores  an
  invalid stream position.

3 Whichever   value   is   specified   in   the  which  parameters,  the
  basic_convbuf handles only one external source/sink stream.

4 If (a) succeeds, returns a newly constructed streampos object returned
  by  traits::conv_traits::get_pos(state,  upos)  where upos is a UPOS_T

  type object which represent the  current  position  of  the  underlaid
  stream.

5 Otherwise, the object stores an invalid stream position.

  27.8.1.3.8  basic_convbuf::setbuf                [lib.convbuf::setbuf]

  //  virtual basic_streambuf<charT,traits>*
  //      setbuf(char_type* s, streamsize n);    inherited

1 Makes  the array of n ( charT type) characters, whose first element is
  designated by s, available for use as a buffer area for the controlled
  sequences, if possible.

  +-------                BEGIN BOX 31                -------+
  The  basic_convbuf  does  not  fix the buffer management strategy.  It
  remains alternatives for the derived class designers.
  +-------                 END BOX 31                 -------+

  27.8.1.3.9  basic_convbuf::sync                    [lib.convbuf::sync]

  //  virtual int sync();    inherited

1 Reflects the pending sequence to the external sink sequence and  reset
  the  get/put  buffer pointers.  It means that if there are some unread
  sequence on the get buffer and the external  source  sequense  is  not
  seekable, the unread sequence is perfectly lost.

2 The detailed behavior is as follows:

  a)Consumes  all  of  the  pending  sequence of characters, (as pending
    sequence and ``consumes the sequence,'' see the description  in  the
    basic_streambuf<charT,traits>::overflow() _lib.streambuf::overflow_)
    In case that consuming means appending characters to the  associated
    output stream, the character sequense shall be converted to the cor­
    responding     underlaid     character     sequence      by      the
    traits::conv_traits::convout().

  b)Clears  all  of  the  following  pointers: pbase(), pptr(), epptr(),
    eback(), gptr(), and egptr().
  Returns:
    -1 if (a) fails, otherwise 0.

  27.8.1.4  Examples of trait specialization       [lib.examples.traits]
  class fstate_t { ... };       // Implementation-defined conversion state
                                // object which is for file I/O.
  class wfstate_t { ... };
  template <class charT> struct file_traits {};

  struct file_traits<char> {
      typedef ios_traits<char> char_traits;
      typedef ios_traits<streampos> char_pos;
      typedef ios_conv_traits<fstate_t> conv_pos;
  };
  struct file_traits<wchar_t>{
      typedef ios_traits<char> char_traits;
      typedef ios_traits<wstreampos> char_pos;
      typedef ios_conv_traits<wfstate_t> conv_pos;
  };
  template <class stateT> struct ios_file_traits {};
  //
  // Specialized for the single-byte filebuf
  //
  struct ios_conv_traits<fstate_t> {
      typedef char       char_type;       // char/wchar_t...
      typedef fstate_t   conv_state;      // key parameter(mainly depend on uchar_type)
      typedef streamoff  conv_upos;       // Physical file offset
      typedef char       uchar_type;      // Physical file I/O
      typedef streampos  pos_type;        // Enough to large
      typedef streamoff  off_type;        // Enough to large
      typedef codecnv<char,wchar_t,fstate_t> codecnv_in;
      typedef codecnv<wchar_t,char,fstate_t> codecnv_out;
      result convin(codecvt_in* ccvt, conv_state& stat,
                            const char *from, const char* from_end,
                            const char*& from_next,
                            char* to, char* to_limit, char*& to_next) {
          return ccvt->convert (stat, from, from_end, from_next,
                               to, to_limit, to_next);
      }
      result convout(codecvt_out* ccvt, conv_state& stat,
                             const char* from, const char* from_end,
                             const char*& from_next,
                             char* to, char* to_limit, char* to_next) {
          return ccvt->convert (stat, from, from_end, from_next,
                               to, to_limit, to_next);
      }
      pos_type get_pos(conv_state&, conv_upos&);
      off_type get_off(conv_state&, conv_upos&);
      conv_state get_posstate(pos_type&);
      conv_state get_offstate(off_type&);
      conv_upos  get_posupos (pos_type&);
      conv_upos  get_offupos (off_type&);
  };
  //
  // Specialized for the wfilebuf
  //

  struct ios_conv_traits<wfstate_t> {
      typedef wchar_t    char_type;       // char/wchar_t...
      typedef wfstate_t   conv_state;     // key parameter(mainly depend on uchar_type)
      typedef streamoff  conv_upos;       // Physical file offset
      typedef char       uchar_type;      // Physical file I/O
      typedef wstreampos pos_type;        // Enough to large
      typedef wstreamoff off_type;        // Enough to large
      typedef codecnv<char,wchar_t,fstate_t> codecnv_in;
      typedef codecnv<wchar_t,char,fstate_t> codecnv_out;
      result convin (codecvt_in* ccvt, conv_state& stat,
                const char *from, const char* from_end, const char*& from_next,
                wchar_t* to, wchar_t* to_limit, wchar_t*& to_next) {
          return ccvt->convert (stat, from, from_end, from_next,
                               to, to_limit, to_next);
      }
      result convout (codecvt_out* ccvt, conv_state& stat,
                const wchar_t* from, const wchar_t* from_end,
                const wchar_t*& from_next,
                char* to, char* to_limit, char* to_next) {
          return ccvt->convert (stat, from, from_end, from_next,
                               to, to_limit, to_next);
      }
      pos_type get_pos (conv_state&, conv_upos&);
          // wstreampos get_pos (wfstate_t&, streampos);
      off_type get_off (conv_state&, conv_upos&);
          // wstreamoff get_off (wfstate_t&, streampos);
      conv_state get_posstate (pos_type&);
          // wfstate_t get_posstate (wstreampos&);
      conv_state get_offstate (off_type&);
          // wfstate_t get_offstate (wstreamoff&);
      conv_upos  get_posupos (pos_type&);
          //
      conv_upos  get_offupos (off_type&);
  };

  27.8.2  File streams                                    [lib.fstreams]

  Header <fstream> synopsis

  #include <cstream>      // for conv_traits, basic_convbuf
  #include <streambuf>
  #include <istream>
  #include <ostream>

  namespace std {
    template <class charT, class traits = conv_traits<charT> >
      class basic_filebuf;
    typedef basic_filebuf<char>    filebuf;
    typedef basic_filebuf<wchar_t> wfilebuf;

    template <class charT, class traits = file_traits<charT> >
      class basic_ifstream;
    typedef basic_ifstream<char>    ifstream;
    typedef basic_ifstream<wchar_t> wifstream;

    template <class charT, class traits = file_traits<charT> >
      class basic_ofstream;
    typedef basic_ofstream<char>    ofstream;
    typedef basic_ofstream<wchar_t> wofstream;
  }

1 The header <fstream> defines six types that associate  stream  buffers
  with files and assist reading and writing files.

  +-------                BEGIN BOX 32                -------+
  basic_filebuf<charT,traits>  should  be  specified so that it treats a
  file as a sequence of charT.  Except for  filebuf  and  wfilebuf  that
  implies it treats the file as binary.
  +-------                 END BOX 32                 -------+

2 In  this  subclause,  the  type  name  FILE  is a synonym for the type
  FILE.45)

  --File A File provides an external source/sink stream whose  underlaid
    character type is char (byte).

  --Multibyte  characters  and Files Class basic_filebuf is derived from
    basic_convbuf to support multibyte  character  I/O.   A  File  is  a
    sequence  of multibyte characters.  In order to provide the contents
    as a wide character sequence, wfilebuf should convert  between  wide
    character sequences and multibyte character sequences.

  --basic_filebuf  Derived  from  basic_convbuf.   Even  the single byte
    character version because single byte code conversion may be  neces­
    sary...   A  basic_filebuf provide... file I/O, char/wchar_t parity.
    fstate_t.  ios_conv_traits

  --Customize Mechanism Change name ( conv_traits->  file_traits),  cus­
    tomize   ios_conv_traits<fstate_t>.    Modify   the   definition  of
  _________________________
  45) FILE is defined in <cstdio> (_lib.c.files_).

    ios_conv_traits.

  --Multibyte character and Files A File provides  byte  sequences.   So
    the streambuf (or its derived classes) treats a file as the external
    source/sink byte sequence.  In a large  character  set  environment,
    multibyte  character  sequences are held in files.  In order to pro­
    vide the contents of a  file  as  wide  character  sequences,  wide-
    oriented  filebuf,  namely  wfilebuf  should  convert wide character
    sequences.  Because of  necessity  of  the  conversion  between  the
    external source/sink streams and wide character sequences.

  27.8.2.1  Template class basic_filebuf                   [lib.filebuf]
  namespace std {
    template <class charT, class traits = conv_traits<charT> >
    class basic_filebuf : public basic_convbuf<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    public:
      basic_filebuf();
      virtual ~basic_filebuf();
      bool is_open() const;
      basic_filebuf<charT,traits>*
           open(const char* s, ios_base::openmode mode);
  //  basic_filebuf<charT,traits>* open(const char* s, ios::open_mode mode);
      basic_filebuf<charT,traits>* close();
    protected:
  //  virtual int_type overflow (int_type c = eof());     inherited
  //  virtual int_type pbackfail(int_type c = eof());     inherited
  //  virtual int      showmany();                inherited
  //  virtual int_type underflow();               inherited
  //  virtual int_type uflow();                   inherited
  //  virtual streamsize xsgetn(char_type* s  streamsize n);      inherited
  //  virtual streamsize xsputn(const char_type* s, streamsize n);        inherited
  //  virtual pos_type seekoff(off_type off,
  //                           ios_base::seekdir way,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);        inherited
  //  virtual pos_type seekpos(pos_type sp,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);        inherited
  //  virtual basic_streambuf<charT,traits>*
  //                   setbuf(char_type* s, streamsize n);        inherited
  //  virtual int sync();                         inherited
    private:
  //  FILE* file; exposition only
    };
  }

1 The     class     basic_filebuf<charT,traits>    is    derived    from
  basic_streambuf<charT,traits> to associate both the input sequence and
  the output sequence with an object of type FILE.

  +-------                BEGIN BOX 33                -------+
  For the sake of exposition, the maintained data is presented here as:

  --FILE*  file,  points to the FILE associated with the object of class
    basic_filebuf<charT,traits>.
  +-------                 END BOX 33                 -------+

2 The restrictions on reading and writing a sequence  controlled  by  an
  object  of class basic_filebuf<charT,traits> are the same as for read­
  ing and writing its associated file.  In particular:

  --If the file is not  open  for  reading  or  for  update,  the  input
    sequence cannot be read.

  --If  the  file  is  not  open  for  writing or for update, the output
    sequence cannot be written.

  --A joint file position is maintained for both the input sequence  and
    the output sequence.

3 In  order to support file I/O and multibyte/wide character conversion,
  the following arrangement is applied to the traits structures:

  --Specify char as the underlaid character type, uchar_type defined  in
    the ios_conv_traits<>.

  --Define  state_t, the template parameter of the ios_conv_traits<>, so
    that it can apply to the conversion function.  In case  the  conver­
    sion  function  provided  by the codecvt facet uses, we adopt a spe­
    cialized template parameter stateT for the  locale-oriented  conver­
    sion  function suitable for the multibyte/wide character conversion.
    Now we assume the name of the conversion state object is fstate_t.

  --Define streamoff (or streampos ) as the repositional information for
    the underlaid byte sequence.

  --Define  streamoff,  wstreampos  for the wide-oriented streambufs (or
    filebufs) so that some composite function in the  ios_conv_traits(),
    for example:
        wstreampos get_pos(fstate_t fs, streampos s);
        wstreamoff get_off(fstate_t fs, streampos s);

  27.8.2.2  basic_filebuf constructors          [lib.basic.filebuf.cons]

  basic_filebuf();

  Effects:
    Constructs   an   object   of   class   basic_filebuf<charT,traits>,

    initializing the base  class  with  basic_streambuf<charT,traits>(),
    and initializing file to a null pointer.

    virtual ~basic_filebuf();

  Effects:
    Destroys  an  object  of  class  basic_filebuf<charT,traits>.  Calls
    close().

  27.8.2.3  Member functions                       [lib.filebuf.members]

  27.8.2.3.1  basic_filebuf::is_open              [lib.filebuf::is.open]

  bool is_open() const;

  Returns:
    true if file is not a null pointer.

  27.8.2.3.2  basic_filebuf::open                    [lib.filebuf::open]

  basic_filebuf<charT,traits>* open(const char* s,
                                    ios_base::openmode mode);

  Effects:
    If file is not a null pointer, returns a null  pointer.   Otherwise,
    calls   basic_streambuf<charT,traits>::basic_streambuf().   It  then
    opens a file, if possible, whose name is the NTBS s,  ``as  if''  by
    calling fopen(s,modstr) and assigning the return value to file.

1 The  NTBS modstr is determined from mode & ~ios_base::ate as indicated
  in Table 17:

                        Table 17--File open modes

              +---------------------------------------------+
              |        ios_base            stdio equivalent |
              |        Value(s)                             |
              +---------------------------------------------+
              |in                          "r"              |
              |out | trunc                 "w"              |
              |out | app                   "a"              |
              |in | out                    "r+"             |
              |in | binary                 "rb"             |
              |out | trunc | binary        "wb"             |
              |out | app | binary          "ab"             |
              |in | out                    "r+              |
              |in | out | trunc            "w+"             |
              |in | out | app              "a+"             |
              |in | out | binary           "r+b"            |
              |in | out | trunc | binary   "w+b"            |
              |in | out | app | binary     "a+b"            |
              +---------------------------------------------+

2 If the resulting file is not a null pointer and mode  &  ios_base::ate
  != 0, calls fseek(file,0,SEEK_END).46)

3 If  fseek  returns  a  null  pointer, calls close() and returns a null
  pointer.  Otherwise, returns this.

  basic_filebuf<charT,traits>* open(const char* s, ios::open_mode mode);

  Returns:
    open(s, ios_base::openmode(mode)).

  27.8.2.3.3  basic_filebuf::close                  [lib.filebuf::close]

  basic_filebuf* close();

  Effects:
    If file is a null pointer, returns a null  pointer.   Otherwise,  if
    the  call  fclose(file)  returns  zero,  the  function stores a null
    pointer  in  file  and  returns  this.47)  Otherwise, returns a null
    pointer.

  _________________________
  46)  The  macro  SEEK_END  is  defined,  and  the  function signatures
  fopen(const char_type*, const char_type*) and fseek(FILE*, long,  int)
  are declared, in <cstdio> (_lib.c.files_).
  47) The function signature  fclose(FILE*)  is  declared,  in  <cstdio>
  (_lib.c.files_).

  27.8.2.3.4  basic_filebuf::overflow            [lib.filebuf::overflow]

  //  virtual int_type overflow(int_type c = eof());    inherited

  Effects:
    Behaves  the  same  as   basic_streambuf<charT,traits>::overflow(c),
    except that the behavior of ``consuming a character'' is as follows:

  --(1) Converting the characters to  be  consumed  into  the  underlaid
    character sequence with the function traits::conv_traits::convout().
    During the conversion, convout maintains the conversion state in the
    member  rdstate().   At  the end of execution of the conversion, the
    conversion state is saved on it.

  --(2) The result underlaid character sequence is written to  the  file
    specified  by  file.   At the consumption of the pending characters,
    none of them are discarded.  All of the characters are converted  to
    be writted to the file.
  Returns:
    eof()  to indicate failure.  If file is a null pointer, the function
    always fails.

  27.8.2.3.5  basic_filebuf::pbackfail          [lib.filebuf::pbackfail]

  //  virtual int_type pbackfail(int_type c = eof());    inherited

  +-------                BEGIN BOX 34                -------+
  Check vs. _lib.streambuf::pbackfail_.
  +-------                 END BOX 34                 -------+

  Effects:
    Puts back the character designated by c to the  input  sequence,  if
    possible, in one of four ways:

  +-------                BEGIN BOX 35                -------+
  Because  the parsing on the underlaid character sequence generally can
  only go advance or most of parsing machined cannot go  back,  some  of
  the   basic_convbuf   implementations  cannot  ``put  back  characters
  directly to the associated input sequence.''  So the behaviors related
  to putting back the associated input stream are removed.
  +-------                 END BOX 35                 -------+

  --If c != eof() and if the function makes a putback position available
    and if char_type(c) == char_type(gptr()[-1]), assigns gptr() - 1  to
    gptr().

  --If c != eof() and if the function makes a putback position available
    and if the function is permitted to assign to the putback  position,
    assigns c to *--gptr().

  --If  c  ==  eof()  and  if  either  the  input sequence has a putback

    position available or the function makes a putback  position  avail­
    able, assigns gptr() - 1 to gptr().
  Returns:
    eof() to indicate failure, otherwise c.
  Notes:
    If file is a null pointer, the function always fails.
    The  function  does  not  put back a character directly to the input
    sequence.
    If the function can succeed in more than one of these  ways,  it  is
    unspecified  which way is chosen.  The function can alter the number
    of putback positions available as a result of any call.
  Default behavior:
    Returns traits::eof().

  +-------                BEGIN BOX 36                -------+
  Shall  we  impose  Library  uses  onto  performing   sync()...    make
  gbuffer/pbuffer  empty every time they try to write after read or vice
  versa, as in the current MSE?

  No.  On systems where this is  necessary  the  basic_filebuf  virtuals
  should  keep  track of the last operation performed on the FILE and do
  whatever is neccessary (equivalent of an fseek?)  in order to  reverse
  the direction.
  +-------                 END BOX 36                 -------+

  27.8.2.3.6  basic_filebuf::showmany            [lib.filebuf::showmany]

  //  virtual int showmany();    inherited

  Effects:
    Behaves the same as basic_streambuf::showmany().
  Notes:
    An  implementation  might  well provide an overriding definition for
    this function signature if it can determine that more characters can
    be read from the input sequence.

  27.8.2.3.7  basic_filebuf::underflow          [lib.filebuf::underflow]

  //  virtual int_type underflow();    inherited

  Effects:
    Behaves the same as basic_convbuf<charT,traits>::underflow(), except
    that the underlaid input character sequence is the byte sequence  in
    the file specified by file.

  +-------                BEGIN BOX 37                -------+
  Describing  the  behavior  about  maintaining  the conversion state is
  needed.
  +-------                 END BOX 37                 -------+

  27.8.2.3.8  basic_filebuf::seekoff              [lib.filebuf::seekoff]

  //  virtual pos_type seekoff(off_type off, ios_base::seekdir way,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);    inherited

  +-------                BEGIN BOX 38                -------+
  Check vs. _lib.stringbuf::seekoff_.
  +-------                 END BOX 38                 -------+

  Effects:
    Alters the stream position within the controlled sequences, if  pos­
    sible, as described below.
  Returns:
    a newly constructed pos_type object that stores the resultant stream
    position, if possible.  If the positioning operation  fails,  or  if
    the  object  cannot  represent  the  resultant  stream position, the
    object stores an invalid stream position.

1 If file is a null pointer, the positioning  operation  fails.   Other­
  wise,  the  function  determines  one of three values for the argument
  whence, of type int, as indicated in Table 18:

                        Table 18--seekoff effects

                   +----------------------------------+
                   |  way Value      stdio Equivalent |
                   +----------------------------------+
                   |basic_ios::beg   SEEK_SET         |
                   |basic_ios::cur   SEEK_CUR         |
                   |basic_ios::end   SEEK_END         |
                   +----------------------------------+

2 The function then calls fseek(file,off,whence) and, if  that  function
  returns nonzero, the positioning operation fails.48)

3 The  function  extracts  the  conversion  state  from  off by means of
  get_offstate() to reset the rdstate() member.

  27.8.2.3.9  basic_filebuf::seekpos              [lib.filebuf::seekpos]

  _________________________
  48)  The  macros SEEK_SET, SEEK_CUR, and SEEK_END are defined, and the
  function signature fseek(FILE*, long, int) is  declared,  in  <cstdio>
  (_lib.c.files_).

  //  virtual pos_type seekpos(pos_type sp,
  //                           ios_base::openmode which
  //                             = ios_base::in
  //                             | ios_base::out);    inherited

  +-------                BEGIN BOX 39                -------+
  [To Be Filled]

  Check vs. _lib.streambuf::seekpos_ and _lib.stringbuf::seekpos_.
  +-------                 END BOX 39                 -------+

  27.8.2.3.10  basic_filebuf::setbuf               [lib.filebuf::setbuf]

  //  virtual basic_streambuf* setbuf(char_type* s, int n);    inherited

  +-------                BEGIN BOX 40                -------+
  [To Be Filled]

  Check vs. _lib.streambuf::setbuf_ and _lib.stringbuf::setbuf_.
  +-------                 END BOX 40                 -------+

  27.8.2.3.11  basic_filebuf::sync                   [lib.filebuf::sync]

  //  virtual int sync();    inherited

  +-------                BEGIN BOX 41                -------+
  [To Be Filled]

  Check vs. _lib.streambuf::sync_.
  +-------                 END BOX 41                 -------+

  27.8.2.4  Template class basic_ifstream                 [lib.ifstream]
  namespace std {
    template <class charT, class traits = file_traits<charT> >
    class basic_ifstream : public basic_istream<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }

    public:
      basic_ifstream();
      basic_ifstream(const char* s, openmode mode = in);
      virtual ~basic_ifstream();
      basic_filebuf<charT,traits>* rdbuf() const;
      bool is_open();
      void open(const char* s, openmode mode = in);
  //  void open(const char* s, open_mode mode = in);    optional
      void close();
    private:
  //  basic_filebuf<charT,traits> fb;     exposition only
    };
  }

1 The   class   basic_ifstream<charT,traits>   is   a   derivative    of
  basic_istream<charT,traits>  that  assists  in  the  reading  of named
  files.  It supplies a basic_filebuf<charT,traits>  object  to  control
  the associated sequence.

  +-------                BEGIN BOX 42                -------+
  For the sake of exposition, the maintained data is presented here as:

  --basic_filebuf<charT,traits> fb, the basic_filebuf object.
  +-------                 END BOX 42                 -------+

  27.8.2.5  basic_ifstream constructors        [lib.basic.ifstream.cons]

  basic_ifstream();

  Effects:
    Constructs an object of class basic_ifstream<charT,traits>, initial­
    izing the base class with basic_istream<charT,traits>(&fb).

    basic_ifstream(const char* s, openmode mode = in);

  Effects:
    Constructs an object of class basic_ifstream, initializing the  base
    class  with  basic_istream<charT,traits>(&fb),  then  calls  open(s,
    mode).

  27.8.2.6  Member functions                      [lib.ifstream.members]

  27.8.2.6.1  basic_ifstream::rdbuf                [lib.ifstream::rdbuf]

  basic_filebuf<charT,traits>* rdbuf() const;

  Returns:
    dynamic_cast<basic_filebuf<charT,traits>*>
    (basic_istream<charT,traits>::rdbuf()).

  27.8.2.6.2  basic_ifstream::is_open            [lib.ifstream::is.open]

  bool is_open();

  Returns:
    rdbuf().is_open().

  27.8.2.6.3  basic_ifstream::open                  [lib.ifstream::open]

  void open(const char* s, openmode mode = in);

  Effects:
    Calls  rdbuf().open(s,mode).   If is_open() returns zero, calls set­
    state(failbit).

  27.8.2.6.4  basic_ifstream::close                [lib.ifstream::close]

  void close();

  Effects:
    Calls rdbuf().close() and, if that function returns zero, calls set­
    state(failbit).

  27.8.2.7  Template class basic_ofstream                 [lib.ofstream]
  namespace std {
    template <class charT, class traits = file_traits<charT> >
    class basic_ofstream : public basic_ostream<charT,traits> {
    public:
      typedef charT            char_type;
      typedef traits::int_type int_type;
      typedef traits::pos_type pos_type;
      typedef traits::off_type off_type;
      int_type  eof()     { return traits::eof(); }
      char_type newline() { return traits::newline(); }
    public:
      basic_ofstream();
      basic_ofstream(const char* s, openmode mode = out);
      virtual ~basic_ofstream();
      basic_filebuf<charT,traits>* rdbuf() const;
      bool is_open();
      void open(const char* s, openmode mode = out | trunc);
  //  void open(const char* s, open_mode mode = out | trunc);    optional
      void close();
    };
  }

1 The    class   basic_ofstream<charT,traits>   is   a   derivative   of
  basic_ostream<charT,traits> that  assists  in  the  writing  of  named
  files.   It  supplies  a basic_filebuf<charT,traits> object to control
  the associated sequence.

  27.8.2.8  basic_ofstream constructors        [lib.basic.ofstream.cons]

  basic_ofstream();

  Effects:
    Constructs an object of class basic_ofstream<charT,traits>, initial­
    izing the base class with basic_ostream<charT,traits>(&fb).

    basic_ofstream(const char* s, openmode mode = out);

  Effects:
    Constructs an object of class basic_ofstream<charT,traits>, initial­
    izing the base  class  with  basic_ostream<charT,traits>(&fb),  then
    calls open(s, mode).

  27.8.2.9  Member functions                      [lib.ofstream.members]

  27.8.2.9.1  basic_ofstream::rdbuf                [lib.ofstream::rdbuf]

  basic_filebuf<charT,traits>* rdbuf() const;

  Returns:
    (basic_filebuf<charT,traits>*)&fb.

  27.8.2.9.2  basic_ofstream::is_open            [lib.ofstream::is.open]

  bool is_open();

  Returns:
    rdbuf().is_open().

  27.8.2.9.3  basic_ofstream::open                  [lib.ofstream::open]

  void open(const char* s, openmode mode = out);

  Effects:
    Calls  rdbuf().open(s,mode).  If is_open() is then false, calls set­
    state(failbit).

  27.8.2.9.4  basic_ofstream::close                [lib.ofstream::close]

  void close();

  Effects:
    Calls rdbuf().close() and, if that function returns zero, calls set­
    state(failbit).

  27.8.3  C Library files                                  [lib.c.files]

1 Headers <cstdio>, and <cwchar>.

                    Table 18--Header <cstdio> synopsis

  +-------------------------------------------------------------------------------+
  |    Type                                   Name(s)                             |
  +-------------------------------------------------------------------------------+
  |Macros:                                                                        |
  |BUFSIZ         L_tmpnam        SEEK_SET   TMP_MAX                              |
  |EOF            NULL <cstdio>   stderr     _IOFBF                               |
  |FILENAME_MAX   SEEK_CUR        stdin      _IOLBF                               |
  |FOPEN_MAX      SEEK_END        stdout     _IONBF                               |
  +-------------------------------------------------------------------------------+
  |Types:         FILE            fpos_t     size_t <cstdio>                      |
  +-------------------------------------------------------------------------------+
  |Functions:                                                                     |
  |clearerr       fgets           fscanf     gets              rewind    tmpfile  |
  |fclose         fopen           fseek      perror            scanf     tmpnam   |
  |feof           fprintf         fsetpos    printf            setbuf    ungetc   |
  |ferror         fputc           ftell      putc              setvbuf   vprintf  |
  |fflush         fputs           fwrite     puts              sprintf   vprintf  |
  |fgetc          fread           getc       remove            sscanf    vsprintf |
  |fgetpos        freopen         getchar    rename            tmpfile            |
  +-------------------------------------------------------------------------------+

                    Table 18--Header <cwchar> synopsis

  +------------------------------------------------------------------------+
  |  Type                               Name(s)                            |
  +------------------------------------------------------------------------+
  |Macros:    NULL <cwchar>   WCHAR_MAX   WCHAR_MIN   WEOF <cwchar>        |
  +------------------------------------------------------------------------+
  |Types:     mbstate_t       wint_t <cwchar>                              |
  +------------------------------------------------------------------------+
  |Struct:    tm <cwchar>                                                  |
  +------------------------------------------------------------------------+
  |Functions:                                                              |
  |btowc      getwchar        ungetwc     wcscpy      wcsrtombs   wmemchr  |
  |fgetwc     mbrlen          vfwprintf   wcscspn     wcsspn      wmemcmp  |
  |fgetws     mbrtowc         vswprintf   wcsftime    wcsstr      wmemcpy  |
  |fputwc     mbsinit         vwprintf    wcslen      wcstod      wmemmove |
  |fputws     mbsrtowcs       wcrtomb     wcsncat     wcstok      wmemset  |
  |fwide      putwc           wcscat      wcsncmp     wcstol      wprintf  |
  |fwprintf   putwchar        wcschr      wcsncpy     wcstoul     wscanf   |
  |fwscanf    swprintf        wcscmp      wcspbrk     wcsxfrm              |
  |getwc      swscanf         wcscoll     wcsrchr     wctob                |
  +------------------------------------------------------------------------+

2 The  contents are the same as the Standard C library, except that none
  of the headers defines wchar_t.  SEE ALSO:

  ISO C subclause 7.9, Amendment 1 subclause 4.6.2.