Prior to C++ 23, when using std::cout
to send output to stdout
, there is a distinction between the following two ways of adding a new line at the end of the printed string:
std::cout << "Hello World\n"
;std::cout << "Hello World" << std::endl;
The second of these is often preferable as it causes the output stream to flush, rather than requiring a call to std::cout.flush()
.
With C++ 23 there are now two new functions for printing, along with a new component to the standard library. We have std::print
and std::println
.
Do either of these functions make a distinction when it comes to flushing the output stream?
Or, is it the case that flushing the output stream is no longer a concept which is relevant in these new implementations?
Documentation from cppreference
does not mention flushing: