streambuf::overflow

virtual int overflow( int nCh = EOF ) = 0;

Return Value

EOF to indicate an error.

Parameter

nCh

EOF or the character to output.

Remarks

The virtual overflow function, together with the sync and underflow functions, defines the characteristics of the streambuf-derived class. Each derived class might implement overflow differently, but the interface with the calling stream class is the same.

The overflow function is most frequently called by public streambuf functions like sputc and sputn when the put area is full, but other classes, including the stream classes, can call overflow anytime.

The function “consumes” the characters in the put area between the pbase and pptr pointers and then reinitializes the put area. The overflow function must also consume nCh (if nCh is not EOF), or it might choose to put that character in the new put area so that it will be consumed on the next call.

The definition of “consume” varies among derived classes. For example, the filebuf class writes its characters to a file, while the strsteambuf class keeps them in its buffer and (if the buffer is designated as dynamic) expands the buffer in response to a call to overflow. This expansion is achieved by freeing the old buffer and replacing it with a new, larger one. The pointers are adjusted as necessary.

Default Implementation

No default implementation. Derived classes must define this function.

streambuf OverviewStream Buffer Classes

See Also   streambuf::pbase, streambuf::pptr, streambuf::setp, streambuf::sync, streambuf::underflow