Title
xsputn inefficient
Status
c++11
Section
[streambuf.virt.put]
Submitter
Martin Sebor

Created on 2006-02-23.00:00:00 last changed 153 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Add the following sentence to the xsputn() Effects clause in 27.5.2.4.5, p1 (N1804):

-1- Effects: Writes up to n characters to the output sequence as if by repeated calls to sputc(c). The characters written are obtained from successive elements of the array whose first element is designated by s. Writing stops when either n characters have been written or a call to sputc(c) would return traits::eof(). It is uspecified whether the function calls overflow() when (pptr() == epptr()) becomes true or whether it achieves the same effects by other means.

In addition, I suggest to add a footnote to this function with the same text as Footnote 292 to make it extra clear that derived classes are permitted to override xsputn() for efficiency.

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

Move to Ready.

Date: 2006-02-23.00:00:00

streambuf::xsputn() is specified to have the effect of "writing up to n characters to the output sequence as if by repeated calls to sputc(c)."

Since sputc() is required to call overflow() when (pptr() == epptr()) is true, strictly speaking xsputn() should do the same. However, doing so would be suboptimal in some interesting cases, such as in unbuffered mode or when the buffer is basic_stringbuf.

Assuming calling overflow() is not really intended to be required and the wording is simply meant to describe the general effect of appending to the end of the sequence it would be worthwhile to mention in xsputn() that the function is not actually required to cause a call to overflow().

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg3073
2010-10-21 18:28:33adminsetmessages: + msg3072
2006-02-23 00:00:00admincreate