mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 04:44:34 +03:00
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:
@@ -20308,6 +20308,14 @@ For writing to a file, there is rarely a need to `flush`.
|
|||||||
|
|
||||||
##### Note
|
##### 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,
|
Apart from the (occasionally important) issue of performance,
|
||||||
the choice between `'\n'` and `endl` is almost completely aesthetic.
|
the choice between `'\n'` and `endl` is almost completely aesthetic.
|
||||||
|
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ optimizable
|
|||||||
O'Reilly
|
O'Reilly
|
||||||
org
|
org
|
||||||
ostream
|
ostream
|
||||||
|
ostringstream
|
||||||
overabstract
|
overabstract
|
||||||
overconstrain
|
overconstrain
|
||||||
overconstrained
|
overconstrained
|
||||||
|
|||||||
Reference in New Issue
Block a user