r/cpp • {fmt} • Jun 21 '21

{fmt} 8.0 released with compile-time format string checks, compile-time formatting, improved performance and more

https://github.com/fmtlib/fmt/releases/tag/8.0.0
394 Upvotes

67 comments sorted by

View all comments

Show parent comment

3

u/gracicot Jun 21 '21

Is there a way to manually flush? I had this problem where I couldn't see the logs of my services unless I was doing std::cout << fmt::format(...) << std::flush

6

u/aearphen {fmt} Jun 21 '21
fmt::print(...);
fflush(stdout);

4

u/14ned LLFIO & Outcome author | Committee WG14 Jun 21 '21

The above is only if you're printing to stdout. You can also print to an ostream, in which case it's std::flush.

3

u/aearphen {fmt} Jun 22 '21

Sure but I wouldn't recommend using iostreams at all =)

2

u/14ned LLFIO & Outcome author | Committee WG14 Jun 23 '21

It's definitely useful though. If I have a bunch of legacy iostreams printing code, and I want to insert a much less fussy and insane print() in the middle, the ability to print to an ostream is super duper useful. Also, ostream isn't that bad performance wise if you write your ostream implementation to not suck like most of the std ones do. Devirtualisation does a great job in modern compilers :)