Topic: Question ostream::operator<<(wchar_t)


Author: "Shankar Unni" <shankar@boris.engr.sgi.com>
Date: 1995/11/09
Raw View
I have to implement an ostream::operator<<(wchar_t) (for a USL-derived iostream

library, with a builtin wchar_t type), and ran into the question: exactly what
should this operator write to the stream?

>From the Sep 95 draft, it seems that (page 27-51)
basic_ostream<wchar_t>::operator<<(wchar_t) should convert its argument with a
"%c" printf specifier. But surely this is a mistake or an oversight, since it
doesn't mean anything for wchar_t: the wchar_t will be cast to a "char" and
written, destroying its value.

My question is: are the input and output operators for wchar_t-based streams
required to do this (silly, IMHO) behavior? Or does it make more sense for them

to read and write multi-byte strings, converting to / from wchar_t as needed
(which is what the scanf/printf "%C" and "%S" operators do)?
--
Shankar Unni    E-Mail: shankar@sgi.com
Silicon Graphics Inc.   Phone: +1-415-933-2072
URL: http://reality.sgi.com/employees/shankar
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]