[RFC] A stream buffer for wcin

Nathan Myers ncm-nospam@cantrip.org
Mon Feb 17 19:24:00 GMT 2003


On Mon, Feb 17, 2003 at 03:45:20PM -0000, P?tur Run?lfsson wrote:
> Nathan Myers wrote:
> > My impression of the suggested patch is that it involves calling
> > underflow on every character, rather than buffering.
> 
> Yes, unless wcin somehow has access to stdin's internal buffer,
> I don't see how this can be avoided for the case when
> ios_base::sync_with_stdio(false) hasn't been called.

Right.  You don't have to be fast if ios_base::sync_with_stdio(false) 
hasn't been called.  But you should be if it has.  (And its effects
are undefined if you've done any input before you call it.)  False
*used* to be default.  Grrr.

> > If it is necessary for good performance to make wcin and wstdin 
> > each do a sync operation between switching between them, that seems 
> > a small price to pay.
> 
> I don't see how such a sync operation could be implemented, there
> is no portable way to put back more than one character to stdin,
> and I'm not aware of any way to get access to the conversion state.

Right.

> However, if ios_base::sync_with_stdio(false) has been called,
> there is no need to sync wcin with stdin. In that case a buffered
> wfilebuf can be used for wcin.

Or, you can derive wcinbuf from wfilebuf, and delegate to the 
base class if ios_base::sync_with_stdio(false) gets called. 

Nathan Myers
ncm-nospam@cantrip.org



More information about the Libstdc++ mailing list