This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]