[streambuf.virt.put] (original) (raw)
31 Input/output library [input.output]
31.6 Stream buffers [stream.buffers]
31.6.3 Class template basic_streambuf [streambuf]
31.6.3.5 Virtual functions [streambuf.virtuals]
31.6.3.5.5 Put area [streambuf.virt.put]
streamsize xsputn(const char_type* s, streamsize n);
Effects: Writes up to n characters to the output sequence as if by repeated calls tosputc(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 tosputc(c)would returntraits::eof().
It is unspecified whether the function calls overflow() when pptr() == epptr() becomes true or whether it achieves the same effects by other means.
Returns: The number of characters written.
int_type overflow(int_type c = traits::eof());
Effects: Consumes some initial subsequence of the characters of thepending sequence.
The pending sequence is defined as the concatenation of
- the empty sequence if pbase() is null, otherwise thepptr() - pbase()characters beginning atpbase(), followed by
- the empty sequence iftraits::eq_int_type(c, traits::eof())returnstrue, otherwise the sequence consisting of c.
Preconditions: Every overriding definition of this virtual function obeys the following constraints:
- The effect of consuming a character on the associated output sequence is specified.271
- Letrbe the number of characters in the pending sequence not consumed.
Ifris nonzero thenpbase()andpptr()are set so that:pptr() - pbase() == rand the r characters starting atpbase()are the associated output stream.
In case r is zero (all characters of the pending sequence have been consumed) then eitherpbase()is set tonullptr, orpbase()andpptr()are both set to the same non-null value. - The function may fail if either appending some character to the associated output stream fails or if it is unable to establishpbase()andpptr()according to the above rules.
Returns: traits::eof()or throws an exception if the function fails.
Otherwise, returns some value other thantraits::eof()to indicate success.272
Default behavior: Returnstraits::eof().
Remarks: The member functionssputc()andsputn()call this function in case that no room can be found in the put buffer enough to accommodate the argument character sequence.