I am creating a special std::streambuf and std::ostream implementation. For that I need to implement the std::streambuf::overflow
function. The function is protected, only called by std::streambuf::sputc
and std::streambuf::xsputn
and only when there is no more room in the buffer (that is pptr() == epptr()
). The default behaviour is to return eof
, so it is obviously not correct to call the function in place of sputc
.
Nevertheless both GNU libc implementation of std::stringbuf
and boost implementation of boost::io::alt_stringbuf
in Boost.Format still check whether pptr() < epptr()
and such case simply append the character. In the later case even daringly by calling sputc
(and thus relying on the fact that it will not call overflow
if there is still room in the buffer).
What is the reason to implement this case?
Ok, I don't really understand the other case, overflow(eof())
, either. It does not appear to be actually used anywhere though it is explicitly specified.