Skip to content

Fix SL.io.50: Avoid endl.#2323

Open
lettersdigits wants to merge 1 commit intoisocpp:masterfrom
lettersdigits:patch-1
Open

Fix SL.io.50: Avoid endl.#2323
lettersdigits wants to merge 1 commit intoisocpp:masterfrom
lettersdigits:patch-1

Conversation

@lettersdigits
Copy link
Copy Markdown

Adds wording that makes it clear that usually, replacing std::endl with '\n' is a good idea, but that there are rare cases, for instance when using std::cout, where flushing is important.

An example of that encountered in practice that caused a bug when changing from std::endl to '\n' (not mentioned in the commit changes) is:

Flushing std::cout (or some other stream that does not always automatically in all configurations flush upon \n), as part of checking assumptions and printing the results of checking, just before potentially crashing.

Adds wording that makes it clear that usually, replacing `std::endl` with `'\n'` is a good idea, but that there are rare cases, for instance when using `std::cout`, where flushing is important.

An example of that encountered in practice that caused a bug when changing from `std::endl` to `'\n'` (not mentioned in the commit changes) is:

Flushing `std::cout` (or some other stream that does not always automatically in all configurations flush upon `\n`), as part of checking assumptions and printing the results of checking, just before potentially crashing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant