public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Paolo Carlini <pcarlini@unitus.it> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters Date: Fri, 07 Mar 2003 21:26:00 -0000 [thread overview] Message-ID: <20030307212601.8038.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/9424; it has been noted by GNATS. From: Paolo Carlini <pcarlini@unitus.it> To: Nathan Myers <ncm@cantrip.org> Cc: libstdc++@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters Date: Fri, 07 Mar 2003 22:25:52 +0100 Nathan Myers wrote: >>int_type c; >>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 snextc() { 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 succesful reads (__charsread) and writes (__xtrct) like this: __xtrct = __charsread = 0; int_type __c = __sbin->sgetc(); while (!_Traits::eq_int_type(__c, _Traits::eof())) { ++__charsread; if (_Traits::eq_int_type(__sbout->sputc(_Traits::to_char_type(__c)), _Traits::eof())) break; ++__xtrct; ++__ret; __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. Thanks, Paolo. (*) I want to buy crack from your pusher: seems excellent!
next reply other threads:[~2003-03-07 21:26 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-03-07 21:26 Paolo Carlini [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-03-09 11:27 paolo 2003-03-07 19:56 Nathan Myers 2003-02-26 9:36 Pétur Runólfsson 2003-02-26 0:34 paolo 2003-01-23 19:06 peturr02
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030307212601.8038.qmail@sources.redhat.com \ --to=pcarlini@unitus.it \ --cc=gcc-prs@gcc.gnu.org \ --cc=paolo@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).