std::strstreambuf::underflow (3) - Linux Manuals
std::strstreambuf::underflow: std::strstreambuf::underflow
Command to display std::strstreambuf::underflow
manual in Linux: $ man 3 std::strstreambuf::underflow
NAME
std::strstreambuf::underflow - std::strstreambuf::underflow
Synopsis
protected:
virtual int_type underflow();
Reads the next character from the get area of the buffer.
If the input sequence has a read position available (gptr() < egptr(), returns (unsigned char)(*gptr()).
Otherwise, if pptr() is not null and pptr() > egptr() (there is a put area and it is located after the get area), extends the end of the get area to include the characters that were recently written into the put area by incrementing egptr() to some value between gptr() and pptr(), and then returns (unsigned char)(*gptr()).
Otherwise, returns EOF to indicate failure.
Parameters
(none)
Return value
The next character in the get area, (unsigned char)(*gptr()) on success, EOF on failure
Example
// Run this code
#include <strstream>
#include <iostream>
struct mybuf : std::strstreambuf
{
int_type overflow(int_type c)
{
std::cout << "Before overflow(): size of the get area is " << egptr()-eback()
<< " size of the put area is " << epptr()-pbase() << '\n';
int_type rc = std::strstreambuf::overflow(c);
std::cout << "After overflow(): size of the get area is " << egptr()-eback()
<< " size of the put area is " << epptr()-pbase() << '\n';
return rc;
}
int_type underflow()
{
std::cout << "Before underflow(): size of the get area is " << egptr()-eback()
<< " size of the put area is " << epptr()-pbase() << '\n';
int_type ch = std::strstreambuf::underflow();
std::cout << "After underflow(): size of the get area is " << egptr()-eback()
<< " size of the put area is " << epptr()-pbase() << '\n';
if (ch == EOF) {
std::cout << "underflow() returns EOF\n";
} else {
std::cout << "underflow() returns '" << char(ch) << "'\n";
}
return ch;
}
};
int main()
{
mybuf sbuf; // read-write dynamic strstreambuf
std::iostream stream(&sbuf);