[iostreams] Auto flush required
Hi.
I've implemented output stream using boost.iostreams library. It requires call
to flush in order to actually write data to sink. But I want to flush data to
sink automatically after I write any object with operator<<.
struct stream_sink : public boost::iostreams::sink
{
stream_sink(std::ostream & strm) : strm_(strm) {}
std::streamsize write(const char * s, std::streamsize n)
{
if (strm_.write(s, n))
return n;
else
throw std::runtime_error("error");
}
private:
std::ostream & strm_;
};
std::stringstream s;
boost::iostreams::stream
Roman Perepelitsa
Hi.
I've implemented output stream using boost.iostreams library. It requires
call
to flush in order to actually write data to sink. But I want to flush data to sink automatically after I write any object with operator<<.
Sorry for the noise, I've solved the problem by using input streams and source instead of output stream and sink. Roman Perepelitsa.
participants (1)
-
Roman Perepelitsa