Do you have a preference on maximum line width for C++ code?
I've seen the craziest debates on this most silly of topic.
I have witnessed engineers spent oodles of time fiddling with
line breaks just to get it right. I find in general a
prescriptive rule makes for markedly less readable code, which
unfortunately is a subjective argument, however, the waste of
time modifying code when it does not need to is not.
I'm interested in knowing what you'all do.
It depends somewhat on the context:
-- Fundamental technological constraints (and yes, they are
still relevant today) means 80 characters, no tab characters
(and displays with fixed with fonts) are an absolute
maximum. At least for code which has to be readable over a
more or less long period of time or with different (possibly
unknown today) equipment; I'll occasionally break the rule
when I'm just experimenting, say to find out what a compiler
will do.
-- If you're posting a sample in a newsgroup, you'll want to
make is shorter; anything over something between 72 and 80
characters will get its formatting messed up, and since
follow-up postings, quoting it, will add a few characters to
the beginning, I generally try to limit it to 64 characters.
(On the other hand, like everyone else, I'll copy/paste my
code directly from the original source, so if I post actual
code from elsewhere, it is wider. And its formatting does
get messed up.)
-- If you're concerned purely about readability, look at a
newspaper column. They're sized for maximum readability.
Of English, anyway---I suspect that code follows slightly
different rules. Still, anything over about 60 characters,
*not* including indentation, will probably cause problems
for the reader. See Ian's comments with regards to finding
the start of the next line. I don't know if this is the
reason, but there have been concrete studies on this
subject. (Again, concerning native languages, not code.
And resulting in the optimal length being that of a
newspaper column. In English, anyway.)
So as a general rule: a maximum of 80 characters, total, and
between 60 and 70, without the leading indentation.