Doc. No.: WG21/N0954R1=X3J16/96-0136R1 Date: 8 Jul 1996 Project: C++ Standard Library Reply to: Nathan Myers Iostream Resolutions (Myers) (Revision 1) ----------------------------------------- The following are proposed resolutions for iostreams issues. --------------- ** Part: 001 ** Issue: 27-001 ** Proposed Resolution In 27.6.1.1 [lib.istream] and 27.6.1.3 [lib.istream.unformatted], replace the member getline with two members: istream_type& getline(char_type*, streamsize, char_type delim); istream_type& getline(char_type* p, streamsize n); The latter member is to be described as: Returns: getline(p,n,widen('\n')); --------------- ** Part: 002 ** Issue: 27-001 ** Discussion The need for a conversion of a char value to the character encoding in use for a stream is not restricted to newline. Members for this purpose would be useful to all users of iostream templates. ** Proposed Resolution In 27.4.4 [lib.ios] and 27.4.4.2 [lib.basic.ios.members], add the two members defined to call the corresponding member of the ctype locale facet in the stream: char narrow(char_type c, char dfault) const; Returns: use_facet< ctype >(getloc()).narrow(c,dfault) char_type widen(char c) const; Returns: use_facet< ctype >(getloc()).widen(c) --------------- ** Part: 003 ** Issue: 27-301 ** Proposed Resolution Add to introductory material in Clause 27 the statement: No function defined in any clause of this Standard, except for ios_base::imbue itself, causes any standard member imbue to be called. If any non-standard function calls imbue as a result of calling a standard function (e.g. if called via a standard virtual function interface), the effect is undefined. --------------- ** Part: 004 ** Issue: 27-904 ** Discussion In Santa Cruz we reinstated the bidirectional iostreams, but failed to specify forward declarations for them in iosfwd. ** Proposed Resolution Replace "Header synopsis" by: namespace { template struct char_traits; template <> struct char_traits; template <> struct char_traits; template > class basic_ios; template > class basic_streambuf; template > class basic_istream; template > class basic_ostream; template > class basic_stringbuf; template > class basic_istringstream; template > class basic_ostringstream; template > class basic_stringstream; template > class basic_filebuf; template > class basic_ifstream; template > class basic_ofstream; template > class basic_fstream; template > class istreambuf_iterator; template > class ostreambuf_iterator; typedef basic_ios ios; typedef basic_streambuf streambuf; typedef basic_istream istream; typedef basic_ostream ostream; typedef basic_iostream iostream; typedef basic_stringbuf stringbuf; typedef basic_istringstream istringstream; typedef basic_ostringstream ostringstream; typedef basic_stringstream stringstream; typedef basic_filebuf filebuf; typedef basic_ifstream ifstream; typedef basic_ofstream ofstream; typedef basic_fstream fstream; typedef basic_ios wios; typedef basic_streambuf wstreambuf; typedef basic_istream wistream; typedef basic_ostream wostream; typedef basic_iostream wiostream; typedef basic_stringbuf wstringbuf; typedef basic_istringstream wistringstream; typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; typedef basic_filebuf wfilebuf; typedef basic_ifstream wifstream; typedef basic_ofstream wofstream; typedef basic_fstream wfstream; typedef [implementation-defined] streampos; typedef [implementation-defined] wstreampos; }; streampos and wstreampos are defined to be the same types as char_traits and char_traits, respectively. --------------- ** Part: 005 ** Issue: 27-906 ** Proposed Resolution In each class template defined in Clauses 21 and 27 that take a traits parameter, add the public member typedef: typedef traits traits_type; --------------- ** Part: 006 ** Issue: 27-911 ** Discussion The traditional function in AT&T iostreams was sync_with_stdio(), because it defaulted to unsynchronized. We prefer for simplicity that it default to synchronized (and possibly slow), with the means available to attain greater speed at a cost in complexity. ** Proposed Resolution Add to 27.4.3 [lib.ios.base] the public static member function of ios_base: bool sync_with_stdio(bool sync = true); Returns: true, the first time it is called; otherwise, returns true if and only if the standard streams were still synchronized at the time of the call. Effects: if any input or output operation has occurred using the standard streams prior to the call, the effect is implementation- defined. Otherwise, called with a false argument, it allows the standard streams to operate independently of the standard C streams [footnote: with a possible performance improvement]; called with a true argument it restores synchronization. --------------- ** Part: 006 ** Issue: 22-057 The Library Working Group addressed the remaining portion of locale issue number 22-057 by approving the suggested change. ** Proposed Resolution: In 22.1 [lib.locales], 22.2.6.1 [lib.locale.money.get], 22.2.6.1.1 [lib.locale.money.get.members], 22.2.6.2 [lib.locale.money.put], 22.2.6.1.1 [lib.locale.money.put.members], and in the second and third tables under 22.1.1.1.1 [lib.locale.category], eliminate the parameter of type bool in templates money_get<> and money_put<>. In the tables, eliminate one of each resulting duplicate entry. In members get and do_get of money_get<>, and in put and do_put of money_put<> function, add an argument declared "bool intl" before the ios_base& argument. This argument is passed along from the non-virtual to the corresponding virtual member. In the semantics for the do_get and do_put members, require that if the "intl" parameter is true, the function uses members of the facet moneypunct, and if false uses members of the facet moneypunct.