Thursday, October 14, 2010

fmt::flush

As discussed in the latest instalment of Quality Matters, having flushing output streams and verifying their status is a pre-requisite of writing a robust program. Doing this with the IOStreams is a somewhat onerous task; see the column for details. Using the new flush() function, introduced in version 0.6.2, makes doing so with FastFormat a breeze, as in:


#include <fastformat/ff.hpp>
#include <fastformat/sinks/ostream.hpp>

#include <iostream>

int main()
{
 ff::flush(ff::writeln(std::cout, "Hello, world!"));

 return 0;
}

No comments:

Post a Comment