I\'m making a logger. I want to create a function log()
that takes a stream as input.
For instance:
log(\"hello\"<<\" \"<<\"
Have log()
return a temporary object that buffers all output in memory. The destructor for this object will run at the end of the expression, and should flush the accumulated data to the actual stream in a single atomic operation (up to you to make that operation atomic).
That will make your second syntax feasible:
log()<<"hello"<<"world"<<10<<"\n";