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] 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


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