This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RE: [RFC] libstdc++/9404 or weird stringbuf internals
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Paolo Carlini" <pcarlini at unitus dot it>,<libstdc++ at gcc dot gnu dot org>
- Date: Wed, 12 Feb 2003 12:59:30 -0000
- Subject: RE: [RFC] libstdc++/9404 or weird stringbuf internals
Hi
> But, if someone (Pétur ;) wants to see overflow called during
> a sputc which starts with pptr() == epptr()...
overflow must be called if a class derived from stringbuf is
supposed to work correctly. Google returns a number of posts
from people who have tried to derive from the standard stream
buffers (including stringbuf).
> What to do, then?
>
> I could try changing both _M_out_buf_size() and overflow
> to the effect of calling overflow for each sputc of a sequence.
> This has a price, however, in terms of virtual functions called.
If efficiency is a concern, sputn should be used instead of
sputc. For maximal efficiency, stringbuf shouldn't be used at all
(for example str() is an O(N) operation).
> Is this the only standard-conforming possibility?
>
> Perhaps I misread the standard and it is not really compulsory
> to call overflow whenever pptr() == epptr()?
>
> Please help!
You might also want to look at DR 169.
Petur