Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(902)

Unified Diff: styleguide/c++/c++11.html

Issue 699283002: c++11: Allow lambdas, with some restrictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/history_backend_unittest.cc ('k') | ui/base/layout.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: styleguide/c++/c++11.html
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html
index 6d870fbd0e39caf68bfbc4ebb072dd60a601d3cf..f99a8eb7fdadf8e0572ed66f3c19ef90ed758bf1 100644
--- a/styleguide/c++/c++11.html
+++ b/styleguide/c++/c++11.html
@@ -116,6 +116,23 @@ enum classes and regular enums.</td>
</tr>
<tr>
+<td>Lambda Expressions</td>
+<td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</code></td>
+<td>Anonymous functions</td>
+<td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td>
+<td>Do not bind or store lambdas; use <code>base::Bind</code> and
+<code>base::Callback</code> instead, because they offer protection against a
+large class of object lifetime mistakes. Don't use default captures
+(<code>[=]</code>, <code>[&amp;]</code> &ndash; <a
+ href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions">Google Style Guide</a>).
+Lambdas are typically useful as a parameter to methods or
+functions that will use them immediately, such as those in
+<code>&lt;algorithm&gt;</code>. <a
+ href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion
+ thread</a></td>
+</tr>
+
+<tr>
<td>Local Types as Template Arguments</td>
<td></td>
<td>Allows local and unnamed types as template arguments</td>
@@ -415,14 +432,6 @@ synthetic function such as a copy constructor</td>
</tr>
<tr>
-<td>Lambda Expressions</td>
-<td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</code></td>
-<td>Anonymous functions</td>
-<td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td>
-<td>No default captures (<a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions">Google Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a></td>
-</tr>
-
-<tr>
<td>Non-Static Class Member Initializers</td>
<td>
<code>
« no previous file with comments | « chrome/browser/history/history_backend_unittest.cc ('k') | ui/base/layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698