people say that and then I loose half an hour trying to understand where my code is going wrong because my terminal did not flush when trying to debug log
people say that and then I loose half an hour trying to understand where my code is going wrong because my terminal did not flush when trying to debug log
endl just saves you from getting out of the habit of using endl, really.
Are you seriously suggesting no one uses std::endl? A simple search on Github actually reveals the opposite... almost everyone uses std::endl and almost no one uses std::flush (94% use std::endl, and 6% use std::flush).
I am also in the std::endl camp and find it absurd when people bike shed over it. It's the most intuitive/least surprising behavior (based on Stack overflow questions) and how almost all other mainstream languages behave (flush on new line), and as such it should be the default choice.
The use of ... << '\n' << std::flush is best when you want to explicitly call out that behavior because of performance reasons or some other exceptional circumstance.
Maybe, but when you're debugging it's essential. Those debugging cout's aren't going to be there in production.