It is used to clears the unitbuf "format" flag for the str stream. When the unitbuf flag is not set, the associated buffer is not forced to be flushed after every insertion operation.
Following is the declaration for std::nounitbuf function.
ios_base& nounitbuf (ios_base& str);
str − Stream object whose format flag is affected.
It returns Argument str.
Basic guarantee − if an exception is thrown, str is in a valid state.
It modifies str. Concurrent access to the same stream object may cause data races.
In below example explains about std::nounitbuf function.
#include <ios> #include <fstream> int main () { std::ofstream outfile ("test.txt"); outfile << std::unitbuf << "Test " << "file" << '\n'; outfile.close(); return 0; }