In the name of efficiency
virtual std::streamsize xsputn(const charT* s,
std::streamsize num)
{
std::copy(s, s+num,
std::back_inserter<buffer_type>(buffer_));
return num;
}
logoutbuf is now fully functional, but there is a further modification that can be made for the sake of efficiency. Currently overflow is called for every single character streamed to the stream buffer. This means that to stream the "31 hexadecimal: " string literal to the stream buffer involves 16 separate function calls. This can be reduced to a single function call by overriding xsputn.
xsputn takes the same parameters as basic_streambuf::sputn and uses the std::copy algorithm together with std::back_inserter to insert the characters from the array into the buffer. logoutbuf is now complete.