Boost logo

Boost :

From: Dave Steffen (steffend_at_[hidden])
Date: 2000-03-06 18:20:17


> Replacing endl with nl trades one efficiency problem for another
> (albeit smaller) one. As it stands now, as long as the industry
> literature makes clear to users "don't use std::endl unless a flush
> is called for", hopefully users will turn to the alterative of:
> cout << "First line\nSecond line";
> or one of its more readable cousins like:
> cout <<
> "First line" "\n"
> "Second line";

 ?? How does that work? Am I missing something?

> Providing a nl encourages the code that is the equivalent of:
> cout << "First line" << "\n" << "Second line";

 Agreed... although, is it that big a slowdown? Or, alternately, is it
 that hard for a compiler to optimize?

 Personally, I got very used to 'endl' before reading Scott Meyer's
 article; I went to 'nl' because I'm used to that kind of thing, find
 it fast to type and easy to read. (My code is all numerical, the I/O
 is something like .001% of the run time. ;-)

--------------------------------------------------------------------------
Dave Steffen Wave after wave will flow with the tide
Dept. of Physics And bury the world as it does
Colorado State University Tide after tide will flow and recede
steffend_at_[hidden] Leaving life to go on as it was...
                                                        - Peart / RUSH
"The reason that our people suffer in this way....
is that our ancestors failed to rule wisely". -General Choi, Hong Hi


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk