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 15 matching lines...) Expand all Loading... | |
26 <p>This document summarizes the features of C++11 (both in the language itself | 26 <p>This document summarizes the features of C++11 (both in the language itself |
27 and in enhancements to the Standard Library) and describes which features are | 27 and in enhancements to the Standard Library) and describes which features are |
28 allowed in Chromium and contains pointers to more detailed information. The | 28 allowed in Chromium and contains pointers to more detailed information. The |
29 Guide applies to Chromium and its subprojects. Subprojects can choose to be | 29 Guide applies to Chromium and its subprojects. Subprojects can choose to be |
30 more restrictive if they need to compile on more toolchains than Chromium.</p> | 30 more restrictive if they need to compile on more toolchains than Chromium.</p> |
31 | 31 |
32 <p>You can propose to make a feature available or to ban a | 32 <p>You can propose to make a feature available or to ban a |
33 feature by sending an email to <a | 33 feature by sending an email to <a |
34 href="https://groups.google.com/a/chromium.org/forum/#!forum/cxx">cxx@chromium.o rg</a>. | 34 href="https://groups.google.com/a/chromium.org/forum/#!forum/cxx">cxx@chromium.o rg</a>. |
35 Ideally include a short blurb on what the feature is, and why you think it | 35 Ideally include a short blurb on what the feature is, and why you think it |
36 should or should not be allowed. Ideally, the list will arrive at some | 36 should or should not be allowed. Ideally, the list will arrive at some |
37 consensus and the wiki page will be updated to mention that consensus. If | 37 consensus and the wiki page will be updated to mention that consensus. If |
38 there's no consensus, <code>src/styleguide/c++/OWNERS</code> get to decide -- | 38 there's no consensus, <code>src/styleguide/c++/OWNERS</code> get to decide -- |
39 for divisive features, we expect the decision to be to not use the feature yet | 39 for divisive features, we expect the decision to be to not use the feature yet |
40 and possibly discuss it again a few months later, when we have more experience | 40 and possibly discuss it again a few months later, when we have more experience |
41 with the language.</p> | 41 with the language.</p> |
42 | 42 |
43 <h2>Table of Contents</h2> | 43 <h2>Table of Contents</h2> |
44 <ol class="toc"> | 44 <ol class="toc"> |
45 <li>Allowed Features<ol> | 45 <li>Allowed Features<ol> |
46 <li><a href="#core-whitelist">Language</a></li> | 46 <li><a href="#core-whitelist">Language</a></li> |
(...skipping 27 matching lines...) Expand all Loading... | |
74 <tr> | 74 <tr> |
75 <td>Aliases</td> | 75 <td>Aliases</td> |
76 <td><code>using <i>new_alias</i> = <i>typename</i></code></td> | 76 <td><code>using <i>new_alias</i> = <i>typename</i></code></td> |
77 <td>Allow parameterized typedefs</td> | 77 <td>Allow parameterized typedefs</td> |
78 <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias (u sing syntax)</a></td> | 78 <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias (u sing syntax)</a></td> |
79 <td>Use instead of typedef, unless the header needs to be compatible with C. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8dOAMz gR4ao">Discussion thread</a></td> | 79 <td>Use instead of typedef, unless the header needs to be compatible with C. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8dOAMz gR4ao">Discussion thread</a></td> |
80 </tr> | 80 </tr> |
81 | 81 |
82 <tr> | 82 <tr> |
83 <td>Angle Bracket Parsing in Templates</td> | 83 <td>Angle Bracket Parsing in Templates</td> |
84 <td><code>>></code> for <code>> ></code> and <br /> | 84 <td><code>>></code> for <code>> ></code>, <code><::</code> for <c ode>< ::</code></td> |
85 <code><::</code> for <code>< ::</code></td> | |
86 <td>More intuitive parsing of template parameters</td> | 85 <td>More intuitive parsing of template parameters</td> |
87 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack ets-pitfall-what-is-the-c11-fix"> | 86 <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> |
88 C++ Templates Angle Brackets Pitfall</a></td> | |
89 <td>Recommended to increase readability. Approved without discussion.</td> | 87 <td>Recommended to increase readability. Approved without discussion.</td> |
90 </tr> | 88 </tr> |
91 | 89 |
92 <tr> | 90 <tr> |
93 <td>Arrays</td> | 91 <td>Arrays</td> |
94 <td><code>std::array</code></td> | 92 <td><code>std::array</code></td> |
95 <td>A fixed-size replacement for built-in arrays, with STL support</td> | 93 <td>A fixed-size replacement for built-in arrays, with STL support</td> |
96 <td><a href="http://en.cppreference.com/w/cpp/container/array"> | 94 <td><a href="http://en.cppreference.com/w/cpp/container/array">std::array</a></t d> |
97 std::array</a></td> | |
98 <td>Useful in performance-critical situations, with small, fixed-size arrays. In most cases, consider std::vector instead. std::vector is cheaper to std::move a nd is more widely used. <a href="https://groups.google.com/a/chromium.org/forum/ #!topic/cxx/pVRQCRWHEU8">Discussion thread</a>.</td> | 95 <td>Useful in performance-critical situations, with small, fixed-size arrays. In most cases, consider std::vector instead. std::vector is cheaper to std::move a nd is more widely used. <a href="https://groups.google.com/a/chromium.org/forum/ #!topic/cxx/pVRQCRWHEU8">Discussion thread</a>.</td> |
99 </tr> | 96 </tr> |
100 | 97 |
101 <tr> | 98 <tr> |
102 <td>Automatic Types</td> | 99 <td>Automatic Types</td> |
103 <td><code>auto</code></td> | 100 <td><code>auto</code></td> |
104 <td>Automatic type deduction</td> | 101 <td>Automatic type deduction</td> |
105 <td><a href="http://en.cppreference.com/w/cpp/language/auto"> | 102 <td><a href="http://en.cppreference.com/w/cpp/language/auto">auto specifier</a>< /td> |
106 auto specifier</a></td> | 103 <td><a href="https://google.github.io/styleguide/cppguide.html#auto">Google Styl e Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chr omium-dev/OQyYSfH9m2M">Discussion thread</a>. <a href="https://groups.google.com /a/chromium.org/forum/#!topic/chromium-dev/5-Bt3BJzAo0">Another discussion threa d</a>.</td> |
107 <td>Use according to the <a | |
108 href="https://google.github.io/styleguide/cppguide.html#auto">Google | |
109 Style Guide on <code>auto</code></a>. <a href="https://groups.google.com/a/chrom ium.org/forum/#!topic/chromium-dev/OQyYSfH9m2M">Discussion thread</a>. <a href=" https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/5-Bt3BJzAo0" >Another discussion thread</a>.</td> | |
110 </tr> | 104 </tr> |
111 | 105 |
112 <tr> | 106 <tr> |
113 <td>Constant Expressions</td> | 107 <td>Constant Expressions</td> |
114 <td><code>constexpr</code></td> | 108 <td><code>constexpr</code></td> |
115 <td>Compile-time constant expressions</td> | 109 <td>Compile-time constant expressions</td> |
116 <td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr spec ifier</a></td> | 110 <td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr spec ifier</a></td> |
117 <td>Prefer to <code>const</code> for variables where possible. Use cautiously on functions. Don't go out of the way to convert existing code. <a href="https://g oogle.github.io/styleguide/cppguide.html#Use_of_constexpr">Google Style Guide</a ></td> | 111 <td>Prefer to <code>const</code> for variables where possible. Use cautiously on functions. Don't go out of the way to convert existing code. <a href="https://g oogle.github.io/styleguide/cppguide.html#Use_of_constexpr">Google Style Guide</a ></td> |
118 </tr> | 112 </tr> |
119 | 113 |
120 <tr> | 114 <tr> |
121 <td>Declared Type Accessor</td> | 115 <td>Declared Type Accessor</td> |
122 <td><code>decltype(<i>expression</i>)</code></td> | 116 <td><code>decltype(<i>expression</i>)</code></td> |
123 <td>Provides a means to determine the type of an expression at compile-time, | 117 <td>Provides a means to determine the type of an expression at compile-time, use ful most often in templates.</td> |
124 useful most often in templates.</td> | 118 <td><a href="http://en.cppreference.com/w/cpp/language/decltype">decltype specif ier</a></td> |
125 <td><a href="http://en.cppreference.com/w/cpp/language/decltype"> | |
126 decltype specifier</a></td> | |
127 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td> | 119 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td> |
128 </tr> | 120 </tr> |
129 | 121 |
130 <tr> | 122 <tr> |
131 <td>Declared Type As Value</td> | |
132 <td><code>declval(<i>expression</i>)</code></td> | |
133 <td>Converts a type to a reference of the type to allow use of members of | |
134 the type without constructing it in templates.</td> | |
135 <td><a href="http://en.cppreference.com/w/cpp/language/declval"> | |
136 decltype specifier</a></td> | |
137 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/d/to pic/cxx/ku6lYjk0-OU/discussion">Discussion thread</a></td> | |
138 </tr> | |
139 | |
140 <tr> | |
141 <td>Default Function Creation</td> | 123 <td>Default Function Creation</td> |
142 <td><code><i>Function</i>(<i>arguments</i>) = default;</code></td> | 124 <td><code><i>Function</i>(<i>arguments</i>) = default;</code></td> |
143 <td>Instructs the compiler to generate a default version | 125 <td>Instructs the compiler to generate a default version of the indicated functi on</td> |
144 of the indicated function</td> | 126 <td><a href="http://stackoverflow.com/questions/823935/whats-the-point-in-defaul ting-functions-in-c11">What's the point in defaulting functions in C++11?</a></t d> |
145 <td><a href="http://stackoverflow.com/questions/823935/whats-the-point-in-defaul ting-functions-in-c11"> | 127 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /qgU4mh_MpGA">Discussion thread</a></td> |
146 What's the point in defaulting functions in C++11?</a></td> | |
147 <td>Doesn't work for move constructors and move assignment operators in MSVC2013 . | |
148 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/qgU 4mh_MpGA">Discussion thread</a></td> | |
149 </tr> | 128 </tr> |
150 | 129 |
151 <tr> | 130 <tr> |
152 <td>Default Function Template Arguments</td> | 131 <td>Default Function Template Arguments</td> |
153 <td><code>template <typename T = <i>type</i>> <br /> | 132 <td><code>template <typename T = <i>type</i>><br /> |
154 <i>type</i> <i>Function</i>(T <i>var</i>) {}</code></td> | 133 <i>type</i> <i>Function</i>(T <i>var</i>) {}</code></td> |
155 <td>Allow function templates, like classes, to have default arguments</td> | 134 <td>Allow function templates, like classes, to have default arguments</td> |
156 <td><a href="http://stackoverflow.com/questions/2447458/default-template-argumen ts-for-function-templates"> | 135 <td><a href="http://stackoverflow.com/questions/2447458/default-template-argumen ts-for-function-templates">Default Template Arguments for Function Templates</a> </td> |
157 Default Template Arguments for Function Templates</a></td> | |
158 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/9KtaAsom e-o">Discussion thread</a></td> | 136 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/9KtaAsom e-o">Discussion thread</a></td> |
159 </tr> | 137 </tr> |
160 | 138 |
161 <tr> | 139 <tr> |
162 <td>Delegated Constructors</td> | 140 <td>Delegated Constructors</td> |
163 <td><code>Class() : Class(0) {}</code><br /> | 141 <td><code>Class() : Class(0) {}<br /> |
164 <code>Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0)</code></td> | 142 Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0) {}</code></td> |
165 <td>Allow overloaded constructors to use common initialization code</td> | 143 <td>Allow overloaded constructors to use common initialization code</td> |
166 <td><a href="https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4b c0-81c5-3956e82276f3/entry/introduction_to_the_c_11_feature_delegating_construct ors?lang=en"> | 144 <td><a href="https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4b c0-81c5-3956e82276f3/entry/introduction_to_the_c_11_feature_delegating_construct ors?lang=en">Introduction to the C++11 feature: delegating constructors</a></td> |
167 Introduction to the C++11 feature: delegating constructors</a></td> | |
168 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /0zVA8Ctx3Xo">Discussion thread</a></td> | 145 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /0zVA8Ctx3Xo">Discussion thread</a></td> |
169 </tr> | 146 </tr> |
170 | 147 |
171 <tr> | 148 <tr> |
172 <td>Enumerated Type Classes and Enum Bases</td> | 149 <td>Enumerated Type Classes and Enum Bases</td> |
173 <td><code>enum class <i>classname</i></code><br> | 150 <td><code>enum class <i>classname</i><br /> |
174 <code>enum class <i>classname</i> : <i>base-type</i></code><br> | 151 enum class <i>classname</i> : <i>base-type</i><br /> |
175 <code>enum <i>enumname</i> : <i>base-type</i></code></td> | 152 enum <i>enumname</i> : <i>base-type</i></code></td> |
176 <td>Provide enums as full classes, with no implicit | 153 <td>Provide enums as full classes, with no implicit conversion to booleans or in tegers. Provide an explicit underlying type for enum classes and regular enums.< /td> |
177 conversion to booleans or integers. Provide an explicit underlying type for | |
178 enum classes and regular enums.</td> | |
179 <td><a href="http://www.stroustrup.com/C++11FAQ.html#enum">enum-class</a></td> | 154 <td><a href="http://www.stroustrup.com/C++11FAQ.html#enum">enum-class</a></td> |
180 <td>Enum classes are still enums and follow enum naming rules | 155 <td>Enum classes are still enums and follow enum naming rules (which means SHOUT Y_CASE in the <a href="http://www.chromium.org/developers/coding-style#Naming">C hromium Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/Q5WmkAImanc">Discussion thread</a></td> |
181 (which means SHOUTY_CASE in the <a href="http://www.chromium.org/developers/codi ng-style#Naming">current style guide</a>). | |
182 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/Q5W mkAImanc">Discussion thread</a></td> | |
183 </tr> | 156 </tr> |
184 | 157 |
185 <tr> | 158 <tr> |
186 <td>Explicit Conversion Operators</td> | 159 <td>Explicit Conversion Operators</td> |
187 <td><code>explicit operator <i>type</i>() { | 160 <td><code>explicit operator <i>type</i>() { ... }</code></td> |
188 <br /> // code<br /> }</code></td> | |
189 <td>Allows conversion operators that cannot be implicitly invoked</td> | 161 <td>Allows conversion operators that cannot be implicitly invoked</td> |
190 <td><a href="http://en.cppreference.com/w/cpp/language/explicit"> | 162 <td><a href="http://en.cppreference.com/w/cpp/language/explicit">explicit specif ier</a></td> |
191 explicit specifier</a></td> | |
192 <td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromi um.org/d/msg/chromium-dev/zGF1SrQ-1HQ/BAiC12vwPeEJ">Discussion thread</a></td> | 163 <td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromi um.org/d/msg/chromium-dev/zGF1SrQ-1HQ/BAiC12vwPeEJ">Discussion thread</a></td> |
193 </tr> | 164 </tr> |
194 | 165 |
195 <tr> | 166 <tr> |
196 <td>Final Specifier</td> | 167 <td>Final Specifier</td> |
197 <td><code>final</code></td> | 168 <td><code>final</code></td> |
198 <td> Indicates that a class or function is final and cannot be overridden</td> | 169 <td> Indicates that a class or function is final and cannot be overridden</td> |
199 <td><a href="http://en.cppreference.com/w/cpp/language/final">final Language Ref erence</a></td> | 170 <td><a href="http://en.cppreference.com/w/cpp/language/final">final Language Ref erence</a></td> |
200 <td>Recommended for new code. Existing uses of the <code>FINAL</code> macro will be <a href="https://crbug.com/417463">replaced throughout the codebase</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzi zN0zo">Discussion thread</a></td> | 171 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
201 </tr> | 172 </tr> |
202 | 173 |
203 <tr> | 174 <tr> |
204 <td>Function Suppression</td> | 175 <td>Function Suppression</td> |
205 <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> | 176 <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> |
206 <td>Suppresses the implementation of a function, especially a | 177 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> |
207 synthetic function such as a copy constructor</td> | |
208 <td>TODO: documentation link</td> | 178 <td>TODO: documentation link</td> |
209 <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> |
210 </tr> | 180 </tr> |
211 | 181 |
212 <tr> | 182 <tr> |
213 <td>Lambda Expressions</td> | 183 <td>Lambda Expressions</td> |
214 <td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</cod e></td> | 184 <td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</cod e></td> |
215 <td>Anonymous functions</td> | 185 <td>Anonymous functions</td> |
216 <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> |
217 <td>Do not bind or store lambdas; use <code>base::Bind</code> and | 187 <td>Do not bind or store lambdas; use <code>base::Bind</code> and <code>base::Ca llback</code> instead, because they offer protection against a large class of ob ject lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&am p;]</code> – <a href="https://google.github.io/styleguide/cppguide.html#La mbda_expressions">Google Style Guide</a>). Lambdas are typically useful as a par ameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.or g/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a></td> |
218 <code>base::Callback</code> instead, because they offer protection against a | |
219 large class of object lifetime mistakes. Don't use default captures | |
220 (<code>[=]</code>, <code>[&]</code> – <a | |
221 href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Go ogle Style Guide</a>). | |
222 Lambdas are typically useful as a parameter to methods or | |
223 functions that will use them immediately, such as those in | |
224 <code><algorithm></code>. <a | |
225 href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9Un nxBnciQ">Discussion | |
226 thread</a></td> | |
227 </tr> | 188 </tr> |
228 | 189 |
229 <tr> | 190 <tr> |
230 <td>Local Types as Template Arguments</td> | 191 <td>Local Types as Template Arguments</td> |
231 <td></td> | 192 <td></td> |
232 <td>Allows local and unnamed types as template arguments</td> | 193 <td>Allows local and unnamed types as template arguments</td> |
233 <td><a href="http://stackoverflow.com/questions/742607/using-local-classes-with- stl-algorithms"> | 194 <td><a href="http://stackoverflow.com/questions/742607/using-local-classes-with- stl-algorithms">Local types, types without linkage and unnamed types as template arguments</a></td> |
234 Local types, types without linkage and unnamed types as template arguments</a></ td> | |
235 <td>Usage should be rare. Approved without discussion.</td> | 195 <td>Usage should be rare. Approved without discussion.</td> |
236 </tr> | 196 </tr> |
237 | 197 |
238 <tr> | 198 <tr> |
239 <td>Non-Static Class Member Initializers</td> | 199 <td>Non-Static Class Member Initializers</td> |
240 <td> | 200 <td><code>class C {<br /> |
241 <code> | 201 <i>type</i> <i>var</i> = <i>value</i>;<br /> |
242 class C {<br /> | 202 C() // copy-initializes <i>var</i></code> |
243 <i>type</i> <i>var</i> = <i>value</i>;<br/> | |
244 C() // copy-initializes <i>var</i><br/> | |
245 </code> | |
246 <td>Allows non-static class members to be initialized at their definitions (outs ide constructors)</td> | 203 <td>Allows non-static class members to be initialized at their definitions (outs ide constructors)</td> |
247 <td><a href="http://en.cppreference.com/w/cpp/language/data_members"> | 204 <td><a href="http://en.cppreference.com/w/cpp/language/data_members">Non-static data members</a></td> |
248 Non-static data members</a></td> | 205 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /zqB-DySA4V0">Discussion thread</a></td> |
249 <td> | |
250 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB -DySA4V0">Discussion thread</a> | |
251 </td> | |
252 </tr> | 206 </tr> |
253 | 207 |
254 <tr> | 208 <tr> |
255 <td>Null Pointer Constant</td> | 209 <td>Null Pointer Constant</td> |
256 <td><code>nullptr</code></td> | 210 <td><code>nullptr</code></td> |
257 <td>Declares a type-safe null pointer</td> | 211 <td>Declares a type-safe null pointer</td> |
258 <td><a href="http://en.cppreference.com/w/cpp/language/nullptr"> | 212 <td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr</a></td> |
259 nullptr</a></td> | 213 <td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://groups.goo gle.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread </a>. <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/N ULL">Google Style Guide</a>. <code>std::nullptr_t</code> can be used too.</td> |
260 <td>Recommended for new code. | |
261 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mi jeJHzxLg">Discussion thread</a>. | |
262 <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/NULL">G oogle Style Guide</a>. | |
263 <code>std::nullptr_t</code> can be used too. | |
264 </td> | |
265 </tr> | 214 </tr> |
266 | 215 |
267 <tr> | 216 <tr> |
268 <td>Override Specifier</td> | 217 <td>Override Specifier</td> |
269 <td><code>override</code></td> | 218 <td><code>override</code></td> |
270 <td>Indicates that a class or function overrides a base implementation</td> | 219 <td>Indicates that a class or function overrides a base implementation</td> |
271 <td><a href="http://en.cppreference.com/w/cpp/language/override">override Langua ge Reference</a></td> | 220 <td><a href="http://en.cppreference.com/w/cpp/language/override">override Langua ge Reference</a></td> |
272 <td>Recommended for new code. Existing uses of the <code>OVERRIDE</code> macro w ill be <a href="https://crbug.com/417463">replaced throughout the codebase</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTN ZzizN0zo">Discussion</a></td> | 221 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
273 </tr> | 222 </tr> |
274 | 223 |
275 <tr> | 224 <tr> |
276 <td>Range-Based For Loops</td> | 225 <td>Range-Based For Loops</td> |
277 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> | 226 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> |
278 <td>Facilitates a more concise syntax for iterating over the elements | 227 <td>Facilitates a more concise syntax for iterating over the elements of a conta iner (or a range of iterators) in a <code>for</code> loop</td> |
279 of a container (or a range of iterators) in a <code>for</code> loop</td> | 228 <td><a href="http://en.cppreference.com/w/cpp/language/range-for">Range-based fo r loop</a></td> |
280 <td><a href="http://en.cppreference.com/w/cpp/language/range-for"> | |
281 Range-based for loop</a></td> | |
282 <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> | 229 <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> |
283 </tr> | 230 </tr> |
284 | 231 |
285 <tr> | 232 <tr> |
286 <td>Rvalue References</td> | 233 <td>Rvalue References</td> |
287 <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)</cod e><br/><br/> | 234 <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)<br/> <br/> |
288 <code>template <typename T><br/>void Function(T&& t) { ... }</code></t d> | 235 template <typename T><br/>void Function(T&& t) { ... }</code></td> |
289 <td>Reference that only binds to a temporary object</td> | 236 <td>Reference that only binds to a temporary object</td> |
290 <td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_referen ces"> | 237 <td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_referen ces">Rvalue references</a></td> |
291 Rvalue references</a></td> | 238 <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. Most classes should n ot be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN (or DI SALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND if needed) in most cases. <a href="htt ps://groups.google.com/a/chromium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussi on thread</a>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/Q52 6tkruXpM">Another discussion thread</a>.</td> |
292 <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>. | |
293 <br/><br/> | |
294 MSVC 2013 has some known bugs with rvalue references: | |
295 <ul> | |
296 <li>Exported classes generate copy constructors even if they are not used, which tries to use copy constructors on members. Use DISALLOW_COPY_AND_ASSIGN on the exported class to resolve it.</li> | |
297 <li>The compiler chooses a T::(T&) constructor before T::(T&&). However copy con structors should be written as T::T(const T&) and these are prioritized correctl y.</li> | |
298 <li>The compiler does not create default move constructors, either implicitly or with the =default keyword. You must provide such constructors explicitly to cre ate them.</li> | |
299 </ul> | |
300 </td> | |
301 </tr> | 239 </tr> |
302 | 240 |
303 <tr> | 241 <tr> |
304 <td>Standard Integers</td> | 242 <td>Standard Integers</td> |
305 <td>Typedefs within <code><stdint.h></code> | 243 <td>Typedefs within <code><stdint.h></code> and <code><inttypes></co de></td> |
306 and <code><inttypes></code></td> | |
307 <td>Provides fixed-size integers independent of platforms</td> | 244 <td>Provides fixed-size integers independent of platforms</td> |
308 <td><a href="http://www.cplusplus.com/reference/cstdint/"> | 245 <td><a href="http://www.cplusplus.com/reference/cstdint/"><stdint.h> (cstd int)</a></td> |
309 <stdint.h> (cstdint)</a></td> | |
310 <td>Already in common use in the codebase. Approved without discussion.</td> | 246 <td>Already in common use in the codebase. Approved without discussion.</td> |
311 </tr> | 247 </tr> |
312 | 248 |
313 <tr> | 249 <tr> |
314 <td>Static Assertions</td> | 250 <td>Static Assertions</td> |
315 <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td> | 251 <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td> |
316 <td>Tests compile-time conditions</td> | 252 <td>Tests compile-time conditions</td> |
317 <td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Ass ertion</a></td> | 253 <td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Ass ertion</a></td> |
318 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /POISBQEhGzU">Discussion thread</a></td> | 254 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /POISBQEhGzU">Discussion thread</a></td> |
319 </tr> | 255 </tr> |
320 | 256 |
321 <tr> | 257 <tr> |
322 <td>Variadic Macros</td> | 258 <td>Variadic Macros</td> |
323 <td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code> </td> | 259 <td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code> </td> |
324 <td>Allows macros that accept a variable number of arguments</td> | 260 <td>Allows macros that accept a variable number of arguments</td> |
325 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons tandard"> | 261 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons tandard">Are Variadic macros nonstandard?</a></td> |
326 Are Variadic macros nonstandard?</a></td> | |
327 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> | 262 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> |
328 </tr> | 263 </tr> |
329 | 264 |
330 <tr> | 265 <tr> |
331 <td>Variadic Templates</td> | 266 <td>Variadic Templates</td> |
332 <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> | 267 <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> |
333 <td>Allows templates that accept a variable number of arguments</td> | 268 <td>Allows templates that accept a variable number of arguments</td> |
334 <td><a href="http://en.cppreference.com/w/cpp/language/parameter_pack"> | 269 <td><a href="http://en.cppreference.com/w/cpp/language/parameter_pack">Parameter pack</a></td> |
335 Parameter pack</a></td> | |
336 <td>Usage should be rare. Use instead of .pump files. <a href="https://groups.go ogle.com/a/chromium.org/forum/#!topic/chromium-dev/6ItymeMXpMc">Discussion threa d</a></td> | 270 <td>Usage should be rare. Use instead of .pump files. <a href="https://groups.go ogle.com/a/chromium.org/forum/#!topic/chromium-dev/6ItymeMXpMc">Discussion threa d</a></td> |
337 </tr> | 271 </tr> |
338 | 272 |
339 </tbody> | 273 </tbody> |
340 </table> | 274 </table> |
341 | 275 |
342 <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Feature s</h2> | 276 <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Feature s</h2> |
343 | 277 |
344 <p>The following library features are currently allowed.</p> | 278 <p>The following library features are currently allowed.</p> |
345 | 279 |
(...skipping 21 matching lines...) Expand all Loading... | |
367 <td>All C++11 features in <code><algorithm></code>:<br/> | 301 <td>All C++11 features in <code><algorithm></code>:<br/> |
368 <code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/> | 302 <code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/> |
369 <code>find_if_not</code><br/> | 303 <code>find_if_not</code><br/> |
370 <code>copy_if</code>, <code>copy_n</code><br/> | 304 <code>copy_if</code>, <code>copy_n</code><br/> |
371 <code>move</code>, <code>move_backward</code> (see note)<br/> | 305 <code>move</code>, <code>move_backward</code> (see note)<br/> |
372 <code>shuffle</code><br/> | 306 <code>shuffle</code><br/> |
373 <code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point< /code><br/> | 307 <code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point< /code><br/> |
374 <code>is_sorted</code>, <code>is_sorted_until</code><br/> | 308 <code>is_sorted</code>, <code>is_sorted_until</code><br/> |
375 <code>is_heap</code>, <code>is_heap_until</code><br/> | 309 <code>is_heap</code>, <code>is_heap_until</code><br/> |
376 <code>minmax</code>, <code>minmax_element</code><br/> | 310 <code>minmax</code>, <code>minmax_element</code><br/> |
377 <code>is_permutation<br/> | 311 <code>is_permutation<br/></td> |
378 </td> | |
379 <td>Safe and performant implementations of common algorithms</td> | 312 <td>Safe and performant implementations of common algorithms</td> |
380 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code><algori thm></code></a></td> | 313 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code><algori thm></code></a></td> |
381 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/> | 314 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/> Note that <algorithm> contains a range-bas ed <code>move</code> method. This is allowed, but because people may confuse it with the single-arg <code>std::move</code>, there is often a way to write code w ithout it that is more readable. <a href='https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td> |
382 Note that <algorithm> contains a range-based <code>move</code> method. Th is is allowed, but because people may confuse it with the single-arg <code>std:: move</code>, there is often a way to write code without it that is more readable . <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZv Q8'>Discussion thread</a></td> | |
383 </tr> | 315 </tr> |
384 | 316 |
385 <tr> | 317 <tr> |
386 <td>Begin and End Non-Member Functions</td> | 318 <td>Begin and End Non-Member Functions</td> |
387 <td><code>std::begin()</code> and <code>std::end()</code></td> | 319 <td><code>std::begin()</code>, <code>std::end()</code></td> |
388 <td>Allows use of free functions on any container, including fixed-size arrays</ td> | 320 <td>Allows use of free functions on any container, including fixed-size arrays</ td> |
389 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin">std::begin</a> and <a href="http://en.cppreference.com/w/cpp/iterator/end">std::end</a></td> | 321 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin">std::begin</a>, <a href="http://en.cppreference.com/w/cpp/iterator/end">std::end</a></td> |
390 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a><br> | 322 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a><br> Note that non- member <code>cbegin()</code> and <code>cend()</code> are not available until C++ 14.</td> |
danakj
2016/04/14 21:22:25
<br/>?
Line breaking after a br makes sense in th
Peter Kasting
2016/04/14 21:32:43
I'll reword this a bit to put the "Discussion thre
| |
391 Note that non-member <code>cbegin()</code> and <code>cend()</code> are not avail able until C++14.</td> | |
392 </tr> | 323 </tr> |
393 | 324 |
394 <tr> | 325 <tr> |
395 <td>Conditional Type Selection</td> | 326 <td>Conditional Type Selection</td> |
396 <td><code>std::enable_if</code> and <code>std::conditional</code></td> | 327 <td><code>std::enable_if</code>, <code>std::conditional</code></td> |
397 <td>Enables compile-time conditional type selection</td> | 328 <td>Enables compile-time conditional type selection</td> |
398 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a > and <a href="http://en.cppreference.com/w/cpp/types/conditional">conditional</ a></td> | 329 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a >, <a href="http://en.cppreference.com/w/cpp/types/conditional">conditional</a>< /td> |
399 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td> | 330 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td> |
400 </tr> | 331 </tr> |
401 | 332 |
402 <tr> | 333 <tr> |
403 <td>Constant Iterator Methods on Containers</td> | 334 <td>Constant Iterator Methods on Containers</td> |
404 <td><code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></td> | 335 <td>E.g. <code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></t d> |
405 <td>Allows more widespread use of <code>const_iterator</code></td> | 336 <td>Allows more widespread use of <code>const_iterator</code></td> |
406 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/begin">std:: vector::cbegin<a> and <a href="http://en.cppreference.com/w/cpp/container/vector /end">std::vector::cend<a></td> | 337 <td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vecto r::cbegin</a>, <a href="http://en.cppreference.com/w/cpp/container/vector/end">s td::vector::cend<a></td> |
407 <td>Applies to all containers, not just <code>vector</code>. Consider using <co de>const_iterator</code> over <code>iterator</code> where possible for the same reason as using <code>const</code> variables and functions where possible; see E ffective Modern C++ item 13 for motivation. <a href="https://groups.google.com/ a/chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discussion thread</a></td> | 338 <td>Applies to all containers, not just <code>vector</code>. Consider using <cod e>const_iterator</code> over <code>iterator</code> where possible for the same r eason as using <code>const</code> variables and functions where possible; see Ef fective Modern C++ item 13 for motivation. <a href="https://groups.google.com/a/ chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discussion thread</a></td> |
408 </tr> | 339 </tr> |
409 | 340 |
410 <tr> | 341 <tr> |
411 <td>Containers containing movable types</td> | 342 <td>Containers containing movable types</td> |
412 <td><code>vector<scoped_ptr></code></td> | 343 <td><code>vector<scoped_ptr></code></td> |
413 <td>Enables containers that contain move-only types like <code>scoped_ptr</code> </td> | 344 <td>Enables containers that contain move-only types like <code>scoped_ptr</code> </td> |
414 <td>TODO</td> | 345 <td>TODO</td> |
415 <td>Allows getting rid of <a href="http://crbug.com/554289">ScopedVector</a></td > | 346 <td>Prefer over <a href="http://crbug.com/554289">ScopedVector</a>.</td> |
347 </tr> | |
348 | |
349 <tr> | |
350 <td>Declared Type As Value</td> | |
351 <td><code>std::declval<<i>class</i>>()</code></td> | |
352 <td>Converts a type to a reference of the type to allow use of members of the ty pe without constructing it in templates.</td> | |
353 <td><a href="http://en.cppreference.com/w/cpp/utility/declval">std::declval</a>< /td> | |
354 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/d/to pic/cxx/ku6lYjk0-OU/discussion">Discussion thread</a></td> | |
416 </tr> | 355 </tr> |
417 | 356 |
418 <tr> | 357 <tr> |
419 <td>Emplacement methods for containers</td> | 358 <td>Emplacement methods for containers</td> |
420 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td> | 359 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td> |
421 <td>Constructs elements directly within a container without a copy or a move. L ess verbose than <code>push_back()</code> due to not naming the type being const ructed.</td> | 360 <td>Constructs elements directly within a container without a copy or a move. Le ss verbose than <code>push_back()</code> due to not naming the type being constr ucted.</td> |
422 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back ">std::vector::emplace_back</a></td> | 361 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back ">std::vector::emplace_back</a></td> |
423 <td><code>std::map::emplace()</code> is not yet available on all libstdc++ versi ons we support. When using emplacement for performance reasons, your type shoul d probably be movable (since e.g. a vector of it might be resized); given a mova ble type, then, consider whether you really need to avoid the move done by <code >push_back()</code>. For readability concerns, treat like <code>auto</code>; so metimes the brevity over <code>push_back()</code> is a win, sometimes a loss. < a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/m3cblzEta7A"> Discussion thread</a></td> | 362 <td><code>std::map::emplace()</code> is not yet available on all libstdc++ versi ons we support. When using emplacement for performance reasons, your type should probably be movable (since e.g. a vector of it might be resized); given a movab le type, then, consider whether you really need to avoid the move done by <code> push_back()</code>. For readability concerns, treat like <code>auto</code>; some times the brevity over <code>push_back()</code> is a win, sometimes a loss. <a h ref="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/m3cblzEta7A">Dis cussion thread</a></td> |
424 </tr> | 363 </tr> |
425 | 364 |
426 <tr> | 365 <tr> |
427 <td>Forwarding references</td> | 366 <td>Forwarding references</td> |
428 <td><code>std::forward()</code></td> | 367 <td><code>std::forward()</code></td> |
429 <td>Perfectly forwards arguments (including rvalues)</td> | 368 <td>Perfectly forwards arguments (including rvalues)</td> |
430 <td><a href="http://en.cppreference.com/w/cpp/utility/forward"><code>std::forwar d</code></a></td> | 369 <td><a href="http://en.cppreference.com/w/cpp/utility/forward"><code>std::forwar d</code></a></td> |
431 <td> | 370 <td>Allowed, though usage should be rare (primarily for forwarding constructor a rguments, or in carefully reviewed library code). <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/-O7euklhSxs/discussion">Discussion thread</a> |
432 Allowed, though usage should be rare (primarily for forwarding constructor arg uments, or in carefully reviewed library code). | |
433 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/-O7euklhSxs/disc ussion">Discussion thread</a> | |
434 </td> | 371 </td> |
435 </tr> | 372 </tr> |
436 | 373 |
437 <tr> | 374 <tr> |
438 <td>Lexicographical struct comparison</td> | 375 <td>Lexicographical struct comparison</td> |
439 <td><code>tie(a, b, c) <<br> tie(rhs.a, rhs.b, rhs.c)</code></td> | 376 <td><code>tie(a, b, c) <<br> tie(rhs.a, rhs.b, rhs.c)</code></td> |
440 <td>Idiom for <code>operator<</code> implementation</td> | 377 <td>Idiom for <code>operator<</code> implementation</td> |
441 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d> | 378 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple/tie">std::tie</a></t d> |
442 <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> | 379 <td>General use of <code>std::tie</code> for unpacking or multiple assignments i s still not allowed. <a href="https://groups.google.com/a/chromium.org/d/topic/c xx/3DZ64dIMRTY/discussion">Discussion thread</a></td> |
443 </tr> | 380 </tr> |
444 | 381 |
445 <tr> | 382 <tr> |
446 <td>Math functions</td> | 383 <td>Math functions</td> |
447 <td>All C++11 features in <code><cmath></code>, e.g.:<br/> | 384 <td>All C++11 features in <code><cmath></code>, e.g.:<br/> |
448 <code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/> | 385 <code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/> |
449 <code>float_t</code>, <code>double_t</code><br/> | 386 <code>float_t</code>, <code>double_t</code><br/> |
450 <code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/ > | 387 <code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/ > |
451 <code>isinf</code>, <code>isnan</code><br/></td> | 388 <code>isinf</code>, <code>isnan</code><br/></td> |
452 <td>Useful for math-related code</td> | 389 <td>Useful for math-related code</td> |
(...skipping 12 matching lines...) Expand all Loading... | |
465 <tr> | 402 <tr> |
466 <td>Move Semantics</td> | 403 <td>Move Semantics</td> |
467 <td><code>std::move()</code></td> | 404 <td><code>std::move()</code></td> |
468 <td>Facilitates efficient move operations</td> | 405 <td>Facilitates efficient move operations</td> |
469 <td><a href="http://en.cppreference.com/w/cpp/utility/move"><code>std::move</cod e> reference</a></td> | 406 <td><a href="http://en.cppreference.com/w/cpp/utility/move"><code>std::move</cod e> reference</a></td> |
470 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td> | 407 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td> |
471 </tr> | 408 </tr> |
472 | 409 |
473 <tr> | 410 <tr> |
474 <td>String Direct Reference Functions</td> | 411 <td>String Direct Reference Functions</td> |
475 <td><code>std::string::front()</code> and <code>std::string::back()</code></td> | 412 <td><code>std::string::front()</code>, <code>std::string::back()</code></td> |
476 <td>Returns a reference to the front or back of a string</td> | 413 <td>Returns a reference to the front or back of a string</td> |
477 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front"> | 414 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front">std::ba sic_string::front</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_st ring/back">std::basic_string::back</a></td> |
478 std::basic_string::front</a> and | |
479 <a href="http://en.cppreference.com/w/cpp/string/basic_string/back"> | |
480 std::basic_string::back</a></td> | |
481 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAY CV4">Discussion thread</a></td> | 415 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAY CV4">Discussion thread</a></td> |
482 </tr> | 416 </tr> |
483 | 417 |
484 <tr> | 418 <tr> |
485 <td>Type Traits</td> | 419 <td>Type Traits</td> |
486 <td>All C++11 features in <code><type_traits></code> except for aligned st orage (see separate item), e.g.:<br/> | 420 <td>All C++11 features in <code><type_traits></code> except for aligned st orage (see separate item), e.g.:<br/> |
487 <code>integral_constant</code><br/> | 421 <code>integral_constant</code><br/> |
488 <code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scala r</code><br/> | 422 <code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scala r</code><br/> |
489 <code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/> | 423 <code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/> |
490 <code>is_default_constructible</code>, <code>is_move_constructible</code>, <code >is_copy_assignable</code><br/> | 424 <code>is_default_constructible</code>, <code>is_move_constructible</code>, <code >is_copy_assignable</code><br/> |
491 <code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/> | 425 <code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></t d> |
492 </td> | |
493 <td>Allows compile-time inspection of the properties of types</td> | 426 <td>Allows compile-time inspection of the properties of types</td> |
494 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"><type_trait s></a></td> | 427 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"><type_trait s></a></td> |
495 <td>Note that not all type traits are available on all platforms (eg std::underl ying_type doesn't work in libstdc++4.6). Use judiciously. <a href='https://group s.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a> </td> | 428 <td>Note that not all type traits are available on all platforms (e.g. <code>std ::underlying_type</code> doesn't work in libstdc++4.6). Use judiciously. <a href ='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discus sion thread</a></td> |
496 </tr> | 429 </tr> |
497 | 430 |
498 <tr> | 431 <tr> |
499 <td>Tuples</td> | 432 <td>Tuples</td> |
500 <td><code>std::tuple</code></td> | 433 <td><code>std::tuple</code></td> |
501 <td>A fixed-size ordered collection of values of mixed types</td> | 434 <td>A fixed-size ordered collection of values of mixed types</td> |
502 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a></td> | 435 <td><a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a></td> |
503 <td><a href="https://crbug.com/554987">Tracking bug</a> to plan moving from <cod e>base::Tuple</code> to <code>std::tuple</code>. See also <code>std::tie</code>. | 436 <td><a href="https://crbug.com/554987">Tracking bug</a> to plan moving from <cod e>base::Tuple</code> to <code>std::tuple</code>. See also <code>std::tie</code>. <code>base::Tuple</code> is now an alias for <code>std::tuple</code>.</td> |
danakj
2016/04/14 21:22:25
You could just say "Prefer over base::Tuple" and l
Peter Kasting
2016/04/14 21:32:43
Good idea.
| |
504 <code>base::Tuple</code> is now an alias for <code>std::tuple</code>. In class t emplate specializations, use <code>std::tuple</code> instead of <code>base::Tupl e</code> to work around a MSVS2013 internal compiler error (Error code: C1001). | |
505 </td> | |
506 </tr> | 437 </tr> |
507 | 438 |
508 <tr> | 439 <tr> |
509 <td>Unordered Associative Containers</td> | 440 <td>Unordered Associative Containers</td> |
510 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, | 441 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, <code>std: :unordered_multiset</code>, <code>std::unordered_multimap</code></td> |
511 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></ td> | |
512 <td>Allows efficient containers of key/value pairs</td> | 442 <td>Allows efficient containers of key/value pairs</td> |
513 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a> | 443 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a>, <a href="http://en.cppreference.com/w/cpp/container/unordered_set ">std::unordered_set</a></td> |
514 and <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unor dered_set</a> | 444 <td>Per the <a href="https://google.github.io/styleguide/cppguide.html#std_hash" >Google Style Guide</a>, specify custom hashers instead of specializing <code>st d::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td> |
515 </td> | |
516 <td>Per the <a href="https://google.github.io/styleguide/cppguide.html#std_hash" >Google style guide</a>, specify custom hashers instead of specializing <code>st d::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td> | |
517 </tr> | 445 </tr> |
518 | 446 |
519 <tr> | 447 <tr> |
520 <td>Unique Pointers</td> | 448 <td>Unique Pointers</td> |
521 <td><code>std::unique_ptr<<i>type</i>></code></td> | 449 <td><code>std::unique_ptr<<i>type</i>></code></td> |
522 <td>A smart pointer with sole ownership of the owned object.</td> | 450 <td>A smart pointer with sole ownership of the owned object.</td> |
523 <td><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">std::unique_ptr </a></td> | 451 <td><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">std::unique_ptr </a></td> |
524 <td>Google style guide: <a href="https://google.github.io/styleguide/cppguide.ht ml#Ownership_and_Smart_Pointers">Ownership and Smart Pointers</a>. <a href="http s://groups.google.com/a/chromium.org/d/msg/cxx/aT2wsBLKvzI/oZuZ718oAwAJ">Discuss ion thread</a>. Use in all newly written code. scoped_ptr is a <a href="https:// groups.google.com/a/chromium.org/d/msg/chromium-dev/roY78iTblYc/bb8nYsxfCgAJ">ty pedef for std::unique_ptr</a> and is going away shortly.</td> | 452 <td>Use in all newly written code. <a href="https://google.github.io/styleguide/ cppguide.html#Ownership_and_Smart_Pointers">Google Style Guide</a>. <a href="htt ps://groups.google.com/a/chromium.org/d/msg/cxx/aT2wsBLKvzI/oZuZ718oAwAJ">Discus sion thread</a>. <code>scoped_ptr</code> is a <a href="https://groups.google.com /a/chromium.org/d/msg/chromium-dev/roY78iTblYc/bb8nYsxfCgAJ">typedef for <code>s td::unique_ptr</code></a> and is going away shortly.</td> |
525 </tr> | 453 </tr> |
526 | 454 |
527 </tbody> | 455 </tbody> |
528 </table> | 456 </table> |
529 | 457 |
530 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> | 458 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> |
531 | 459 |
532 <p>This section lists features that are not allowed to be used yet. | 460 <p>This section lists features that are not allowed to be used yet. |
533 | 461 |
534 <h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3 > | 462 <h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3 > |
535 | 463 |
536 <p>This section lists C++11 features that are not allowed in the Chromium | 464 <p>This section lists C++11 features that are not allowed in the Chromium |
537 codebase. | 465 codebase. |
538 </p> | 466 </p> |
539 | 467 |
540 <table id="banned_list" class="unlined striped"> | 468 <table id="banned_list" class="unlined striped"> |
541 <tbody> | 469 <tbody> |
542 | 470 |
543 <tr> | 471 <tr> |
544 <th style='width:240px;'>Feature or Library</th> | 472 <th style='width:240px;'>Feature or Library</th> |
545 <th style='width:240px;'>Snippet</th> | 473 <th style='width:240px;'>Snippet</th> |
546 <th style='width:240px;'>Description</th> | 474 <th style='width:240px;'>Description</th> |
547 <th style='width:240px;'>Documentation Link</th> | 475 <th style='width:240px;'>Documentation Link</th> |
548 <th style='width:240px;'>Notes</th> | 476 <th style='width:240px;'>Notes</th> |
549 </tr> | 477 </tr> |
550 | 478 |
551 <tr> | 479 <tr> |
552 <td>Alignment Features</td> | 480 <td>Alignment Features</td> |
553 <td> | 481 <td><code>alignas</code> specifier, <code>alignof</code> operator</td> |
554 <code>alignas</code> specifier, | |
555 <code>alignof</code> operator | |
556 <td>Object alignment</td> | 482 <td>Object alignment</td> |
557 <td> | 483 <td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof</a></td> |
558 <a href="http://en.cppreference.com/w/cpp/language/alignas">alignas</a>, | 484 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/d/msg/cxx/rwXN02jzzq0/CpUc1ZzMBQAJ">Discussion thread</a></td> |
559 <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof</a> | |
560 </td> | |
561 <td> | |
562 <a href="https://codereview.chromium.org/1497963002/">Doesn't work in | |
563 MSVS2013</a>. | |
564 <a href="https://msdn.microsoft.com/en-us/library/dn956970.aspx">MSVS2015 | |
565 supports them</a>; reevaluate after MSVS2015 is available. | |
566 <a href="https://groups.google.com/a/chromium.org/d/msg/cxx/rwXN02jzzq0/CpUc1ZzM BQAJ">Discussion thread</a> | |
567 </td> | |
568 </tr> | 485 </tr> |
569 | 486 |
570 <tr> | 487 <tr> |
571 <td>Function Local Variable</td> | 488 <td>Function Local Variable</td> |
572 <td><code>__func__</code></td> | 489 <td><code>__func__</code></td> |
573 <td>Provides a local variable of the name of the enclosing | 490 <td>Provides a local variable of the name of the enclosing function for logging purposes</td> |
574 function for logging purposes</td> | 491 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum= 338">The __func__ Predeclared Identifier is Coming to C++</a></td> |
575 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum= 338"> | 492 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discussion thread</a></ td> |
576 The __func__ Predeclared Identifier is Coming to C++</a></td> | |
577 <td>Doesn't work in MSVS2013. Reevaluate once it does. <a href="https://groups.g oogle.com/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discussion thre ad</a></td> | |
578 </tr> | 493 </tr> |
579 | 494 |
580 <tr> | 495 <tr> |
581 <td>Inherited Constructors</td> | 496 <td>Inherited Constructors</td> |
582 <td><code>class Derived : Base { | 497 <td><code>class Derived : Base {<br /> |
583 <br /> using Base::Base; | 498 using Base::Base;<br /> |
584 <br />};</code></td> | 499 };</code></td> |
585 <td>Allow derived classes to inherit constructors from base classes</td> | 500 <td>Allow derived classes to inherit constructors from base classes</td> |
586 <td><a href="http://en.cppreference.com/w/cpp/language/using_declaration">Using- declaration</a></td> | 501 <td><a href="http://en.cppreference.com/w/cpp/language/using_declaration">Using- declaration</a></td> |
587 <td>Doesn't work in MSVS2013. Reevaluate once it does. <a | 502 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/d/msg/chromium-dev/BULzgIKZ-Ao/PLO7_GoVNvYJ">Discussion thread< /a></td> |
588 href="https://groups.google.com/a/chromium.org/d/msg/chromium-dev/BULzgIKZ-Ao/PL O7_GoVNvYJ">Discussion thread</a></td> | |
589 </tr> | 503 </tr> |
590 | 504 |
591 <tr> | 505 <tr> |
592 <td><code>long long</code> Type</td> | 506 <td><code>long long</code> Type</td> |
593 <td><code>long long <i>var</i>= <i>value</i>;</code></td> | 507 <td><code>long long <i>var</i>= <i>value</i>;</code></td> |
594 <td>An integer of at least 64 bits</td> | 508 <td>An integer of at least 64 bits</td> |
595 <td><a href="http://en.cppreference.com/w/cpp/language/types"> | 509 <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types< /a></td> |
596 Fundamental types</a></td> | 510 <td>Use a stdint.h type if you need a 64bit number. <a href="https://groups.goog le.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread< /a></td> |
597 <td>Use an stdint.h type if you need a 64bit number. <a href="https://groups.goo gle.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread </a></td> | |
598 </tr> | 511 </tr> |
599 | 512 |
600 <tr> | 513 <tr> |
601 <td>Raw String Literals</td> | 514 <td>Raw String Literals</td> |
602 <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> | 515 <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> |
603 <td>Allows a string to be encoded without any escape | 516 <td>Allows a string to be encoded without any escape sequences, easing parsing i n regex expressions, for example</td> |
604 sequences, easing parsing in regex expressions, for example</td> | 517 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string li teral</a></td> |
605 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> | |
606 string literal</a></td> | |
607 <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> | 518 <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> |
608 </tr> | 519 </tr> |
609 | 520 |
610 <tr> | 521 <tr> |
611 <td>(Uniform) Initialization Syntax</td> | 522 <td>(Uniform) Initialization Syntax</td> |
612 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t d> | 523 <td><code><i>type</i> <i>name</i> {[<i>value</i> ..., <i>value</i>]};</code></td > |
613 <td>Allows any object of primitive, aggregate or class | 524 <td>Allows any object of primitive, aggregate or class type to be initialized us ing brace syntax</td> |
614 type to be initialized using brace syntax</td> | |
615 <td>TODO: documentation link</td> | 525 <td>TODO: documentation link</td> |
616 <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> | 526 <td>Reevaulate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/forum/#!topic/chromium-dev/GF96FshwHLw">Discussion thread</a></ td> |
617 </tr> | 527 </tr> |
618 | 528 |
619 <tr> | 529 <tr> |
620 <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td> | 530 <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td> |
621 <td><code>char16_t</code> and <code>char32_t</code></td> | 531 <td><code>char16_t</code> and <code>char32_t</code></td> |
622 <td>Provides character types for handling 16-bit | 532 <td>Provides character types for handling 16-bit and 32-bit code units (useful f or encoding UTF-16 and UTF-32 string data)</td> |
623 and 32-bit code units (useful for encoding | 533 <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types< /a></td> |
624 UTF-16 and UTF-32 string data)</td> | 534 <td>Reevaluate now that MSVS2015 is available. 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 useful for consuming non-ASCII data. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ME2kL7 _Kvyk">Discussion thread</a></td> |
625 <td><a href="http://en.cppreference.com/w/cpp/language/types"> | |
626 Fundamental types</a></td> | |
627 <td>Doesn't work in MSVS2013. Reevaluate once it does. Non-UTF-8 text is | |
628 banned by the | |
629 <a href="https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters" > | |
630 C++ Style Guide</a>. However, may be useful for | |
631 consuming non-ASCII data. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/ME2kL7_Kvyk">Discussion thread</a></td> | |
632 </tr> | 535 </tr> |
633 | 536 |
634 <tr> | 537 <tr> |
635 <td>UTF-8, UTF-16, UTF-32 String Literals</td> | 538 <td>UTF-8, UTF-16, UTF-32 String Literals</td> |
636 <td><code>u8"<i>string</i>", u"<i>string</i>", U"<i>str ing</i>"</code></td> | 539 <td><code>u8"<i>string</i>", u"<i>string</i>", U"<i>str ing</i>"</code></td> |
637 <td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td> | 540 <td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td> |
638 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> | 541 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string li teral</a></td> |
639 string literal</a></td> | 542 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/forum/#!topic/chromium-dev/gcoUbcjfsII">Discussion thread</a></ td> |
640 <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> | |
641 </tr> | 543 </tr> |
642 | 544 |
643 <tr> | 545 <tr> |
644 <td>Ref-qualified Member Functions</td> | 546 <td>Ref-qualified Member Functions</td> |
645 <td><code>class T {<br/> void f() & {}<br/> void f() && {} <br/>};<br/>t.f(); // first<br/>T().f(); // second<br/>std::move(t).f(); // sec ond</code></td> | 547 <td><code>class T {<br /> |
548 void f() & {}<br /> | |
549 void f() && {}<br /> | |
550 };<br /> | |
551 t.f(); // first<br /> | |
552 T().f(); // second<br /> | |
553 std::move(t).f(); // second</code></td> | |
646 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td> | 554 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td> |
647 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions"> | 555 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions">Member functions</a></td> |
648 Member functions</a></td> | 556 <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#C++ 11">Google Style Guide</a>. Banned in Chromium except by explicit approval from <code>styleguide/c++/OWNERS</code>. <a href="https://groups.google.com/a/chromiu m.org/d/topic/cxx/gowclr2LPQA/discussion">Discussion Thread</a></td> |
649 <td> | |
650 Banned in the google3 C++11 library style guide. Banned in Chromium except by explicit approval from <code>styleguide/c++/OWNERS</code>. | |
651 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/gowclr2LPQA/disc ussion">Discussion Thread</a> | |
652 </td> | |
653 </tr> | 557 </tr> |
654 | 558 |
655 </tbody> | 559 </tbody> |
656 </table> | 560 </table> |
657 | 561 |
658 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3> | 562 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3> |
659 | 563 |
660 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p> | 564 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p> |
661 | 565 |
662 <table id="blacklist_lib_list" class="unlined striped"> | 566 <table id="blacklist_lib_list" class="unlined striped"> |
(...skipping 18 matching lines...) Expand all Loading... | |
681 <tr> | 585 <tr> |
682 <td>Regex Library</td> | 586 <td>Regex Library</td> |
683 <td><code><regex></code></td> | 587 <td><code><regex></code></td> |
684 <td>Provides a standard regular expressions library</td> | 588 <td>Provides a standard regular expressions library</td> |
685 <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library </a></td> | 589 <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library </a></td> |
686 <td>We already have too many regular expression libraries in Chromium. Use re2 w hen in doubt.</td> | 590 <td>We already have too many regular expression libraries in Chromium. Use re2 w hen in doubt.</td> |
687 </tr> | 591 </tr> |
688 | 592 |
689 <tr> | 593 <tr> |
690 <td>Thread Library</td> | 594 <td>Thread Library</td> |
691 <td><code><thread> support, including <future>, | 595 <td><code><thread></code> support, including<br /> |
692 <mutex>, <condition_variable></code></td> | 596 <code><future></code>, <code><mutex></code>, <code><condition_var iable></code></td> |
693 <td>Provides a standard mulitthreading library using <code>std::thread</code> an d associates</td> | 597 <td>Provides a standard mulitthreading library using <code>std::thread</code> an d associates</td> |
694 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td> | 598 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td> |
695 <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> | 599 <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> |
696 </tr> | 600 </tr> |
697 | 601 |
698 <tr> | 602 <tr> |
699 <td>Atomics</td> | 603 <td>Atomics</td> |
700 <td><code>std::atomic</code> and others in <code><atomic></code></td> | 604 <td><code>std::atomic</code> and others in <code><atomic></code></td> |
701 <td>Fine-grained atomic types and operations</td> | 605 <td>Fine-grained atomic types and operations</td> |
702 <td><a href="http://en.cppreference.com/w/cpp/atomic"><atomic></a></td> | 606 <td><a href="http://en.cppreference.com/w/cpp/atomic"><atomic></a></td> |
703 <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> | 607 <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> |
704 </tr> | 608 </tr> |
705 | 609 |
706 <tr> | 610 <tr> |
707 <td>Shared Pointers</td> | 611 <td>Shared Pointers</td> |
708 <td><code>std::shared_ptr</code></td> | 612 <td><code>std::shared_ptr</code></td> |
709 <td>Allows shared ownership of a pointer through reference counts</td> | 613 <td>Allows shared ownership of a pointer through reference counts</td> |
710 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td> | 614 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td> |
711 <td> | 615 <td>Needs a lot more evaluation for Chromium, and there isn't enough of a push f or this feature. <a href="https://google.github.io/styleguide/cppguide.html#Owne rship_and_Smart_Pointers">Google Style Guide</a>. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/aT2wsBLKvzI/discussion">Discussion Thread</a>.</ td> |
712 Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature. | |
713 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/aT2wsBLKvzI/disc ussion">Discussion Thread</a>, | |
714 <a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart _Pointers">Google Style Guide</a> | |
715 </td> | |
716 </tr> | 616 </tr> |
717 | 617 |
718 <tr> | 618 <tr> |
719 <td>Initializer Lists</td> | 619 <td>Initializer Lists</td> |
720 <td><code>std::initializer_list<T></code></td> | 620 <td><code>std::initializer_list<T></code></td> |
721 <td>Allows containers to be initialized with aggregate elements</td> | 621 <td>Allows containers to be initialized with aggregate elements</td> |
722 <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list"><code>st d::initializer_list</code></a></td> | 622 <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list"><code>st d::initializer_list</code></a></td> |
723 <td> | 623 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/d/topic/cxx/TQQ-L51_naM/discussion">Discussion Thread</a></td> |
724 Banned for now; will be re-evaluated once we switch to MSVC 2015. | |
725 <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/TQQ-L51_naM/disc ussion">Discussion Thread</a> | |
726 </td> | |
727 </tr> | 624 </tr> |
728 | 625 |
729 </tbody> | 626 </tbody> |
730 </table> | 627 </table> |
731 | 628 |
732 | 629 |
733 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3> | 630 <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discuss ed</h3> |
734 | 631 |
735 <p>The following C++ language features are currently disallowed. | 632 <p>The following C++ language features are currently disallowed. |
736 See the top of this page on how to propose moving a feature from this list | 633 See the top of this page on how to propose moving a feature from this list |
737 into the allowed or banned sections. Note that not all of these features | 634 into the allowed or banned sections. Note that not all of these features |
738 work in all our compilers yet.</p> | 635 work in all our compilers yet.</p> |
739 | 636 |
740 <table id="blacklist_review_list" class="unlined striped"> | 637 <table id="blacklist_review_list" class="unlined striped"> |
741 <tbody> | 638 <tbody> |
742 | 639 |
743 <tr> | 640 <tr> |
744 <th style='width:240px;'>Feature</th> | 641 <th style='width:240px;'>Feature</th> |
745 <th style='width:240px;'>Snippet</th> | 642 <th style='width:240px;'>Snippet</th> |
746 <th style='width:240px;'>Description</th> | 643 <th style='width:240px;'>Description</th> |
747 <th style='width:240px;'>Documentation Link</th> | 644 <th style='width:240px;'>Documentation Link</th> |
748 <th style='width:240px;'>Notes</th> | 645 <th style='width:240px;'>Notes</th> |
749 </tr> | 646 </tr> |
750 | 647 |
751 <tr> | 648 <tr> |
752 <td>Attributes</td> | 649 <td>Attributes</td> |
753 <td><code>[[<i>attribute_name</i>]]</code></td> | 650 <td><code>[[<i>attribute_name</i>]]</code></td> |
754 <td>Attaches properties to declarations that | 651 <td>Attaches properties to declarations that specific compiler implementations m ay use.</td> |
755 specific compiler implementations may use.</td> | 652 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz ed-attributes/">C++11 generalized attributes</a></td> |
756 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz ed-attributes/"> | |
757 C++11 generalized attributes</a></td> | |
758 <td></td> | 653 <td></td> |
759 </tr> | 654 </tr> |
760 | 655 |
761 <tr> | 656 <tr> |
762 <td>Exception Features</td> | 657 <td>Exception Features</td> |
763 <td><code>noexcept</code>, <code>exception_ptr</code>, | 658 <td><code>noexcept</code>, <code>exception_ptr</code>, <code>current_exception() </code>, <code>rethrow_exception</code>, <code>nested_exception</code></td> |
764 <code>current_exception()</code>, <code>rethrow_exception</code>, | |
765 and <code>nested_exception</code></td> | |
766 <td>Enhancements to exception throwing and handling</td> | 659 <td>Enhancements to exception throwing and handling</td> |
767 <td><a href="http://en.cppreference.com/w/cpp/error/exception"> | 660 <td><a href="http://en.cppreference.com/w/cpp/error/exception">std::exception</a ></td> |
768 std::exception</a></td> | 661 <td>Exceptions are banned by the <a href="https://google.github.io/styleguide/cp pguide.html#Exceptions">Google Style Guide</a>. <a href="https://groups.google.c om/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a>< /td> |
769 <td>Exceptions are banned by the | |
770 <a href="https://google.github.io/styleguide/cppguide.html#Exceptions"> C++ Styl e Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chr omium-dev/8i4tMqNpHhg">Discussion thread</a></td> | |
771 </tr> | 662 </tr> |
772 | 663 |
773 <tr> | 664 <tr> |
774 <td>Inline Namespaces</td> | 665 <td>Inline Namespaces</td> |
775 <td><code>inline</code></td> | 666 <td><code>inline</code></td> |
776 <td>Allows better versioning of namespaces</td> | 667 <td>Allows better versioning of namespaces</td> |
777 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td> | 668 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a> </td> |
778 <td>Unclear how it will work with components</td> | 669 <td>Unclear how it will work with components</td> |
779 </tr> | 670 </tr> |
780 | 671 |
781 <tr> | 672 <tr> |
782 <td>Union Class Members</td> | 673 <td>Union Class Members</td> |
783 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td> | 674 <td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td> |
784 <td>Allows class type members</td> | 675 <td>Allows class type members</td> |
785 <td><a href="http://en.cppreference.com/w/cpp/language/union"> | 676 <td><a href="http://en.cppreference.com/w/cpp/language/union">Union declarations </a></td> |
786 Union declarations</a></td> | |
787 <td></td> | 677 <td></td> |
788 </tr> | 678 </tr> |
789 | 679 |
790 <tr> | 680 <tr> |
791 <td>User-Defined Literals</td> | 681 <td>User-Defined Literals</td> |
792 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> | 682 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
793 <td>Allows user-defined literal expressions</td> | 683 <td>Allows user-defined literal expressions</td> |
794 <td><a href="http://en.cppreference.com/w/cpp/language/user_literal"> | 684 <td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-define d literals</a></td> |
795 User-defined literals</a></td> | |
796 <td></td> | 685 <td></td> |
797 </tr> | 686 </tr> |
798 | 687 |
799 </tbody> | 688 </tbody> |
800 </table> | 689 </table> |
801 | 690 |
802 <h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Lib rary Features To Be Discussed</h3> | 691 <h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Lib rary Features To Be Discussed</h3> |
803 | 692 |
804 <p>The following C++ library features are currently disallowed. See the top of t his page on how to propose moving a feature from this list into the allowed or b anned sections. Note that not all of these features work in all our compilers ye t.</p> | 693 <p>The following C++ library features are currently disallowed. See the top of t his page on how to propose moving a feature from this list into the allowed or b anned sections. Note that not all of these features work in all our compilers ye t.</p> |
805 | 694 |
806 <table id="banned_stdlib" class="unlined striped"> | 695 <table id="banned_stdlib" class="unlined striped"> |
807 | 696 |
808 <tbody> | 697 <tbody> |
809 <tr> | 698 <tr> |
810 <th style='width:240px;'>Feature</th> | 699 <th style='width:240px;'>Feature</th> |
811 <th style='width:240px;'>Snippet</th> | 700 <th style='width:240px;'>Snippet</th> |
812 <th style='width:240px;'>Description</th> | 701 <th style='width:240px;'>Description</th> |
813 <th style='width:240px;'>Documentation Link</th> | 702 <th style='width:240px;'>Documentation Link</th> |
814 <th style='width:240px;'>Style Guide Usage</th> | 703 <th style='width:240px;'>Style Guide Usage</th> |
815 </tr> | 704 </tr> |
816 | 705 |
817 <tr> | 706 <tr> |
818 <td>Address Retrieval</td> | 707 <td>Address Retrieval</td> |
819 <td><code>std::addressof()</code></td> | 708 <td><code>std::addressof()</code></td> |
820 <td>Obtains the address of an object even with overloaded <code>operator&</c ode></td> | 709 <td>Obtains the address of an object even with overloaded <code>operator&</c ode></td> |
821 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</ a></td> | 710 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</ a></td> |
822 <td>Usage should be rare as | 711 <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> |
823 <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading" > | |
824 Operator Overloading</a> is rare and <code>&</code> | |
825 should suffice in most cases. May be preferable | |
826 over <code>&</code> for performing object | |
827 identity checks.</td> | |
828 </tr> | 712 </tr> |
829 | 713 |
830 <tr> | 714 <tr> |
831 <td>Aligned Storage</td> | 715 <td>Aligned Storage</td> |
832 <td><code>std::aligned_storage<Size, Align>::type</code> | 716 <td><code>std::aligned_storage<Size, Align>::type</code><br /> |
833 <code>std::alignment_of<T></code>, | 717 <code>std::alignment_of<T></code>, <code>std::aligned_union<Size, ...Ty pes></code> <code>std::max_align_t</code></td> |
834 <code>std::aligned_union<Size, ...Types></code> and | |
835 <code>std::max_align_t</code></td> | |
836 <td>Declare uninitialized storage having a specified alignment, or determine ali gnments.</td> | 718 <td>Declare uninitialized storage having a specified alignment, or determine ali gnments.</td> |
837 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligne d_storage</a></td> | 719 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligne d_storage</a></td> |
838 <td><code>std::aligned_storage</code> and <code>std::aligned_union</code> are | 720 <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> |
839 disallowed in google3 over concerns about compatibility with internal cross-comp iling | |
840 toolchains.</td> | |
841 </tr> | 721 </tr> |
842 | 722 |
843 <tr> | 723 <tr> |
844 <td>Allocator Traits</td> | 724 <td>Allocator Traits</td> |
845 <td><code>std::allocator_traits</code></td> | 725 <td><code>std::allocator_traits</code></td> |
846 <td>Provides an interface for accessing custom allocators</td> | 726 <td>Provides an interface for accessing custom allocators</td> |
847 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits"> | 727 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">std::allo cator_traits</a></td> |
848 std::allocator_traits</a></td> | |
849 <td>Usage should be rare.</td> | 728 <td>Usage should be rare.</td> |
850 </tr> | 729 </tr> |
851 | 730 |
852 <tr> | 731 <tr> |
853 <td>Bind Operations</td> | 732 <td>Bind Operations</td> |
854 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> | 733 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
855 <td>Declares a function object bound to certain arguments</td> | 734 <td>Declares a function object bound to certain arguments</td> |
856 <td>TODO: documentation link</td> | 735 <td>TODO: documentation link</td> |
857 <td></td> | 736 <td></td> |
858 </tr> | 737 </tr> |
859 | 738 |
860 <tr> | 739 <tr> |
861 <td>C Floating-Point Environment</td> | 740 <td>C Floating-Point Environment</td> |
862 <td><code><cfenv></code>, <code><fenv.h></code></td> | 741 <td><code><cfenv></code>, <code><fenv.h></code></td> |
863 <td>Provides floating point status flags and control modes for C-compatible code </td> | 742 <td>Provides floating point status flags and control modes for C-compatible code </td> |
864 <td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library hea der <cfenv></a></td> | 743 <td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library hea der <cfenv></a></td> |
865 <td>Compilers do not support use. This is banned in google style guide over | 744 <td>Banned in <a href="https://google.github.io/styleguide/cppguide.html#C++11"> Google Style Guide</a> due to concerns about compiler support.</td> |
866 compilers not supporting these reliably.</td> | |
867 </tr> | 745 </tr> |
868 | 746 |
869 <tr> | 747 <tr> |
870 <td>Complex Inverse Trigonometric and Hyperbolic Functions</td> | 748 <td>Complex Inverse Trigonometric and Hyperbolic Functions</td> |
871 <td>Functions within <code><complex></code></td> | 749 <td>Functions within <code><complex></code></td> |
872 <td>Adds inverse trigonomentric and hyperbolic non-member functions to | 750 <td>Adds inverse trigonomentric and hyperbolic non-member functions to the <code ><complex></code> library.</td> |
873 the <code><complex></code> library.</td> | |
874 <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a>< /td> | 751 <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a>< /td> |
875 <td></td> | 752 <td></td> |
876 </tr> | 753 </tr> |
877 | 754 |
878 <tr> | 755 <tr> |
879 <td>Container Compaction Functions</td> | 756 <td>Container Compaction Functions</td> |
880 <td><code>std::vector::shrink_to_fit()</code>, | 757 <td><code>std::vector::shrink_to_fit()</code>, <code>std::deque::shrink_to_fit() </code>, <code>std::string::shrink_to_fit()</code></td> |
881 <code>std::deque::shrink_to_fit()</code>, and | 758 <td>Requests the removal of unused space in the container</td> |
882 <code>std::string::shrink_to_fit()</code></td> | 759 <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit">st d::vector::shrink_to_fit</a>, <a href="http://en.cppreference.com/w/cpp/containe r/deque/shrink_to_fit">std::deque::shrink_to_fit</a>, <a href="http://en.cpprefe rence.com/w/cpp/string/basic_string/shrink_to_fit">std::basic_string::shrink_to_ fit</a></td> |
883 <td>Requests the removal of unused space | |
884 in the container</td> | |
885 <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit"> | |
886 std::vector::shrink_to_fit</a>, | |
887 <a href="http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit"> | |
888 std::deque::shrink_to_fit</a>, and | |
889 <a href="http://en.cppreference.com/w/cpp/string/basic_string/shrink_to_fit"> | |
890 std::basic_string::shrink_to_fit</a></td> | |
891 <td></td> | 760 <td></td> |
892 </tr> | 761 </tr> |
893 | 762 |
894 <tr> | 763 <tr> |
895 <td>Date/Time String Formatting Specifiers</td> | 764 <td>Date/Time String Formatting Specifiers</td> |
896 <td><code>std::strftime()</code></td> | 765 <td><code>std::strftime()</code></td> |
897 <td>Converts date and time information into a | 766 <td>Converts date and time information into a formatted string using new specifi ers</td> |
898 formatted string using new specifiers</td> | 767 <td><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime">std::strftime</ a></td> |
899 <td><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime"> | |
900 std::strftime</a></td> | |
901 <td></td> | 768 <td></td> |
902 </tr> | 769 </tr> |
903 | 770 |
904 <tr> | 771 <tr> |
905 <td>Function Return Type Deduction</td> | 772 <td>Function Return Type Deduction</td> |
906 <td><code>std::result_of<<i>Functor(ArgTypes...)</i>></code></td> | 773 <td><code>std::result_of<<i>Functor(ArgTypes...)</i>></code></td> |
907 <td>Extracts the return type from the type signature of | 774 <td>Extracts the return type from the type signature of a function call invocati on at compile-time.</td> |
908 a function call invocation at compile-time.</td> | 775 <td><a href="http://en.cppreference.com/w/cpp/types/result_of">std::result_of</a ></td> |
909 <td><a href="http://en.cppreference.com/w/cpp/types/result_of"> | 776 <td><a href="http://stackoverflow.com/questions/15486951/why-does-stdresult-of-t ake-an-unrelated-function-type-as-a-type-argument">Why does std::result_of take an (unrelated) function type as a type argument?</a></td> |
910 std::result_of</a></td> | |
911 <td> | |
912 <a href="http://stackoverflow.com/questions/15486951/why-does-stdresult-of-take- an-unrelated-function-type-as-a-type-argument"> | |
913 Why does std::result_of take an (unrelated) function type as a type argument? | |
914 </a></td> | |
915 </tr> | 777 </tr> |
916 | 778 |
917 <tr> | 779 <tr> |
918 <td>Function Objects</td> | 780 <td>Function Objects</td> |
919 <td><code>std::function</code></td> | 781 <td><code>std::function</code></td> |
920 <td>Wraps a standard polymorphic function</td> | 782 <td>Wraps a standard polymorphic function</td> |
921 <td>TODO: documentation link</td> | 783 <td>TODO: documentation link</td> |
922 <td></td> | 784 <td></td> |
923 </tr> | 785 </tr> |
924 | 786 |
925 <tr> | 787 <tr> |
926 <td>Forward Lists</td> | 788 <td>Forward Lists</td> |
927 <td><code>std::forward_list</code></td> | 789 <td><code>std::forward_list</code></td> |
928 <td>Provides an efficient singly linked list</td> | 790 <td>Provides an efficient singly linked list</td> |
929 <td><a href="http://en.cppreference.com/w/cpp/container/forward_list"> | 791 <td><a href="http://en.cppreference.com/w/cpp/container/forward_list">std::forwa rd_list</a></td> |
930 std::forward_list</a></td> | |
931 <td></td> | 792 <td></td> |
932 </tr> | 793 </tr> |
933 | 794 |
934 <tr> | 795 <tr> |
935 <td>Gamma Natural Log</td> | 796 <td>Gamma Natural Log</td> |
936 <td><code>std::lgamma()</code></td> | 797 <td><code>std::lgamma()</code></td> |
937 <td>Computes the natural log of the gamma of a | 798 <td>Computes the natural log of the gamma of a floating point value</td> |
938 floating point value</td> | 799 <td><a href="http://en.cppreference.com/w/cpp/numeric/math/lgamma">std::lgamma</ a></td> |
939 <td><a href="http://en.cppreference.com/w/cpp/numeric/math/lgamma"> | |
940 std::lgamma</a></td> | |
941 <td></td> | 800 <td></td> |
942 </tr> | 801 </tr> |
943 | 802 |
944 <tr> | 803 <tr> |
945 <td>Garbage Collection Features</td> | 804 <td>Garbage Collection Features</td> |
946 <td><code>std::{un}declare_reachable()</code> and | 805 <td><code>std::{un}declare_reachable()</code>, <code>std::{un}declare_no_pointer s()</code></td> |
947 <code>std::{un}declare_no_pointers()</code></td> | |
948 <td>Enables garbage collection implementations</td> | 806 <td>Enables garbage collection implementations</td> |
949 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable"> | 807 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable">std:: declare_reachable</a>, <a href="http://en.cppreference.com/w/cpp/memory/gc/decla re_no_pointers">std::declare_no_pointers</a></td> |
950 std::declare_reachable</a> | |
951 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers"> | |
952 std::declare_no_pointers</a></td> | |
953 <td></td> | 808 <td></td> |
954 </tr> | 809 </tr> |
955 | 810 |
956 <tr> | 811 <tr> |
957 <td>Iterator Operators</td> | 812 <td>Iterator Operators</td> |
958 <td><code>std::next()</code> and <code>std::prev()</code></td> | 813 <td><code>std::next()</code>, <code>std::prev()</code></td> |
959 <td>Copies an iterator and increments or decrements the copy by | 814 <td>Copies an iterator and increments or decrements the copy by some value</td> |
960 some value</td> | 815 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a>, <a h ref="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a></td> |
961 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a> | |
962 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> | |
963 </td> | |
964 <td></td> | 816 <td></td> |
965 </tr> | 817 </tr> |
966 | 818 |
967 <tr> | 819 <tr> |
968 <td>Pointer Traits Class Template</td> | 820 <td>Pointer Traits Class Template</td> |
969 <td><code>std::pointer_traits</code></td> | 821 <td><code>std::pointer_traits</code></td> |
970 <td>Provides a standard way to access properties | 822 <td>Provides a standard way to access properties of pointers and pointer-like ty pes</td> |
971 of pointers and pointer-like types</td> | 823 <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits">std::pointe r_traits</a></td> |
972 <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits"> | 824 <td>Useful for determining the element type pointed at by a (possibly smart) poi nter.</td> |
973 std::pointer_traits</a></td> | |
974 <td>Useful for determining the element type | |
975 pointed at by a (possibly smart) pointer.</td> | |
976 </tr> | 825 </tr> |
977 | 826 |
978 <tr> | 827 <tr> |
979 <td>Random Number Generators</td> | 828 <td>Random Number Generators</td> |
980 <td>Functions within <code><random></code></td> | 829 <td>Functions within <code><random></code></td> |
981 <td>Random number generation algorithms and utilities</td> | 830 <td>Random number generation algorithms and utilities</td> |
982 <td><a href="http://en.cppreference.com/w/cpp/numeric/random"> | 831 <td><a href="http://en.cppreference.com/w/cpp/numeric/random">Pseudo-random numb er generation</a></td> |
983 Pseudo-random number generation</a></td> | |
984 <td></td> | 832 <td></td> |
985 </tr> | 833 </tr> |
986 | 834 |
987 <tr> | 835 <tr> |
988 <td>Ratio Template Class</td> | 836 <td>Ratio Template Class</td> |
989 <td><code>std::ratio<<i>numerator</i>, <i>denominator</i>></code></td> | 837 <td><code>std::ratio<<i>numerator</i>, <i>denominator</i>></code></td> |
990 <td>Provides compile-time rational numbers</td> | 838 <td>Provides compile-time rational numbers</td> |
991 <td><a href="http://en.cppreference.com/w/cpp/numeric/ratio/ratio">std::ratio | 839 <td><a href="http://en.cppreference.com/w/cpp/numeric/ratio/ratio">std::ratio</a ></td> |
992 </a></td> | 840 <td>Banned in <a href="https://google.github.io/styleguide/cppguide.html#C++11"> Google Style Guide</a> due to concerns that they are tied to a more template-hea vy interface style.</td> |
993 <td>Note: These are banned in the google style guide over concerns that they are | |
994 tied to a more template-heavy interface style.</td> | |
995 </tr> | 841 </tr> |
996 | 842 |
997 <tr> | 843 <tr> |
998 <td>Reference Wrapper Classes</td> | 844 <td>Reference Wrapper Classes</td> |
999 <td><code>std::reference_wrapper</code> and | 845 <td><code>std::reference_wrapper</code> and <code>std::ref()</code>, <code>std:: cref()</code></td> |
1000 <code>std::ref()</code>, <code>std::cref()</code></td> | 846 <td>Allows you to wrap a reference within a standard object (and use those withi n containers)</td> |
1001 <td>Allows you to wrap a reference within a standard | 847 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum= 217">Reference Wrappers</a></td> |
1002 object (and use those within containers)</td> | |
1003 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum= 217"> | |
1004 Reference Wrappers</a></td> | |
1005 <td></td> | 848 <td></td> |
1006 </tr> | 849 </tr> |
1007 | 850 |
1008 <tr> | 851 <tr> |
1009 <td>Soft Program Exits</td> | 852 <td>Soft Program Exits</td> |
1010 <td><code>std::at_quick_exit()</code> | 853 <td><code>std::at_quick_exit()</code>, <code>std::quick_exit()</code></td> |
1011 and <code>std::quick_exit()</code></td> | 854 <td>Allows registration of functions to be called upon exit, allowing cleaner pr ogram exit than <code>abort()</code> or <code>exit</code></td> |
1012 <td>Allows registration of functions to be called upon exit, | 855 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">std:qu ick_exit</a></td> |
1013 allowing cleaner program exit than <code>abort()</code> or | |
1014 <code>exit</code></td> | |
1015 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit"> | |
1016 std:quick_exit</a></td> | |
1017 <td></td> | 856 <td></td> |
1018 </tr> | 857 </tr> |
1019 | 858 |
1020 <tr> | 859 <tr> |
1021 <td>String to Number Functions</td> | 860 <td>String to Number Functions</td> |
1022 <td><code>std::stoi()</code>, <code>std::stol()</code>, | 861 <td><code>std::stoi()</code>, <code>std::stol()</code>, <code>std::stoul()</code >, <code>std::stoll</code>, <code>std::stoull()</code>, <code>std::stof()</code> , <code>std::stod()</code>, <code>std::stold()</code>, <code>std::to_string()</c ode></td> |
1023 <code>std::stoul()</code>, <code>std::stoll</code>, <code>std::stoull()</code>, | |
1024 <code>std::stof()</code>, <code>std::stod()</code>, <code>std::stold()</code>, | |
1025 and <code>std::to_string()</code></td> | |
1026 <td>Converts strings to numbers</td> | 862 <td>Converts strings to numbers</td> |
1027 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol"> | 863 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">std::sto i, std::stol, std::stoll</a>, <a href="http://en.cppreference.com/w/cpp/string/b asic_string/stoul">std::stoul, std::stoull</a>, <a href="http://en.cppreference. com/w/cpp/string/basic_string/stof">std::stof, std::stod, std::stold</a></td> |
1028 std::stoi, std::stol, std::stoll</a>, | |
1029 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul"> | |
1030 std::stoul, std::stoull</a>, and | |
1031 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof"> | |
1032 std::stof, std::stod, std::stold</a> </td> | |
1033 <td></td> | 864 <td></td> |
1034 </tr> | 865 </tr> |
1035 | 866 |
1036 <tr> | 867 <tr> |
1037 <td>System Errors</td> | 868 <td>System Errors</td> |
1038 <td><code><system_error></code></td> | 869 <td><code><system_error></code></td> |
1039 <td>Provides a standard system error library</td> | 870 <td>Provides a standard system error library</td> |
1040 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er ror</a></td> | 871 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er ror</a></td> |
1041 <td></td> | 872 <td></td> |
1042 </tr> | 873 </tr> |
1043 | 874 |
1044 <tr> | 875 <tr> |
1045 <td>Trailing Return Types</td> | 876 <td>Trailing Return Types</td> |
1046 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> | 877 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> |
1047 <td>Allows trailing function return value syntax</td> | 878 <td>Allows trailing function return value syntax</td> |
1048 <td><a href="http://en.cppreference.com/w/cpp/language/function"> | 879 <td><a href="http://en.cppreference.com/w/cpp/language/function">Declaring funct ions</a></td> |
1049 Declaring functions</a></td> | |
1050 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /OQyYSfH9m2M">Discussion thread</a></td> | 880 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /OQyYSfH9m2M">Discussion thread</a></td> |
1051 </tr> | 881 </tr> |
1052 | 882 |
1053 <tr> | 883 <tr> |
1054 <td>Type-Generic Math Functions</td> | 884 <td>Type-Generic Math Functions</td> |
1055 <td>Functions within <code><ctgmath></code></td> | 885 <td>Functions within <code><ctgmath></code></td> |
1056 <td>Provides a means to call real or complex functions | 886 <td>Provides a means to call real or complex functions based on the type of argu ments</td> |
1057 based on the type of arguments</td> | 887 <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library h eader <ctgmath></a></td> |
1058 <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath"> | |
1059 Standard library header <ctgmath></a></td> | |
1060 <td></td> | 888 <td></td> |
1061 </tr> | 889 </tr> |
1062 | 890 |
1063 <tr> | 891 <tr> |
1064 <td>Type Info Enhancements</td> | 892 <td>Type Info Enhancements</td> |
1065 <td><code>std::type_index</code> and <code>std::type_info::hash_code()</code></t d> | 893 <td><code>std::type_index</code>, <code>std::type_info::hash_code()</code></td> |
1066 <td>Allows type information (most often within containers) | 894 <td>Allows type information (most often within containers) that can be copied, a ssigned, or hashed</td> |
1067 that can be copied, assigned, or hashed</td> | 895 <td><a href="http://en.cppreference.com/w/cpp/types/type_index">std::type_index< /a>, <a href="http://en.cppreference.com/w/cpp/types/type_info/hash_code">std::t ype_info::hash_code</a></td> |
1068 <td><a href="http://en.cppreference.com/w/cpp/types/type_index"> | 896 <td><code>std::type_index</code> is a thin wrapper for <code>std::type_info</cod e>, allowing you to use it directly within both associative and unordered contai ners</td> |
1069 std::type_index</a> and | |
1070 <a href="http://en.cppreference.com/w/cpp/types/type_info/hash_code"> | |
1071 std::type_info::hash_code</a></td> | |
1072 <td><code>std::type_index</code> is a thin wrapper for | |
1073 <code>std::type_info</code>, allowing you to use it directly | |
1074 within both associative and unordered containers</td> | |
1075 </tr> | 897 </tr> |
1076 | 898 |
1077 <tr> | 899 <tr> |
1078 <td>Variadic Copy Macro</td> | 900 <td>Variadic Copy Macro</td> |
1079 <td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> | 901 <td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> |
1080 <td>Makes a copy of the variadic function arguments</td> | 902 <td>Makes a copy of the variadic function arguments</td> |
1081 <td></td> | 903 <td></td> |
1082 <td></td> | 904 <td></td> |
1083 </tr> | 905 </tr> |
1084 | 906 |
1085 <tr> | 907 <tr> |
1086 <td>Weak Pointers</td> | 908 <td>Weak Pointers</td> |
1087 <td><code>std::weak_ptr</code></td> | 909 <td><code>std::weak_ptr</code></td> |
1088 <td>Allows a weak reference to a <code>std::shared_ptr</code></td> | 910 <td>Allows a weak reference to a <code>std::shared_ptr</code></td> |
1089 <td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr"> | 911 <td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr">std::weak_ptr</a> </td> |
1090 std::weak_ptr</a></td> | 912 <td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Sma rt_Pointers">Ownership and Smart Pointers</a></td> |
1091 <td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Sma rt_Pointers"> | |
1092 Ownership and Smart Pointers</a></td> | |
1093 </tr> | 913 </tr> |
1094 | 914 |
1095 <tr> | 915 <tr> |
1096 <td>Wide String Support</td> | 916 <td>Wide String Support</td> |
1097 <td><code>std::wstring_convert</code>, | 917 <td><code>std::wstring_convert</code>, <code>std::wbuffer_convert</code><br /> |
1098 <code>std::wbuffer_convert</code>. | 918 <code>std::codecvt_utf8</code>, <code>std::codecvt_utf16</code>, <code>std::code cvt_utf8_utf16</code></td> |
1099 <code>std::codecvt_utf8</code>, <code>std::codecvt_utf16</code>, | |
1100 and <code>std::codecvt_utf8_utf16</code></td> | |
1101 <td>Converts between string encodings</td> | 919 <td>Converts between string encodings</td> |
1102 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert"> | 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> |
1103 std::wstring_convert</a>, | 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> |
1104 <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert"> | |
1105 std::wbuffer_convert</a>, | |
1106 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf8"> | |
1107 std::codecvt_utf8</a>, | |
1108 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf16"> | |
1109 std::codecvt_utf16</a>, and | |
1110 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf8_utf16"> | |
1111 std::codecvt_utf8_utf16</a> | |
1112 </td> | |
1113 <td>Non-UTF-8 text is banned by the | |
1114 <a href="https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters" > | |
1115 C++ Style Guide</a>. However, may be useful for | |
1116 consuming non-ASCII data.</td> | |
1117 </tr> | 922 </tr> |
1118 | 923 |
1119 </tbody> | 924 </tbody> |
1120 </table> | 925 </table> |
1121 | 926 |
1122 </div> | 927 </div> |
1123 </body> | 928 </body> |
1124 </html> | 929 </html> |
OLD | NEW |