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

Side by Side Diff: styleguide/c++/c++11.html

Issue 2382103003: Clarify uncapturing lambda functions with Bind styleguide. (Closed)
Patch Set: danakj addressed Created 4 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2014 The Chromium Authors. All rights reserved. 3 Copyright 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <head> 8 <head>
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <title>C++11 use in Chromium</title> 10 <title>C++11 use in Chromium</title>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> 188 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td>
189 <td>TODO: documentation link</td> 189 <td>TODO: documentation link</td>
190 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td> 190 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td>
191 </tr> 191 </tr>
192 192
193 <tr> 193 <tr>
194 <td>Lambda Expressions</td> 194 <td>Lambda Expressions</td>
195 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td> 195 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td>
196 <td>Anonymous functions</td> 196 <td>Anonymous functions</td>
197 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td> 197 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td>
198 <td>Do not bind or store capturing lambdas outside the lifetime of the stack fra me they are defined in; use captureless lambda with <code>base::Bind</code> and <code>base::Callback</code> instead, because they offer protection against a lar ge class of object lifetime mistakes. Don't use default captures (<code>[=]</cod e>, <code>[&amp;]</code> &ndash; <a href="https://google.github.io/styleguide/cp pguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically u seful as a parameter to methods or functions that will use them immediately, suc h 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></t d> 198 <td>Do not bind or store capturing lambdas outside the lifetime of the stack fra me they are defined in. Captureless lambdas can be used with <code>base::Callbac k</code>, such as <code>base::Bind([](int j){}, i);</code>, because they offer p rotection against a large class of object lifetime mistakes. Don't use default c aptures (<code>[=]</code>, <code>[&amp;]</code> &ndash; <a href="https://google. github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will us e them immediately, such as those in <code>&lt;algorithm&gt;</code>. <a href="ht tps://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">D iscussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#! topic/cxx/QxjsPELDYdQ">uncapturing thread</a>.
199 </td>
199 </tr> 200 </tr>
200 201
201 <tr> 202 <tr>
202 <td>Local Types as Template Arguments</td> 203 <td>Local Types as Template Arguments</td>
203 <td><code>void func() {<br /> 204 <td><code>void func() {<br />
204 &nbsp;&nbsp;class Pred {<br /> 205 &nbsp;&nbsp;class Pred {<br />
205 &nbsp;&nbsp;&nbsp;public:<br /> 206 &nbsp;&nbsp;&nbsp;public:<br />
206 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br /> 207 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br />
207 &nbsp;&nbsp;};<br /> 208 &nbsp;&nbsp;};<br />
208 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td> 209 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td>
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert">std::wstri ng_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert ">std::wbuffer_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/cod ecvt_utf8">std::codecvt_utf8</a>, <a href="http://en.cppreference.com/w/cpp/loca le/codecvt_utf16">std::codecvt_utf16</a>, <a href="http://en.cppreference.com/w/ cpp/locale/codecvt_utf8_utf16">std::codecvt_utf8_utf16</a></td> 922 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert">std::wstri ng_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert ">std::wbuffer_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/cod ecvt_utf8">std::codecvt_utf8</a>, <a href="http://en.cppreference.com/w/cpp/loca le/codecvt_utf16">std::codecvt_utf16</a>, <a href="http://en.cppreference.com/w/ cpp/locale/codecvt_utf8_utf16">std::codecvt_utf8_utf16</a></td>
922 <td>Non-UTF-8 text is banned by the <a href="https://google.github.io/styleguide /cppguide.html#Non-ASCII_Characters">Google Style Guide</a>. However, may be use ful for consuming non-ASCII data.</td> 923 <td>Non-UTF-8 text is banned by the <a href="https://google.github.io/styleguide /cppguide.html#Non-ASCII_Characters">Google Style Guide</a>. However, may be use ful for consuming non-ASCII data.</td>
923 </tr> 924 </tr>
924 925
925 </tbody> 926 </tbody>
926 </table> 927 </table>
927 928
928 </div> 929 </div>
929 </body> 930 </body>
930 </html> 931 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698