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

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

Issue 1499293002: Move Rvalue references to the allowed section of the C++11 styleguide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stylervalues: linky Created 5 years 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 <td>Range-Based For Loops</td> 238 <td>Range-Based For Loops</td>
239 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> 239 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td>
240 <td>Facilitates a more concise syntax for iterating over the elements 240 <td>Facilitates a more concise syntax for iterating over the elements
241 of a container (or a range of iterators) in a <code>for</code> loop</td> 241 of a container (or a range of iterators) in a <code>for</code> loop</td>
242 <td><a href="http://en.cppreference.com/w/cpp/language/range-for"> 242 <td><a href="http://en.cppreference.com/w/cpp/language/range-for">
243 Range-based for loop</a></td> 243 Range-based for loop</a></td>
244 <td>As a rule of thumb, use <code>for (const auto& ...)</code>, <code>for (auto& ...)</code>, or <code>for (<i>concrete type</i> ...)</code>. For pointers, use <code>for (auto* ...)</code> to make clear that the copy of the loop variable is intended, and only a pointer is copied. <a href="https://groups.google.com/a/ch romium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread</a></td> 244 <td>As a rule of thumb, use <code>for (const auto& ...)</code>, <code>for (auto& ...)</code>, or <code>for (<i>concrete type</i> ...)</code>. For pointers, use <code>for (auto* ...)</code> to make clear that the copy of the loop variable is intended, and only a pointer is copied. <a href="https://groups.google.com/a/ch romium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread</a></td>
245 </tr> 245 </tr>
246 246
247 <tr> 247 <tr>
248 <td>Rvalue References</td>
249 <td><code>T(T&amp;&amp; t)</code> and <code>T&amp; operator=(T&amp;&amp; t)</cod e><br/>
250 <code>template <typename T>void Function(T&& t) { ... }</code></td>
251 <td>Reference that only binds to a temporary object</td>
252 <td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_referen ces">
253 Rvalue references</a></td>
254 <td>As per the <a href="https://google.github.io/styleguide/cppguide.html#Rvalue _references">Google style guide</a>: Only use these to define move constructors and move assignment operators, and for perfect forwarding.<br/>Most classes shou ld not be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN (o r DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND if needed) in most cases. <a href= "https://groups.google.com/a/chromium.org/d/topic/chromium-dev/UnRaORb4TSw">Disc ussion thread</a> and <a href="https://groups.google.com/a/chromium.org/d/topic/ cxx/Q526tkruXpM">discussion thread</a>.</td>
Nico 2015/12/07 19:00:35 Should we list the MSVC bugs we know about here to
danakj 2015/12/07 19:08:27 Done! (I only remember 2, do you remember more?)
255 </tr>
256
257 <tr>
248 <td>Standard Integers</td> 258 <td>Standard Integers</td>
249 <td>Typedefs within <code>&lt;stdint.h&gt;</code> 259 <td>Typedefs within <code>&lt;stdint.h&gt;</code>
250 and <code>&lt;inttypes&gt;</code></td> 260 and <code>&lt;inttypes&gt;</code></td>
251 <td>Provides fixed-size integers independent of platforms</td> 261 <td>Provides fixed-size integers independent of platforms</td>
252 <td><a href="http://www.cplusplus.com/reference/cstdint/"> 262 <td><a href="http://www.cplusplus.com/reference/cstdint/">
253 &lt;stdint.h&gt; (cstdint)</a></td> 263 &lt;stdint.h&gt; (cstdint)</a></td>
254 <td>Already in common use in the codebase. Approved without discussion.</td> 264 <td>Already in common use in the codebase. Approved without discussion.</td>
255 </tr> 265 </tr>
256 266
257 <tr> 267 <tr>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d> 343 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d>
334 <td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpack ing or multiple assignments is still not allowed. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></t d> 344 <td>General use of <code>std::tuple</code>, and <code>std::tie</code> for unpack ing or multiple assignments is still not allowed. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/3DZ64dIMRTY/discussion">Discussion thread</a></t d>
335 </tr> 345 </tr>
336 346
337 <tr> 347 <tr>
338 <td>Move Semantics</td> 348 <td>Move Semantics</td>
339 <td><code>std::move()</code></td> 349 <td><code>std::move()</code></td>
340 <td>Facilitates efficient move operations</td> 350 <td>Facilitates efficient move operations</td>
341 <td><a href="http://en.cppreference.com/w/cpp/utility/move"> 351 <td><a href="http://en.cppreference.com/w/cpp/utility/move">
342 <code>std::move</code> reference</a></td> 352 <code>std::move</code> reference</a></td>
343 <td>Note: std::move() is allowed but writing your own move constructors is still only allowed in exceptional cases for now, see 'Rvalue References (and Move Sem antics)'. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_ dWFxJFdbM'>Discussion thread</a></td> 353 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td>
344 </tr> 354 </tr>
345 355
346 <tr> 356 <tr>
347 <td>Conditional Type Selection</td> 357 <td>Conditional Type Selection</td>
348 <td><code>std::enable_if</code> and <code>std::conditional</code></td> 358 <td><code>std::enable_if</code> and <code>std::conditional</code></td>
349 <td>Enables compile-time conditional type selection</td> 359 <td>Enables compile-time conditional type selection</td>
350 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if"> 360 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if">
351 std::enable_if</a> and 361 std::enable_if</a> and
352 <a href="http://en.cppreference.com/w/cpp/types/conditional"> 362 <a href="http://en.cppreference.com/w/cpp/types/conditional">
353 conditional</a></td> 363 conditional</a></td>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 <td>Raw String Literals</td> 461 <td>Raw String Literals</td>
452 <td><code>string <i>var</i>=R&quot;(<i>raw_string</i>)&quot;;</code></td> 462 <td><code>string <i>var</i>=R&quot;(<i>raw_string</i>)&quot;;</code></td>
453 <td>Allows a string to be encoded without any escape 463 <td>Allows a string to be encoded without any escape
454 sequences, easing parsing in regex expressions, for example</td> 464 sequences, easing parsing in regex expressions, for example</td>
455 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> 465 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">
456 string literal</a></td> 466 string literal</a></td>
457 <td>Causes incorrect line numbers in MSVS2013 and gcc. Reevaluate once that work s. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ 2kWQHbbuMHI">Discussion thread</a></td> 467 <td>Causes incorrect line numbers in MSVS2013 and gcc. Reevaluate once that work s. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ 2kWQHbbuMHI">Discussion thread</a></td>
458 </tr> 468 </tr>
459 469
460 <tr> 470 <tr>
461 <td>Rvalue References (and Move Semantics)</td>
462 <td><code>T(T&amp;&amp; t)</code> and <code>T&amp; operator=(T&amp;&amp; t)</cod e></td>
463 <td>Reference that only binds to a temporary object</td>
464 <td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_referen ces">
465 Rvalue references</a></td>
466 <td>To be revisited in the future. Allowed in exceptional cases where approved by the OWNERS of src/styleguide/c++/. <a href="https://groups.google.com/a/chrom ium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussion thread</a></td>
467 </tr>
468
469 <tr>
470 <td>(Uniform) Initialization Syntax</td> 471 <td>(Uniform) Initialization Syntax</td>
471 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t d> 472 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t d>
472 <td>Allows any object of primitive, aggregate or class 473 <td>Allows any object of primitive, aggregate or class
473 type to be initialized using brace syntax</td> 474 type to be initialized using brace syntax</td>
474 <td>TODO: documentation link</td> 475 <td>TODO: documentation link</td>
475 <td>Dangerous without library support, see thread. Reevaulate once we have C++11 library support. <a href="https://groups.google.com/a/chromium.org/forum/#!topi c/chromium-dev/GF96FshwHLw">Discussion thread</a></td> 476 <td>Dangerous without library support, see thread. Reevaulate once we have C++11 library support. <a href="https://groups.google.com/a/chromium.org/forum/#!topi c/chromium-dev/GF96FshwHLw">Discussion thread</a></td>
476 </tr> 477 </tr>
477 478
478 <tr> 479 <tr>
479 <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td> 480 <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td>
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 C++ Style Guide</a>. However, may be useful for 1069 C++ Style Guide</a>. However, may be useful for
1069 consuming non-ASCII data.</td> 1070 consuming non-ASCII data.</td>
1070 </tr> 1071 </tr>
1071 1072
1072 </tbody> 1073 </tbody>
1073 </table> 1074 </table>
1074 1075
1075 </div> 1076 </div>
1076 </body> 1077 </body>
1077 </html> 1078 </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