On Fri, 19 Sep 2008 13:30:52 -0700 (PDT), James Kanze <james.kanze@gm ail.comwrote:
....
>
>
Sounds like premature optimization to me.
No, it's more "do not do things without a reason" or "use the simplest
construct which does what I want".
>
Just the opposite. Most of the time, std::endl is preferable.
With '\n', you never know when your data is going to end up on
disk.
My reasoning is the opposite of yours. Most of the time I don't care
when the data hits disk[1], and I make this clearer by not using
std::endl.
(OK, I admit I also have this suspicion -- not confirmed by
experiments -- that std::endl means a large performance hit in some
situations. I don't want my Unix pipelines to run at half the speed
because there is extensive I/O flushing somewhere along the way.)
I thought everyone reasoned like that about endl, except newbies who
used it because they thought that '\n' was somehow a less portable way
of ending a line. But I know you as an experienced and careful C++
programmer, so I clearly have to revise that opinion ...
/Jorgen
[1] Or whatever endl guarantees on my system; I assume it will at
least leave the application.
--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se R'lyeh wgah'nagl fhtagn!
On Sep 19, 12:55 pm, Jorgen Grahn <grahn+n...@sni pabacken.sewrot e:
>On Wed, 10 Sep 2008 17:06:16 +0500, arnuld <sunr...@invali d.addresswrote:
std::cout << "--------------------------------"
<< std::endl;
<< std::endl;
>I would skip the std::endl here though, and use "...---\n" instead.
Sounds like premature optimization to me.
construct which does what I want".
>std::endl is not "the thing you should use instead of '\n'"
>(although many people believe it is, for some reason).
>(although many people believe it is, for some reason).
Just the opposite. Most of the time, std::endl is preferable.
With '\n', you never know when your data is going to end up on
disk.
when the data hits disk[1], and I make this clearer by not using
std::endl.
(OK, I admit I also have this suspicion -- not confirmed by
experiments -- that std::endl means a large performance hit in some
situations. I don't want my Unix pipelines to run at half the speed
because there is extensive I/O flushing somewhere along the way.)
I thought everyone reasoned like that about endl, except newbies who
used it because they thought that '\n' was somehow a less portable way
of ending a line. But I know you as an experienced and careful C++
programmer, so I clearly have to revise that opinion ...
/Jorgen
[1] Or whatever endl guarantees on my system; I assume it will at
least leave the application.
--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se R'lyeh wgah'nagl fhtagn!
Comment