aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-01-20 19:01:26 +0000
committerChris Lattner <sabre@nondot.org>2002-01-20 19:01:26 +0000
commit13c4659220bc78a0a3529f4d9e57546e898088e3 (patch)
tree5fd8ac5857802243dc54e668178729144d3a6a91
parent304e707e8e09edceb4a5eb1d3270e9319dcbfc96 (diff)
Add a note about endl semantics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1502 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/CodingStandards.html16
1 files changed, 15 insertions, 1 deletions
diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html
index 62288cc9e8..8566e670f2 100644
--- a/docs/CodingStandards.html
+++ b/docs/CodingStandards.html
@@ -37,6 +37,7 @@
<ol>
<li><a href="#hl_assert">Assert Liberally</a>
<li><a href="#hl_preincrement">Prefer Preincrement</a>
+ <li><a href="#hl_avoidendl">Avoid endl</a>
<li><a href="#hl_exploitcpp">Exploit C++ to its Fullest</a>
</ol>
<li><a href="#iterators">Writing Iterators</a>
@@ -293,6 +294,19 @@ The semantics of postincrement include making a copy of the value being incremen
<!-- _______________________________________________________________________ -->
+</ul><a name="hl_avoidendl"><h4><hr size=0>Avoid endl</h4><ul>
+
+The <tt>endl</tt> modifier, when used with iostreams outputs a newline to the output stream specified. In addition to doing this, however, it also flushes the output stream. In other words, these are equivalent:<p>
+
+<pre>
+ cout << endl;
+ cout << "\n" << flush;
+</pre>
+
+Most of the time, you probably have no reason to flush the output stream, so it's better to use a literal <tt>"\n"</tt>.<p>
+
+
+<!-- _______________________________________________________________________ -->
</ul><a name="hl_exploitcpp"><h4><hr size=0>Exploit C++ to its Fullest</h4><ul>
C++ is a powerful language. With a firm grasp on its capabilities, you can make write effective, consise, readable and maintainable code all at the same time. By staying consistent, you reduce the amount of special cases that need to be remembered. Reducing the total number of lines of code you write is a good way to avoid documentation, and avoid giving bugs a place to hide.<p>
@@ -646,7 +660,7 @@ If you get some free time, and you haven't read them: do so, you might learn som
<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
<!-- Created: Tue Jan 23 15:19:28 CST 2001 -->
<!-- hhmts start -->
-Last modified: Mon Oct 1 15:33:40 CDT 2001
+Last modified: Sun Jan 20 13:01:02 CST 2002
<!-- hhmts end -->
</font>
</body></html>