WarpX icon indicating copy to clipboard operation
WarpX copied to clipboard

Replace "std::endl" with "\n" (except for error messages)

Open lucafedeli88 opened this issue 1 year ago • 2 comments

It is often preferable to use \n instead of std::endl, since the latter forces the flush of the buffer. This PR replaces all the occurrences of std::endl with \n in WarpX.

~Warning: while I think that in most cases this is a good idea, I am not sure about error messages. I am inclined to revert to std::endl for error messages that are printed just before an abort, to make sure that they are actually printed. What do you think?~

Note: Where flushing the buffer seems intentional and useful (e.g., right before an abort or when the message is written to std::cerr), I did not replace std::endl with \n

lucafedeli88 avatar Aug 28 '24 14:08 lucafedeli88

I am inclined to revert to std::endl for error messages [...]

Agreed, please don't generally replace.

ax3l avatar Aug 28 '24 20:08 ax3l

I am inclined to revert to std::endl for error messages [...]

Agreed, please don't generally replace.

@ax3l , as agreed I reverted to std::endl in cases where flushing the buffer seemed a good idea (essentially for error messages).

lucafedeli88 avatar Aug 29 '24 08:08 lucafedeli88

We can collapse a few extra << between string constants.

I agree. I have accepted all your suggestions!

lucafedeli88 avatar Sep 05 '24 11:09 lucafedeli88