This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [RFC] Strive to prefer sbumpc() to snextc()?!?
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Paolo Carlini" <pcarlini at suse dot de>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>,"Nathan Myers" <ncm at cantrip dot org>
- Date: Fri, 23 Apr 2004 09:30:43 -0000
- Subject: RE: [RFC] Strive to prefer sbumpc() to snextc()?!?
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