SL.io.50 (Avoid endl): Mention string streams (#1920)

Explicitly mentioned string streams as `endl` insertions into string streams do actually occur in the wild.

With help from Sergey Zubkov.
This commit is contained in:
Niels Dekker
2022-06-13 18:11:50 +02:00
committed by GitHub
parent a534f4a168
commit 9ead2c44b4
2 changed files with 9 additions and 0 deletions

View File

@@ -20308,6 +20308,14 @@ For writing to a file, there is rarely a need to `flush`.
##### Note
For string streams (specifically `ostringstream`), the insertion of an `endl` is entirely equivalent
to the insertion of a `'\n'` character, but also in this case, `endl` might be significantly slower.
`endl` does *not* take care of producing a platform specific end-of-line sequence (like "\r\n" on
Windows). So for a string stream, `s << endl` just inserts a *single* character, `'\n'`.
##### Note
Apart from the (occasionally important) issue of performance,
the choice between `'\n'` and `endl` is almost completely aesthetic.

View File

@@ -389,6 +389,7 @@ optimizable
O'Reilly
org
ostream
ostringstream
overabstract
overconstrain
overconstrained