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

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

Issue 2115533002: Allow binding captureless lambdas into base::Callback by base::Bind (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@05_remove_runnable
Patch Set: rebase Created 4 years, 5 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 | « base/bind_unittest.nc ('k') | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> 177 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td>
178 <td>TODO: documentation link</td> 178 <td>TODO: documentation link</td>
179 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td> 179 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td>
180 </tr> 180 </tr>
181 181
182 <tr> 182 <tr>
183 <td>Lambda Expressions</td> 183 <td>Lambda Expressions</td>
184 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td> 184 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td>
185 <td>Anonymous functions</td> 185 <td>Anonymous functions</td>
186 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td> 186 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td>
187 <td>Do not bind or store lambdas outside the lifetime of the stack frame they ar e defined in; use <code>base::Bind</code> and <code>base::Callback</code> instea d, because they offer protection against a large class of object lifetime mistak es. Don't use default captures (<code>[=]</code>, <code>[&amp;]</code> &ndash; < a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Go ogle 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/chro mium-dev/D9UnnxBnciQ">Discussion thread</a></td> 187 <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>
188 </tr> 188 </tr>
189 189
190 <tr> 190 <tr>
191 <td>Local Types as Template Arguments</td> 191 <td>Local Types as Template Arguments</td>
192 <td><code>void func() {<br /> 192 <td><code>void func() {<br />
193 &nbsp;&nbsp;class Pred {<br /> 193 &nbsp;&nbsp;class Pred {<br />
194 &nbsp;&nbsp;&nbsp;public:<br /> 194 &nbsp;&nbsp;&nbsp;public:<br />
195 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br /> 195 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br />
196 &nbsp;&nbsp;};<br /> 196 &nbsp;&nbsp;};<br />
197 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td> 197 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td>
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 <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> 918 <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>
919 <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> 919 <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>
920 </tr> 920 </tr>
921 921
922 </tbody> 922 </tbody>
923 </table> 923 </table>
924 924
925 </div> 925 </div>
926 </body> 926 </body>
927 </html> 927 </html>
OLDNEW
« no previous file with comments | « base/bind_unittest.nc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698