From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8053 invoked by alias); 7 Mar 2003 21:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 8039 invoked by uid 71); 7 Mar 2003 21:26:01 -0000 Date: Fri, 07 Mar 2003 21:26:00 -0000 Message-ID: <20030307212601.8038.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Paolo Carlini Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters Reply-To: Paolo Carlini X-SW-Source: 2003-03/txt/msg00370.txt.bz2 List-Id: The following reply was made to PR libstdc++/9424; it has been noted by GNATS. From: Paolo Carlini To: Nathan Myers 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!