This is the mail archive of the
mailing list for the libstdc++ project.
Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Nathan Myers <ncm at cantrip dot org>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
- Date: Fri, 07 Mar 2003 22:25:52 +0100
- Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F5533@nike.hir.is> <20030307195055.GD15175@tofu.dreamhost.com>
Nathan Myers wrote:
while ((c = sbin->sbumpc()) != traits_type::eof() &&
(sbout->sputc(c) != traits_type::eof())
I seem to recall that sbumpc() can be implemented more efficiently
than snextc, although it's just possible I was smoking crack.
Hi Nathan. Thanks for your feedback.
Indeed (*), the basic loop is much more elegant in terms of sbumpc, and more
efficient too, I guess, since our snextc is implemented in terms of sbumpc:
int_type __eof = traits_type::eof();
return (traits_type::eq_int_type(this->sbumpc(), __eof)
? __eof : this->sgetc());
However, in the application I want to count separately the number of
reads (__charsread) and writes (__xtrct) like this:
__xtrct = __charsread = 0;
int_type __c = __sbin->sgetc();
while (!_Traits::eq_int_type(__c, _Traits::eof()))
__c = __sbin->snextc();
and can't see a straightforward way to use your suggestion. Can you?
Otherwise, as indicated by Benjamin, for the time being I would check in
this correctness fix with the promise of returning to this function to
streamline it in the _near_ future.
(*) I want to buy crack from your pusher: seems excellent!