From: Ed Brey (brey_at_[hidden])
Date: 2000-03-06 17:07:12
From: "Dave Steffen" <steffend_at_[hidden]>
> Greg Colvin writes:
> > > Dave Abrahams writes:
> > > [...]
> > > cout << "First line" << nl << "Second line" << nl;
> > Just to save two keystrokes? Well, four total in this line.
> Well, it's not just the keystrokes. I didn't mind typing "endl", but
> wanted to avoid gratuitously flushing the buffer. And I find that
> "nl" is a lot easier to type than "'\n'", my fingers don't have to
> leave the home keys and all that. ;-)
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:
"First line" "\n"
Providing a nl encourages the code that is the equivalent of:
cout << "First line" << "\n" << "Second line";
which, at least under VC and gcc, doesn't get optimized away.
> BTW this is one of the less important things we should think about
> fixing/tweaking in the streams library... I'm much more interested in
> some of the proposals for formatting.
Agreed. Definitely not worth the time trying to put in a "fix", especially
when there is a current solution which is readable and generates optimal
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk