Setting the output stream
private:
typedef typename
std::basic_streambuf<charT, traits>::int_type int_type;
std::basic_streambuf<charT, traits>* out_;
public:
logoutbuf() : out_(0), buffer_() { }
void init(std::basic_ostream<charT, traits>* out)
{
out_ = out;
}
As we'll discuss later on, logoutbuf will become a virtual base class and even though out_ could be set easily via the constructor, having a default constructor and an initialisation function is a helpful trade off.
The output stream must be of the correct type for the character type and is stored via a pointer and initialised via an initialisation function.