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

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

Issue 1570443005: styleguide: Ban ref-qualified member functions, <atomic>, std::shared_ptr and std::initializer_list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 <tr> 542 <tr>
543 <td>UTF-8, UTF-16, UTF-32 String Literals</td> 543 <td>UTF-8, UTF-16, UTF-32 String Literals</td>
544 <td><code>u8&quot;<i>string</i>&quot;, u&quot;<i>string</i>&quot;, U&quot;<i>str ing</i>&quot;</code></td> 544 <td><code>u8&quot;<i>string</i>&quot;, u&quot;<i>string</i>&quot;, U&quot;<i>str ing</i>&quot;</code></td>
545 <td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td> 545 <td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td>
546 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> 546 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">
547 string literal</a></td> 547 string literal</a></td>
548 <td>Does not yet work in MSVS2013. Reevaluate once it does. <a href="https://gro ups.google.com/a/chromium.org/forum/#!topic/chromium-dev/gcoUbcjfsII">Discussion thread</a></td> 548 <td>Does not yet work in MSVS2013. Reevaluate once it does. <a href="https://gro ups.google.com/a/chromium.org/forum/#!topic/chromium-dev/gcoUbcjfsII">Discussion thread</a></td>
549 </tr> 549 </tr>
550 550
551 <tr>
552 <td>Ref-qualified Member Functions</td>
553 <td><code>class T {<br/>&nbsp;&nbsp;void f() & {}<br/>&nbsp;&nbsp;void f() && {} <br/>};<br/>t.f(); // first<br/>T().f(); // second<br/>std::move(t).f(); // sec ond</code></td>
554 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td>
555 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions">
556 Member functions</a></td>
557 <td>Banned in the google3 C++11 library style guide. Banned in Chromium except b y explicit approval.</td>
Nico 2016/01/07 22:40:36 Can you add a Discussion thread link here?
jbroman 2016/01/07 23:26:32 Done.
558 </tr>
559
551 </tbody> 560 </tbody>
552 </table> 561 </table>
553 562
554 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3> 563 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3>
555 564
556 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p> 565 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p>
557 566
558 <table id="blacklist_lib_list" class="unlined striped"> 567 <table id="blacklist_lib_list" class="unlined striped">
559 <tbody> 568 <tbody>
560 569
(...skipping 23 matching lines...) Expand all
584 593
585 <tr> 594 <tr>
586 <td>Thread Library</td> 595 <td>Thread Library</td>
587 <td><code>&lt;thread&gt; support, including &lt;future&gt;, 596 <td><code>&lt;thread&gt; support, including &lt;future&gt;,
588 &lt;mutex&gt;, &lt;condition_variable&gt;</code></td> 597 &lt;mutex&gt;, &lt;condition_variable&gt;</code></td>
589 <td>Provides a standard mulitthreading library using <code>std::thread</code> an d associates</td> 598 <td>Provides a standard mulitthreading library using <code>std::thread</code> an d associates</td>
590 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td> 599 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td>
591 <td>C++11 has all kinds of classes for threads, mutexes, etc. Since we already h ave good code for this in <code>base/</code>, we should keep using the base clas ses, at least at first. <code>base::Thread</code> is tightly coupled to <code>Me ssageLoop</code> which would make it hard to replace. We should investigate usin g standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td> 600 <td>C++11 has all kinds of classes for threads, mutexes, etc. Since we already h ave good code for this in <code>base/</code>, we should keep using the base clas ses, at least at first. <code>base::Thread</code> is tightly coupled to <code>Me ssageLoop</code> which would make it hard to replace. We should investigate usin g standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td>
592 </tr> 601 </tr>
593 602
603 <tr>
604 <td>Atomics</td>
605 <td><code>std::atomic</code> and others in <code>&lt;atomic&gt;</code></td>
606 <td>Fine-grained atomic types and operations</td>
607 <td><a href="http://en.cppreference.com/w/cpp/atomic">&lt;atomic&gt;</a></td>
608 <td>Use in tcmalloc has caused <a href="http://crbug.com/572525">performance reg ressions</a>. Banned until we understand this better. <a href="https://groups.go ogle.com/a/chromium.org/d/topic/cxx/Ej3RAiaI44s/discussion">Discussion Thread</a ></td>
609 </tr>
610
611 <tr>
612 <td>Shared Pointers</td>
613 <td><code>std::shared_ptr</code></td>
614 <td>Allows shared ownership of a pointer through reference counts</td>
615 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td>
616 <td>
617 Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature.
618 <a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart _Pointers">Ownership and Smart Pointers</a>
Nico 2016/01/07 22:40:36 Here too
jbroman 2016/01/07 23:26:32 Done.
619 </td>
620 </tr>
621
594 </tbody> 622 </tbody>
595 </table> 623 </table>
596 624
597 625
598 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3> 626 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3>
599 627
600 <p>The following C++ language features are currently disallowed. 628 <p>The following C++ language features are currently disallowed.
601 See the top of this page on how to propose moving a feature from this list 629 See the top of this page on how to propose moving a feature from this list
602 into the allowed or banned sections. Note that not all of these features 630 into the allowed or banned sections. Note that not all of these features
603 work in all our compilers yet.</p> 631 work in all our compilers yet.</p>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 665
638 <tr> 666 <tr>
639 <td>Inline Namespaces</td> 667 <td>Inline Namespaces</td>
640 <td><code>inline</code></td> 668 <td><code>inline</code></td>
641 <td>Allows better versioning of namespaces</td> 669 <td>Allows better versioning of namespaces</td>
642 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td> 670 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td>
643 <td>Unclear how it will work with components</td> 671 <td>Unclear how it will work with components</td>
644 </tr> 672 </tr>
645 673
646 <tr> 674 <tr>
647 <td>Ref-qualified Member Functions</td>
648 <td><code>class T {<br/>&nbsp;&nbsp;void f() & {}<br/>&nbsp;&nbsp;void f() && {} <br/>};<br/>t.f(); // first<br/>T().f(); // second<br/>std::move(t).f(); // sec ond</code></td>
649 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td>
650 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions">
651 Member functions</a></td>
652 <td>Banned in the google3 C++11 library style guide, but being considered for us e in bind/callback in google3 and the standard library.</td>
653 </tr>
654
655 <tr>
656 <td>Union Class Members</td> 675 <td>Union Class Members</td>
657 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td> 676 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td>
658 <td>Allows class type members</td> 677 <td>Allows class type members</td>
659 <td><a href="http://en.cppreference.com/w/cpp/language/union"> 678 <td><a href="http://en.cppreference.com/w/cpp/language/union">
660 Union declarations</a></td> 679 Union declarations</a></td>
661 <td></td> 680 <td></td>
662 </tr> 681 </tr>
663 682
664 <tr> 683 <tr>
665 <td>User-Defined Literals</td> 684 <td>User-Defined Literals</td>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 <tr> 736 <tr>
718 <td>Allocator Traits</td> 737 <td>Allocator Traits</td>
719 <td><code>std::allocator_traits</code></td> 738 <td><code>std::allocator_traits</code></td>
720 <td>Provides an interface for accessing custom allocators</td> 739 <td>Provides an interface for accessing custom allocators</td>
721 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits"> 740 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">
722 std::allocator_traits</a></td> 741 std::allocator_traits</a></td>
723 <td>Usage should be rare.</td> 742 <td>Usage should be rare.</td>
724 </tr> 743 </tr>
725 744
726 <tr> 745 <tr>
727 <td>Atomics</td>
728 <td><code>std::atomic</code> and others in <code>&lt;atomic&gt;</code></td>
729 <td>Fine-grained atomic types and operations</td>
730 <td><a href="http://en.cppreference.com/w/cpp/atomic">&lt;atomic&gt;</a></td>
731 <td></td>
732 </tr>
733
734 <tr>
735 <td>Bind Operations</td> 746 <td>Bind Operations</td>
736 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> 747 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td>
737 <td>Declares a function object bound to certain arguments</td> 748 <td>Declares a function object bound to certain arguments</td>
738 <td>TODO: documentation link</td> 749 <td>TODO: documentation link</td>
739 <td></td> 750 <td></td>
740 </tr> 751 </tr>
741 752
742 <tr> 753 <tr>
743 <td>C Floating-Point Environment</td> 754 <td>C Floating-Point Environment</td>
744 <td><code>&lt;cfenv&gt;</code>, <code>&lt;fenv.h&gt;</code></td> 755 <td><code>&lt;cfenv&gt;</code>, <code>&lt;fenv.h&gt;</code></td>
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 <td><code>std::reference_wrapper</code> and 927 <td><code>std::reference_wrapper</code> and
917 <code>std::ref()</code>, <code>std::cref()</code></td> 928 <code>std::ref()</code>, <code>std::cref()</code></td>
918 <td>Allows you to wrap a reference within a standard 929 <td>Allows you to wrap a reference within a standard
919 object (and use those within containers)</td> 930 object (and use those within containers)</td>
920 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum= 217"> 931 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum= 217">
921 Reference Wrappers</a></td> 932 Reference Wrappers</a></td>
922 <td></td> 933 <td></td>
923 </tr> 934 </tr>
924 935
925 <tr> 936 <tr>
926 <td>Shared Pointers</td>
927 <td><code>std::shared_ptr</code></td>
928 <td>Allows shared ownership of a pointer through reference counts</td>
929 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td>
930 <td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Sma rt_Pointers">
931 Ownership and Smart Pointers</a></td>
932 </tr>
933
934 <tr>
935 <td>Soft Program Exits</td> 937 <td>Soft Program Exits</td>
936 <td><code>std::at_quick_exit()</code> 938 <td><code>std::at_quick_exit()</code>
937 and <code>std::quick_exit()</code></td> 939 and <code>std::quick_exit()</code></td>
938 <td>Allows registration of functions to be called upon exit, 940 <td>Allows registration of functions to be called upon exit,
939 allowing cleaner program exit than <code>abort()</code> or 941 allowing cleaner program exit than <code>abort()</code> or
940 <code>exit</code></td> 942 <code>exit</code></td>
941 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit"> 943 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">
942 std:quick_exit</a></td> 944 std:quick_exit</a></td>
943 <td></td> 945 <td></td>
944 </tr> 946 </tr>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 C++ Style Guide</a>. However, may be useful for 1091 C++ Style Guide</a>. However, may be useful for
1090 consuming non-ASCII data.</td> 1092 consuming non-ASCII data.</td>
1091 </tr> 1093 </tr>
1092 1094
1093 </tbody> 1095 </tbody>
1094 </table> 1096 </table>
1095 1097
1096 </div> 1098 </div>
1097 </body> 1099 </body>
1098 </html> 1100 </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