OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 <tr> | 72 <tr> |
73 <td>__func__ Local Variable</td> | 73 <td>__func__ Local Variable</td> |
74 <td><code>__func__</code></td> | 74 <td><code>__func__</code></td> |
75 <td>Provides a local variable containing the name of the enclosing function</td> | 75 <td>Provides a local variable containing the name of the enclosing function</td> |
76 <td><a href="http://en.cppreference.com/w/cpp/language/function#func">__func__</
a></td> | 76 <td><a href="http://en.cppreference.com/w/cpp/language/function#func">__func__</
a></td> |
77 <td>Use instead of the non-standard <code>__FUNCTION__</code>. <a href="https://
groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discuss
ion thread</a></td> | 77 <td>Use instead of the non-standard <code>__FUNCTION__</code>. <a href="https://
groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discuss
ion thread</a></td> |
78 </tr> | 78 </tr> |
79 | 79 |
80 <tr> | 80 <tr> |
| 81 <td>Alignment Features</td> |
| 82 <td><code>alignas(alignof(T)) char[10];</code></td> |
| 83 <td>Specifies or queries storage alignment.</td> |
| 84 <td><a href="http://en.cppreference.com/w/chttp://en.cppreference.com/w/cpp/lang
uage/alignas">alignas</a>, <a href="http://en.cppreference.com/w/cpp/language/al
ignof">alignof</a></td> |
| 85 <td><code>alignof()</code> can be used. <code>alignas()</code> must be used with
care because it does not interact well with export and packing specifiers. If y
our declaration contains any other attributes, use <code>ALIGNAS()</code> from <
code>base/compiler_specific.h</code> instead. <a href="https://codereview.chromi
um.org/2670873002/">Patch where this was discussed</a></td> |
| 86 </tr> |
| 87 |
| 88 <tr> |
81 <td>Angle Bracket Parsing in Templates</td> | 89 <td>Angle Bracket Parsing in Templates</td> |
82 <td><code>>></code> for <code>> ></code>, <code><::</code> for <c
ode>< ::</code></td> | 90 <td><code>>></code> for <code>> ></code>, <code><::</code> for <c
ode>< ::</code></td> |
83 <td>More intuitive parsing of template parameters</td> | 91 <td>More intuitive parsing of template parameters</td> |
84 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack
ets-pitfall-what-is-the-c11-fix">C++ templates angle brackets pitfall</a></td> | 92 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack
ets-pitfall-what-is-the-c11-fix">C++ templates angle brackets pitfall</a></td> |
85 <td>Recommended to increase readability. Approved without discussion.</td> | 93 <td>Recommended to increase readability. Approved without discussion.</td> |
86 </tr> | 94 </tr> |
87 | 95 |
88 <tr> | 96 <tr> |
89 <td>Arrays</td> | 97 <td>Arrays</td> |
90 <td><code>std::array</code></td> | 98 <td><code>std::array</code></td> |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 619 |
612 <tr> | 620 <tr> |
613 <th style='width:240px;'>Feature</th> | 621 <th style='width:240px;'>Feature</th> |
614 <th style='width:240px;'>Snippet</th> | 622 <th style='width:240px;'>Snippet</th> |
615 <th style='width:240px;'>Description</th> | 623 <th style='width:240px;'>Description</th> |
616 <th style='width:240px;'>Documentation Link</th> | 624 <th style='width:240px;'>Documentation Link</th> |
617 <th style='width:240px;'>Notes and Discussion Thread</th> | 625 <th style='width:240px;'>Notes and Discussion Thread</th> |
618 </tr> | 626 </tr> |
619 | 627 |
620 <tr> | 628 <tr> |
| 629 <td>Aligned storage</td> |
| 630 <td><code>std::aligned_storage<10, 128></code></td> |
| 631 <td>Uninitialized storage for objects requiring specific alignment.</td> |
| 632 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligne
d_storage</a></td> |
| 633 <td>MSVC 2017's implementation does not align on boundaries greater than sizeof(
double) = 8 bytes. Use <code>alignas(128) char foo[10];</code> instead. <a href=
"https://codereview.chromium.org/2932053002">Patch where this was discovered</a>
.</td> |
| 634 </tr> |
| 635 |
621 <td>Bind Operations</td> | 636 <td>Bind Operations</td> |
622 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> | 637 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
623 <td>Declares a function object bound to certain arguments</td> | 638 <td>Declares a function object bound to certain arguments</td> |
624 <td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind
</a></td> | 639 <td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind
</a></td> |
625 <td>Use <code>base::Bind</code> instead. Compared to <code>std::bind</code>, <co
de>base::Bind</code> helps prevent lifetime issues by preventing binding of capt
uring lambdas and by forcing callers to declare raw pointers as <code>Unretained
</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoE
j7oIDNuA">Discussion thread</a></td> | 640 <td>Use <code>base::Bind</code> instead. Compared to <code>std::bind</code>, <co
de>base::Bind</code> helps prevent lifetime issues by preventing binding of capt
uring lambdas and by forcing callers to declare raw pointers as <code>Unretained
</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoE
j7oIDNuA">Discussion thread</a></td> |
626 </tr> | 641 </tr> |
627 | 642 |
628 <tr> | 643 <tr> |
629 <td>C Floating-Point Environment</td> | 644 <td>C Floating-Point Environment</td> |
630 <td><code><cfenv></code>, <code><fenv.h></code></td> | 645 <td><code><cfenv></code>, <code><fenv.h></code></td> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 718 |
704 <tr> | 719 <tr> |
705 <th style='width:240px;'>Feature</th> | 720 <th style='width:240px;'>Feature</th> |
706 <th style='width:240px;'>Snippet</th> | 721 <th style='width:240px;'>Snippet</th> |
707 <th style='width:240px;'>Description</th> | 722 <th style='width:240px;'>Description</th> |
708 <th style='width:240px;'>Documentation Link</th> | 723 <th style='width:240px;'>Documentation Link</th> |
709 <th style='width:240px;'>Notes and Discussion Thread</th> | 724 <th style='width:240px;'>Notes and Discussion Thread</th> |
710 </tr> | 725 </tr> |
711 | 726 |
712 <tr> | 727 <tr> |
713 <td>Alignment Features</td> | |
714 <td><code>alignas</code> specifier, <code>alignof</code> operator</td> | |
715 <td>Object alignment</td> | |
716 <td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas specifie
r</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof opera
tor</a></td> | |
717 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co
m/a/chromium.org/forum/#!topic/cxx/rwXN02jzzq0">Discussion thread</a></td> | |
718 </tr> | |
719 | |
720 <tr> | |
721 <td>Attributes</td> | 728 <td>Attributes</td> |
722 <td><code>[[<i>attribute_name</i>]]</code></td> | 729 <td><code>[[<i>attribute_name</i>]]</code></td> |
723 <td>Attaches properties to declarations that specific compiler implementations m
ay use.</td> | 730 <td>Attaches properties to declarations that specific compiler implementations m
ay use.</td> |
724 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz
ed-attributes/">C++11 generalized attributes</a></td> | 731 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz
ed-attributes/">C++11 generalized attributes</a></td> |
725 <td></td> | 732 <td></td> |
726 </tr> | 733 </tr> |
727 | 734 |
728 <tr> | 735 <tr> |
729 <td>UTF-8, UTF-16, UTF-32 String Literals</td> | 736 <td>UTF-8, UTF-16, UTF-32 String Literals</td> |
730 <td><code>u8"<i>string</i>", u"<i>string</i>", U"<i>str
ing</i>"</code></td> | 737 <td><code>u8"<i>string</i>", u"<i>string</i>", U"<i>str
ing</i>"</code></td> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 <tr> | 769 <tr> |
763 <td>Address Retrieval</td> | 770 <td>Address Retrieval</td> |
764 <td><code>std::addressof()</code></td> | 771 <td><code>std::addressof()</code></td> |
765 <td>Obtains the address of an object even with overloaded <code>operator&</c
ode></td> | 772 <td>Obtains the address of an object even with overloaded <code>operator&</c
ode></td> |
766 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</
a></td> | 773 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</
a></td> |
767 <td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguid
e.html#Operator_Overloading">operator overloading</a> is rare and <code>&</c
ode> should suffice in most cases. May be preferable over <code>&</code> for
performing object identity checks.</td> | 774 <td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguid
e.html#Operator_Overloading">operator overloading</a> is rare and <code>&</c
ode> should suffice in most cases. May be preferable over <code>&</code> for
performing object identity checks.</td> |
768 </tr> | 775 </tr> |
769 | 776 |
770 <tr> | 777 <tr> |
771 <td>Aligned Storage</td> | 778 <td>Aligned Storage</td> |
772 <td><code>std::aligned_storage<Size, Align>::type</code><br /> | 779 <td><code>std::alignment_of<T></code>, <code>std::aligned_union<Size, .
..Types></code> <code>std::max_align_t</code></td> |
773 <code>std::alignment_of<T></code>, <code>std::aligned_union<Size, ...Ty
pes></code> <code>std::max_align_t</code></td> | |
774 <td>Declare uninitialized storage having a specified alignment, or determine ali
gnments.</td> | 780 <td>Declare uninitialized storage having a specified alignment, or determine ali
gnments.</td> |
775 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligne
d_storage</a></td> | 781 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_union">std::aligned_
union</a></td> |
776 <td><code>std::aligned_storage</code> and <code>std::aligned_union</code> are di
sallowed in google3 over concerns about compatibility with internal cross-compil
ing toolchains.</td> | 782 <td><code>std::aligned_union</code> is disallowed in google3 over concerns about
compatibility with internal cross-compiling toolchains. <code>std::aligned_stor
age</code> is on the disallowed list due to compatibility concerns.</td> |
777 </tr> | 783 </tr> |
778 | 784 |
779 <tr> | 785 <tr> |
780 <td>Allocator Traits</td> | 786 <td>Allocator Traits</td> |
781 <td><code>std::allocator_traits</code></td> | 787 <td><code>std::allocator_traits</code></td> |
782 <td>Provides an interface for accessing custom allocators</td> | 788 <td>Provides an interface for accessing custom allocators</td> |
783 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">std::allo
cator_traits</a></td> | 789 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">std::allo
cator_traits</a></td> |
784 <td>Usage should be rare.</td> | 790 <td>Usage should be rare.</td> |
785 </tr> | 791 </tr> |
786 | 792 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 <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> | 926 <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> |
921 <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> | 927 <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> |
922 </tr> | 928 </tr> |
923 | 929 |
924 </tbody> | 930 </tbody> |
925 </table> | 931 </table> |
926 | 932 |
927 </div> | 933 </div> |
928 </body> | 934 </body> |
929 </html> | 935 </html> |
OLD | NEW |