[RFC] Strive to prefer sbumpc() to snextc()?!?
Pétur Runólfsson
peturr02@ru.is
Fri Apr 23 09:30:00 GMT 2004
Paolo Carlini wrote:
> >It is currently possible to implement an unbuffered streambuf for input
> >by overloading uflow() and underflow(), but not pbackfail(), so I don't
> >think that using sungetc() or sputbackc() is a good idea.
> >
> >
> Thanks for your message. Before discussing your other interesting
> suggestions,
> could you possibly explain in better detail this part. "Currently" means
> in the
> current standard?
No. Current libstdc++ sources. But the standard also says that
(un)formatted input functions use sgetc() and sbumpc() to get characters,
it doesn't mention sungetc() or sputbackc().
> Why, exactly?
It is often easy to write underflow() and uflow(), but pbackfail can be
much harder. See PR 12048 ;-)
> And, more general, isn't true that
> sbumpc() +
> sungetc() has to be always equivalent to sgetc()?
I don't think the standard requires this. As far as I can tell, pbackfail
is allowed to always fail. Note that this is different from stdio, where
ungetc() can always unget at least one character if called after getc().
Regards,
Petur
More information about the Libstdc++
mailing list