considering a simple counting filter:
class CountableOstreamFilter : public boost::iostreams::multichar_output_filter {
public:
CountableOstreamFilter(): m_written(0) {
}
template<typename Sink>
std::streamsize write(Sink& dest, const char* s, std::streamsize n)
{
auto result = boost::iostreams::write(dest, s, n);
assert(n == result);
m_written += result;
return result;
}
inline std::streamsize writtenBytes() const {
return m_written;
}
private:
std::streamsize m_written;
};
and using it thus:
boost::iostreams::filtering_ostream counted_cout;
counted_cout.push(CountableOstreamFilter());
counted_cout.push(std::cout);
counted_cout << "hello world";
what would be the difference between calling sync(), strict_sync() or flush()? counted_cout.sync(); // what is different from this call counted_cout.strict_sync(); // to this call counted_cout.flush(); // to this call?
I'm using boost 1.50.0