This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
xsputn inefficientSection: 31.6.3.5.5[streambuf.virt.put]Status:C++11Submitter: Martin SeborOpened: 2006-02-23Last modified: 2016-01-28
Priority:Not Prioritized
View all issues withC++11 status.
Discussion:
streambuf::xsputn() is specified to have the effect of"writing up ton characters to the output sequence as if byrepeated calls tosputc(c)."
Sincesputc() is required to calloverflow() when(pptr() == epptr()) is true, strictly speakingxsputn() should do the same. However, doing so would besuboptimal in some interesting cases, such as in unbuffered mode orwhen the buffer isbasic_stringbuf.
Assuming callingoverflow() is not really intended to berequired and the wording is simply meant to describe the generaleffect of appending to the end of the sequence it would be worthwhileto mention inxsputn() that the function is not actuallyrequired to cause a call tooverflow().
[2009-07 Frankfurt]
Move to Ready.
Proposed resolution:
Add the following sentence to thexsputn() Effects clause in27.5.2.4.5, p1 (N1804):
-1-Effects: Writes up to
ncharacters to the outputsequence as if by repeated calls tosputc(c). The characters written are obtained from successive elements of the array whose first elementis designated bys. Writing stops when eitherncharacters have been written or a call tosputc(c)would returntraits::eof().It is uspecified whether the function callsoverflow()when(pptr() == epptr())becomes true or whetherit achieves the same effects by other means.
In addition, I suggest to add a footnote to this function with thesame text as Footnote 292 to make it extra clear that derived classesare permitted to overridexsputn() for efficiency.
[Kona (2007): We want to permit astreambuf that streams output directlyto a device without making calls tosputc oroverflow. We believe thathas always been the intention of the committee. We believe that theproposed wording doesn't accomplish that. Proposed Disposition: Open]