Adding to the buffer

virtual int_type overflow(int_type c)
{
  if(!traits::eq_int_type(c, traits::eof()))
    buffer_.push_back(c);

  return traits::not_eof(c);
}
The overflow member function of std::basic_streambuf is called for each character that is sent to the stream buffer. Overriding it allows the behaviour to be modified. In the implementation of overflow above the following happens:

The character is checked to make sure it is not EOF.
If it is not EOF it is added to the buffer.
An indication of whether the character is EOF is returned.


Traits are used throughout to make sure that the character type being used is correctly interpreted