In C++, nounitbuf turns off unitbuf. The stream goes back to normal buffering: it collects output and sends it in bigger pieces, which is faster.
This is the default state of cout and file streams. It is useful when you changed a stream to unit buffering, or when you want to speed up cerr. It comes from <ios>, which <iostream> includes.
This is a manipulator. You do not call it on its own. You send it into a stream with << or >>, and it changes how that stream behaves from then on (or does one small job, like ending a line).
Syntax
Put std::nounitbuf into an output stream.
C++
std::cerr << std::nounitbuf; // cerr now buffers
out << std::unitbuf << "A\n" << std::nounitbuf << "B\n";
Call
What it does
std::cout << std::nounitbuf
Normal buffering for cout.
std::cerr << std::nounitbuf
Stops the automatic flushing of cerr.
out << std::unitbuf << a << std::nounitbuf << b
Flushes after a but not after b.
Turn buffering back on only for the output that must be seen at once.
Library declarations
C++
ios_base& nounitbuf(ios_base& str);
Parameters
Parameter
Description
str
The stream. It is passed in for you when you write cout << nounitbuf. You never write this argument yourself.
Return Value
Return Value
Description
ios_base&
A reference to the same stream, so you can keep chaining << or >> after nounitbuf.