Boost logo

Boost :

From: John Torjo (john_at_[hidden])
Date: 2003-04-24 01:29:09


I've just looked at the more_io library
( ->

I would have a comment:

The I/O streambuf wrapping seems unnecessary complex.
It can be easily emulated like this:
(the key function is basic_ios::init(&buf) )
(no unnecessary boost::io::...wrapping... classes)

// the following compiles and runs as expected
#include <iostream>

struct nul_streambuf : public std::streambuf
    nul_streambuf() { this->setp( NULL, NULL); }
    virtual int sync() { return 0; }
    virtual int overflow(int nChar) { return 0; }
    virtual std::streamsize xsputn(const char *S, std::streamsize N)
 return N; }

template< class StreamBuf>
struct ostream_base : public std::ostream
    typedef std::ostream base_class;
        : base_class( NULL)
        this->init( &m_buf);
    StreamBuf m_buf;

class nul_ostream : public ostream_base< nul_streambuf>

int main(int argc, char* argv[])
    nul_ostream out;
    out << "test" << std::endl;

Of course, the ostream_base can be templated (by char_type, traits_type).


John Torjo
-- "Practical C++" column writer for
Freelancer, C++ consultant

Boost list run by bdawes at, gregod at, cpdaniel at, john at