OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2014 The Chromium Authors. All rights reserved. | 3 Copyright 2014 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 <html> | 7 <html> |
8 <head> | 8 <head> |
9 <meta charset="utf-8"> | 9 <meta charset="utf-8"> |
10 <title>C++11 use in Chromium</title> | 10 <title>C++11 use in Chromium</title> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 <td>More intuitive parsing of template parameters</td> | 71 <td>More intuitive parsing of template parameters</td> |
72 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack
ets-pitfall-what-is-the-c11-fix"> | 72 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack
ets-pitfall-what-is-the-c11-fix"> |
73 C++ Templates Angle Brackets Pitfall</a></td> | 73 C++ Templates Angle Brackets Pitfall</a></td> |
74 <td>Recommended to increase readability. Approved without discussion.</td> | 74 <td>Recommended to increase readability. Approved without discussion.</td> |
75 </tr> | 75 </tr> |
76 | 76 |
77 <tr> | 77 <tr> |
78 <td>Automatic Types</td> | 78 <td>Automatic Types</td> |
79 <td><code>auto</code></td> | 79 <td><code>auto</code></td> |
80 <td>Automatic type deduction</td> | 80 <td>Automatic type deduction</td> |
81 <td>TODO: documentation link</td> | 81 <td><a href="http://en.cppreference.com/w/cpp/language/auto"> |
| 82 auto specifier</a></td> |
82 <td>Use according to the <a | 83 <td>Use according to the <a |
83 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto">Goo
gle | 84 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto">Goo
gle |
84 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> | 85 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> |
85 </tr> | 86 </tr> |
86 | 87 |
87 <tr> | 88 <tr> |
88 <td>Declared Type Accessor</td> | 89 <td>Declared Type Accessor</td> |
89 <td><code>decltype(<i>expression</i>)</code></td> | 90 <td><code>decltype(<i>expression</i>)</code></td> |
90 <td>Provides a means to determine the type of an expression at compile-time, | 91 <td>Provides a means to determine the type of an expression at compile-time, |
91 useful most often in templates.</td> | 92 useful most often in templates.</td> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#In
itialization">Google | 187 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#In
itialization">Google |
187 Style Guide</a>. | 188 Style Guide</a>. |
188 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB
-DySA4V0">Discussion thread</a> | 189 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB
-DySA4V0">Discussion thread</a> |
189 </td> | 190 </td> |
190 </tr> | 191 </tr> |
191 | 192 |
192 <tr> | 193 <tr> |
193 <td>Null Pointer Constant</td> | 194 <td>Null Pointer Constant</td> |
194 <td><code>nullptr</code></td> | 195 <td><code>nullptr</code></td> |
195 <td>Declares a type-safe null pointer</td> | 196 <td>Declares a type-safe null pointer</td> |
196 <td>TODO: documentation link</td> | 197 <td><a href="http://en.cppreference.com/w/cpp/language/nullptr"> |
| 198 nullptr</a></td> |
197 <td>Recommended for new code. | 199 <td>Recommended for new code. |
198 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mi
jeJHzxLg">Discussion thread</a>. | 200 <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mi
jeJHzxLg">Discussion thread</a>. |
199 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#0_and_
nullptr/NULL">Google Style Guide</a>. | 201 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#0_and_
nullptr/NULL">Google Style Guide</a>. |
200 Note: <code>std::nullptr_t</code> is a library feature and not available. | 202 Note: <code>std::nullptr_t</code> is a library feature and not available. |
201 </td> | 203 </td> |
202 </tr> | 204 </tr> |
203 | 205 |
204 <tr> | 206 <tr> |
205 <td>Override Specifier</td> | 207 <td>Override Specifier</td> |
206 <td><code>override</code></td> | 208 <td><code>override</code></td> |
207 <td>Indicates that a class or function overrides a base implementation</td> | 209 <td>Indicates that a class or function overrides a base implementation</td> |
208 <td><a href="http://en.cppreference.com/w/cpp/language/override">override Langua
ge Reference</a></td> | 210 <td><a href="http://en.cppreference.com/w/cpp/language/override">override Langua
ge Reference</a></td> |
209 <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> | 211 <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> |
210 </tr> | 212 </tr> |
211 | 213 |
212 <tr> | 214 <tr> |
213 <td>Range-Based For Loops</td> | 215 <td>Range-Based For Loops</td> |
214 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> | 216 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> |
215 <td>Facilitates a more concise syntax for iterating over the elements | 217 <td>Facilitates a more concise syntax for iterating over the elements |
216 of a container (or a range of iterators) in a <code>for</code> loop</td> | 218 of a container (or a range of iterators) in a <code>for</code> loop</td> |
217 <td>TODO: documentation link</td> | 219 <td><a href="http://en.cppreference.com/w/cpp/language/range-for"> |
| 220 Range-based for loop</a></td> |
218 <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> | 221 <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> |
219 </tr> | 222 </tr> |
220 | 223 |
221 <tr> | 224 <tr> |
222 <td>Standard Integers</td> | 225 <td>Standard Integers</td> |
223 <td>Typedefs within <code><stdint.h></code> | 226 <td>Typedefs within <code><stdint.h></code> |
224 and <code><inttypes></code></td> | 227 and <code><inttypes></code></td> |
225 <td>Provides fixed-size integers independent of platforms</td> | 228 <td>Provides fixed-size integers independent of platforms</td> |
226 <td><a href="http://www.cplusplus.com/reference/cstdint/"> | 229 <td><a href="http://www.cplusplus.com/reference/cstdint/"> |
227 <stdint.h> (cstdint)</a></td> | 230 <stdint.h> (cstdint)</a></td> |
(...skipping 14 matching lines...) Expand all Loading... |
242 <td>Allows macros that accept a variable number of arguments</td> | 245 <td>Allows macros that accept a variable number of arguments</td> |
243 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons
tandard"> | 246 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons
tandard"> |
244 Are Variadic macros nonstandard?</a></td> | 247 Are Variadic macros nonstandard?</a></td> |
245 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru
m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> | 248 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru
m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> |
246 </tr> | 249 </tr> |
247 | 250 |
248 <tr> | 251 <tr> |
249 <td>Variadic Templates</td> | 252 <td>Variadic Templates</td> |
250 <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> | 253 <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> |
251 <td>Allows templates that accept a variable number of arguments</td> | 254 <td>Allows templates that accept a variable number of arguments</td> |
252 <td>TODO: documentation link</td> | 255 <td><a href="http://en.cppreference.com/w/cpp/language/parameter_pack"> |
| 256 Parameter pack</a></td> |
253 <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> | 257 <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> |
254 </tr> | 258 </tr> |
255 | 259 |
256 </tbody> | 260 </tbody> |
257 </table> | 261 </table> |
258 | 262 |
259 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> | 263 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> |
260 | 264 |
261 <p>This section lists features that are not allowed to be used yet. | 265 <p>This section lists features that are not allowed to be used yet. |
262 | 266 |
(...skipping 11 matching lines...) Expand all Loading... |
274 <th style='width:240px;'>Snippet</th> | 278 <th style='width:240px;'>Snippet</th> |
275 <th style='width:240px;'>Description</th> | 279 <th style='width:240px;'>Description</th> |
276 <th style='width:240px;'>Documentation Link</th> | 280 <th style='width:240px;'>Documentation Link</th> |
277 <th style='width:240px;'>Notes</th> | 281 <th style='width:240px;'>Notes</th> |
278 </tr> | 282 </tr> |
279 | 283 |
280 <tr> | 284 <tr> |
281 <td>Constant Expressions</td> | 285 <td>Constant Expressions</td> |
282 <td><code>constexpr</code></td> | 286 <td><code>constexpr</code></td> |
283 <td>Compile-time constant expressions</td> | 287 <td>Compile-time constant expressions</td> |
284 <td>TODO: documentation link</td> | 288 <td><a href="http://en.cppreference.com/w/cpp/language/constexpr"> |
| 289 constexpr specifier</a></td> |
285 <td>Doesn't work in MSVS2013. Reevalute once it does. <a | 290 <td>Doesn't work in MSVS2013. Reevalute once it does. <a |
286 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Use_of_co
nstexpr">Google | 291 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Use_of_co
nstexpr">Google |
287 Style Guide on <code>constexpr</code></a></td> | 292 Style Guide on <code>constexpr</code></a></td> |
288 </tr> | 293 </tr> |
289 | 294 |
290 <tr> | 295 <tr> |
291 <td>Explicit Conversion Operators</td> | 296 <td>Explicit Conversion Operators</td> |
292 <td><code>explicit operator <i>type</i>() { | 297 <td><code>explicit operator <i>type</i>() { |
293 <br /> // code<br /> }</code></td> | 298 <br /> // code<br /> }</code></td> |
294 <td>Allows conversion operators that cannot be implicitly invoked</td> | 299 <td>Allows conversion operators that cannot be implicitly invoked</td> |
(...skipping 30 matching lines...) Expand all Loading... |
325 <td><a href="http://en.cppreference.com/w/cpp/language/types"> | 330 <td><a href="http://en.cppreference.com/w/cpp/language/types"> |
326 Fundamental types</a></td> | 331 Fundamental types</a></td> |
327 <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> | 332 <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> |
328 </tr> | 333 </tr> |
329 | 334 |
330 <tr> | 335 <tr> |
331 <td>Raw String Literals</td> | 336 <td>Raw String Literals</td> |
332 <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> | 337 <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> |
333 <td>Allows a string to be encoded without any escape | 338 <td>Allows a string to be encoded without any escape |
334 sequences, easing parsing in regex expressions, for example</td> | 339 sequences, easing parsing in regex expressions, for example</td> |
335 <td>TODO: documentation link</td> | 340 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> |
| 341 string literal</a></td> |
336 <td>Causes incorrect line numbers in MSVS2014 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> | 342 <td>Causes incorrect line numbers in MSVS2014 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> |
337 </tr> | 343 </tr> |
338 | 344 |
339 <tr> | 345 <tr> |
340 <td>Rvalue References (and Move Semantics)</td> | 346 <td>Rvalue References (and Move Semantics)</td> |
341 <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)</cod
e></td> | 347 <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)</cod
e></td> |
342 <td>Reference that only binds to a temporary object</td> | 348 <td>Reference that only binds to a temporary object</td> |
343 <td>TODO: documentation link</td> | 349 <td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_referen
ces"> |
| 350 Rvalue references</a></td> |
344 <td>To be revisited in the future. Allowed in exceptional cases where approved
by the OWNERS of src/styleguide/c++/. <a href="https://groups.google.com/a/chrom
ium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussion thread</a></td> | 351 <td>To be revisited in the future. Allowed in exceptional cases where approved
by the OWNERS of src/styleguide/c++/. <a href="https://groups.google.com/a/chrom
ium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussion thread</a></td> |
345 </tr> | 352 </tr> |
346 | 353 |
347 <tr> | 354 <tr> |
348 <td>(Uniform) Initialization Syntax</td> | 355 <td>(Uniform) Initialization Syntax</td> |
349 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t
d> | 356 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t
d> |
350 <td>Allows any object of primitive, aggregate or class | 357 <td>Allows any object of primitive, aggregate or class |
351 type to be initialized using brace syntax</td> | 358 type to be initialized using brace syntax</td> |
352 <td>TODO: documentation link</td> | 359 <td>TODO: documentation link</td> |
353 <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> | 360 <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> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 <td>Allows class type members</td> | 463 <td>Allows class type members</td> |
457 <td><a href="http://en.cppreference.com/w/cpp/language/union"> | 464 <td><a href="http://en.cppreference.com/w/cpp/language/union"> |
458 Union declarations</a></td> | 465 Union declarations</a></td> |
459 <td></td> | 466 <td></td> |
460 </tr> | 467 </tr> |
461 | 468 |
462 <tr> | 469 <tr> |
463 <td>User-Defined Literals</td> | 470 <td>User-Defined Literals</td> |
464 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> | 471 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
465 <td>Allows user-defined literal expressions</td> | 472 <td>Allows user-defined literal expressions</td> |
466 <td>TODO: documentation link</td> | 473 <td><a href="http://en.cppreference.com/w/cpp/language/user_literal"> |
| 474 User-defined literals</a></td> |
467 <td></td> | 475 <td></td> |
468 </tr> | 476 </tr> |
469 | 477 |
470 </tbody> | 478 </tbody> |
471 </table> | 479 </table> |
472 | 480 |
473 <h3 id="blacklist_stdlib">C++11 Standard Library features</h3> | 481 <h3 id="blacklist_stdlib">C++11 Standard Library features</h3> |
474 | 482 |
475 <details> | 483 <details> |
476 | 484 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 </tr> | 978 </tr> |
971 | 979 |
972 </tbody> | 980 </tbody> |
973 </table> | 981 </table> |
974 | 982 |
975 </details> | 983 </details> |
976 | 984 |
977 </div> | 985 </div> |
978 </body> | 986 </body> |
979 </html> | 987 </html> |
OLD | NEW |