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

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: specify who can approve ref-qualified member functions 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>
558 Banned in the google3 C++11 library style guide. Banned in Chromium except by explicit approval from <code>styleguide/c++/OWNERS</code>.
559 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/gowclr2LPQA/disc ussion">Discussion Thread</a>
560 </td>
561 </tr>
562
551 </tbody> 563 </tbody>
552 </table> 564 </table>
553 565
554 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3> 566 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3>
555 567
556 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p> 568 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p>
557 569
558 <table id="blacklist_lib_list" class="unlined striped"> 570 <table id="blacklist_lib_list" class="unlined striped">
559 <tbody> 571 <tbody>
560 572
(...skipping 23 matching lines...) Expand all
584 596
585 <tr> 597 <tr>
586 <td>Thread Library</td> 598 <td>Thread Library</td>
587 <td><code>&lt;thread&gt; support, including &lt;future&gt;, 599 <td><code>&lt;thread&gt; support, including &lt;future&gt;,
588 &lt;mutex&gt;, &lt;condition_variable&gt;</code></td> 600 &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> 601 <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> 602 <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> 603 <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> 604 </tr>
593 605
606 <tr>
607 <td>Atomics</td>
608 <td><code>std::atomic</code> and others in <code>&lt;atomic&gt;</code></td>
609 <td>Fine-grained atomic types and operations</td>
610 <td><a href="http://en.cppreference.com/w/cpp/atomic">&lt;atomic&gt;</a></td>
611 <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>
612 </tr>
613
614 <tr>
615 <td>Shared Pointers</td>
616 <td><code>std::shared_ptr</code></td>
617 <td>Allows shared ownership of a pointer through reference counts</td>
618 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td>
619 <td>
620 Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature.
621 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/aT2wsBLKvzI/disc ussion">Discussion Thread</a>,
622 <a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart _Pointers">Google Style Guide</a>
623 </td>
624 </tr>
625
626 <tr>
627 <td>Initializer Lists</td>
628 <td><code>std::initializer_list&lt;T&gt;</code></td>
629 <td>Allows containers to be initialized with aggregate elements</td>
630 <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list"><code>st d::initializer_list</code></a></td>
631 <td>
632 Banned for now; will be re-evaluated once we switch to MSVC 2015.
633 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/TQQ-L51_naM/disc ussion">Discussion Thread</a>
634 </td>
635 </tr>
636
594 </tbody> 637 </tbody>
595 </table> 638 </table>
596 639
597 640
598 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3> 641 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3>
599 642
600 <p>The following C++ language features are currently disallowed. 643 <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 644 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 645 into the allowed or banned sections. Note that not all of these features
603 work in all our compilers yet.</p> 646 work in all our compilers yet.</p>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 680
638 <tr> 681 <tr>
639 <td>Inline Namespaces</td> 682 <td>Inline Namespaces</td>
640 <td><code>inline</code></td> 683 <td><code>inline</code></td>
641 <td>Allows better versioning of namespaces</td> 684 <td>Allows better versioning of namespaces</td>
642 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td> 685 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td>
643 <td>Unclear how it will work with components</td> 686 <td>Unclear how it will work with components</td>
644 </tr> 687 </tr>
645 688
646 <tr> 689 <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> 690 <td>Union Class Members</td>
657 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td> 691 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td>
658 <td>Allows class type members</td> 692 <td>Allows class type members</td>
659 <td><a href="http://en.cppreference.com/w/cpp/language/union"> 693 <td><a href="http://en.cppreference.com/w/cpp/language/union">
660 Union declarations</a></td> 694 Union declarations</a></td>
661 <td></td> 695 <td></td>
662 </tr> 696 </tr>
663 697
664 <tr> 698 <tr>
665 <td>User-Defined Literals</td> 699 <td>User-Defined Literals</td>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 <tr> 751 <tr>
718 <td>Allocator Traits</td> 752 <td>Allocator Traits</td>
719 <td><code>std::allocator_traits</code></td> 753 <td><code>std::allocator_traits</code></td>
720 <td>Provides an interface for accessing custom allocators</td> 754 <td>Provides an interface for accessing custom allocators</td>
721 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits"> 755 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">
722 std::allocator_traits</a></td> 756 std::allocator_traits</a></td>
723 <td>Usage should be rare.</td> 757 <td>Usage should be rare.</td>
724 </tr> 758 </tr>
725 759
726 <tr> 760 <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> 761 <td>Bind Operations</td>
736 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> 762 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td>
737 <td>Declares a function object bound to certain arguments</td> 763 <td>Declares a function object bound to certain arguments</td>
738 <td>TODO: documentation link</td> 764 <td>TODO: documentation link</td>
739 <td></td> 765 <td></td>
740 </tr> 766 </tr>
741 767
742 <tr> 768 <tr>
743 <td>C Floating-Point Environment</td> 769 <td>C Floating-Point Environment</td>
744 <td><code>&lt;cfenv&gt;</code>, <code>&lt;fenv.h&gt;</code></td> 770 <td><code>&lt;cfenv&gt;</code>, <code>&lt;fenv.h&gt;</code></td>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 <td><code>std::next()</code> and <code>std::prev()</code></td> 893 <td><code>std::next()</code> and <code>std::prev()</code></td>
868 <td>Copies an iterator and increments or decrements the copy by 894 <td>Copies an iterator and increments or decrements the copy by
869 some value</td> 895 some value</td>
870 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a> 896 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a>
871 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> 897 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a>
872 </td> 898 </td>
873 <td></td> 899 <td></td>
874 </tr> 900 </tr>
875 901
876 <tr> 902 <tr>
877 <td>Initializer Lists</td>
878 <td><code>std::initializer_list&lt;T&gt;</code></td>
879 <td>Allows containers to be initialized with aggregate elements</td>
880 <td>TODO: documentation link</td>
881 <td></td>
882 </tr>
883
884 <tr>
885 <td>Pointer Traits Class Template</td> 903 <td>Pointer Traits Class Template</td>
886 <td><code>std::pointer_traits</code></td> 904 <td><code>std::pointer_traits</code></td>
887 <td>Provides a standard way to access properties 905 <td>Provides a standard way to access properties
888 of pointers and pointer-like types</td> 906 of pointers and pointer-like types</td>
889 <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits"> 907 <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits">
890 std::pointer_traits</a></td> 908 std::pointer_traits</a></td>
891 <td>Useful for determining the element type 909 <td>Useful for determining the element type
892 pointed at by a (possibly smart) pointer.</td> 910 pointed at by a (possibly smart) pointer.</td>
893 </tr> 911 </tr>
894 912
(...skipping 21 matching lines...) Expand all
916 <td><code>std::reference_wrapper</code> and 934 <td><code>std::reference_wrapper</code> and
917 <code>std::ref()</code>, <code>std::cref()</code></td> 935 <code>std::ref()</code>, <code>std::cref()</code></td>
918 <td>Allows you to wrap a reference within a standard 936 <td>Allows you to wrap a reference within a standard
919 object (and use those within containers)</td> 937 object (and use those within containers)</td>
920 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum= 217"> 938 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum= 217">
921 Reference Wrappers</a></td> 939 Reference Wrappers</a></td>
922 <td></td> 940 <td></td>
923 </tr> 941 </tr>
924 942
925 <tr> 943 <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> 944 <td>Soft Program Exits</td>
936 <td><code>std::at_quick_exit()</code> 945 <td><code>std::at_quick_exit()</code>
937 and <code>std::quick_exit()</code></td> 946 and <code>std::quick_exit()</code></td>
938 <td>Allows registration of functions to be called upon exit, 947 <td>Allows registration of functions to be called upon exit,
939 allowing cleaner program exit than <code>abort()</code> or 948 allowing cleaner program exit than <code>abort()</code> or
940 <code>exit</code></td> 949 <code>exit</code></td>
941 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit"> 950 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">
942 std:quick_exit</a></td> 951 std:quick_exit</a></td>
943 <td></td> 952 <td></td>
944 </tr> 953 </tr>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 C++ Style Guide</a>. However, may be useful for 1098 C++ Style Guide</a>. However, may be useful for
1090 consuming non-ASCII data.</td> 1099 consuming non-ASCII data.</td>
1091 </tr> 1100 </tr>
1092 1101
1093 </tbody> 1102 </tbody>
1094 </table> 1103 </table>
1095 1104
1096 </div> 1105 </div>
1097 </body> 1106 </body>
1098 </html> 1107 </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