std::strstreambuf::overflow
Min standard notice:
Appends the character c to the put area of the buffer, reallocating if possible.
# Declarations
protected:
virtual int_type overflow( int_type c = EOF );
(deprecated in C++98) (removed in C++26)
# Parameters
c: the character to store in the put area
# Return value
If c == EOF, returns some value other than EOF. Otherwise, returns (unsigned char)(c) on success, EOF on failure.
# Example
#include <iostream>
#include <strstream>
struct mybuf : std::strstreambuf
{
int_type overflow(int_type c)
{
std::cout << "Before overflow(): size of the put area is " << epptr()-pbase()
<< " with " << epptr()-pptr() << " write positions available\n";
int_type rc = std::strstreambuf::overflow(c);
std::cout << "After overflow(): size of the put area is " << epptr()-pbase()
<< " with " << epptr()-pptr() << " write positions available\n";
return rc;
}
};
int main()
{
mybuf sbuf; // read-write dynamic strstreambuf
std::iostream stream(&sbuf);
stream << "Sufficiently long string to overflow the initial allocation, at least "
<< " on some systems.";
}