OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 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 |
| 5 found in the LICENSE file. |
| 6 --> |
| 7 <html> |
| 8 <head> |
| 9 <meta charset="utf-8"> |
| 10 <link rel="stylesheet" href="c++11.css"> |
| 11 <style> |
| 12 table tbody tr td:first-child { |
| 13 font-weight: bold; |
| 14 font-size: 110%; |
| 15 } |
| 16 </style> |
| 17 </head> |
| 18 <body> |
| 19 <div id="content"> |
| 20 <h1>C++11 use in Chromium</h1> |
| 21 |
| 22 <p><i>This document lives at src/styleguide/c++/c++11.html in a Chromium |
| 23 checkout.</i></p> |
| 24 |
| 25 <p>This document summarizes the features of C++11 (both in the language itself |
| 26 and in enhancements to the Standard Library) and describes which features are |
| 27 allowed in Chromium and contains pointers to more detailed information. The |
| 28 Guide applies to Chromium and its subprojects. Subprojects can choose to be |
| 29 more restrictive if they need to compile on more toolchains than Chromium.</p> |
| 30 |
| 31 <p>You can propose to make a feature available or to ban a |
| 32 feature by sending an email to chromium-dev. Ideally include a short blurb |
| 33 on what the feature is, and why you think it should or should not be allowed. |
| 34 Ideally, the list will arrive at some consensus and the wiki page will be |
| 35 updated to mention that consensus. If there's no consensus, |
| 36 <code>src/styleguide/C++/OWNERS</code> get to decide -- for divisive features, w
e expect |
| 37 the decision to be to not use the feature yet and possibly discuss it again a |
| 38 few months later, when we have more experience with the language.</p> |
| 39 |
| 40 <p class="warning">Unless otherwise noted, <strong>no</strong> C++11 |
| 41 <strong>library</strong> features are allowed.</p> |
| 42 |
| 43 <h2 id="whitelist">C++11 Allowed Features</h2> |
| 44 |
| 45 <p>The following features are currently allowed.</p> |
| 46 |
| 47 <table id="whitelist_lang_list" class="unlined striped"> |
| 48 <tbody> |
| 49 |
| 50 <tr> |
| 51 <th style='width:220px;'>Feature</th> |
| 52 <th style='width:260px;'>Snippet</th> |
| 53 <th style='width:240px;'>Description</th> |
| 54 <th style='width:240px;'>Documentation Link</th> |
| 55 <th style='width:240px;'>Notes and Discussion Thread</th> |
| 56 </tr> |
| 57 |
| 58 <tr> |
| 59 <td>Angle Bracket Parsing in Templates</td> |
| 60 <td><code>>></code> for <code>> ></code> and <br /> |
| 61 <code><::</code> for <code>< ::</code></td> |
| 62 <td>More intuitive parsing of template parameters</td> |
| 63 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack
ets-pitfall-what-is-the-c11-fix"> |
| 64 C++ Templates Angle Brackets Pitfall</a></td> |
| 65 <td>Recommended to increase readability. Approved without discussion.</td> |
| 66 </tr> |
| 67 |
| 68 <tr> |
| 69 <td>Local Types as Template Arguments</td> |
| 70 <td></td> |
| 71 <td>Allows local and unnamed types as template arguments</td> |
| 72 <td><a href="http://stackoverflow.com/questions/742607/using-local-classes-with-
stl-algorithms"> |
| 73 Local types, types without linkage and unnamed types as template arguments</a></
td> |
| 74 <td>Usage should be rare. Approved without discussion.</td> |
| 75 </tr> |
| 76 |
| 77 <tr> |
| 78 <td>Standard Integers</td> |
| 79 <td>Typedefs within <code><stdint.h></code> |
| 80 and <code><inttypes></code></td> |
| 81 <td>Provides fixed-size integers independent of platforms</td> |
| 82 <td><a href="http://www.cplusplus.com/reference/cstdint/"> |
| 83 <stdint.h> (cstdint)</a></td> |
| 84 <td>Already in common use in the codebase. Approved without discussion.</td> |
| 85 </tr> |
| 86 |
| 87 </tbody> |
| 88 </table> |
| 89 |
| 90 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> |
| 91 |
| 92 <p>This section lists features that are not allowed to be used yet. |
| 93 |
| 94 <h3 id="blacklist_banned">C++11 Banned Features</h3> |
| 95 |
| 96 <p>None yet! This section will list C++11 features that are not allowed in the |
| 97 Chromium codebase. |
| 98 </p> |
| 99 |
| 100 <!-- |
| 101 <table id="banned_list" class="unlined striped"> |
| 102 <tbody> |
| 103 |
| 104 <tr> |
| 105 <th style='width:240px;'>Feature or Library</th> |
| 106 <th style='width:240px;'>Snippet</th> |
| 107 <th style='width:240px;'>Description</th> |
| 108 <th style='width:240px;'>Documentation Link</th> |
| 109 <th style='width:240px;'>Status</th> |
| 110 </tr> |
| 111 |
| 112 </tbody> |
| 113 </table> |
| 114 --> |
| 115 |
| 116 <h3 id="blacklist_review">C++11 Features To Be Discussed</h3> |
| 117 |
| 118 <p>The following C++ language features are currently disallowed. |
| 119 See the top of this page on how to propose moving a feature from this list |
| 120 into the allowed or banned sections. Note that not all of these features |
| 121 work in all our compilers yet.</p> |
| 122 |
| 123 <table id="blacklist_review_list" class="unlined striped"> |
| 124 <tbody> |
| 125 |
| 126 <tr> |
| 127 <th style='width:240px;'>Feature</th> |
| 128 <th style='width:240px;'>Snippet</th> |
| 129 <th style='width:240px;'>Description</th> |
| 130 <th style='width:240px;'>Documentation Link</th> |
| 131 <th style='width:240px;'>Notes</th> |
| 132 </tr> |
| 133 |
| 134 <tr> |
| 135 <td>Aliases</td> |
| 136 <td><code>using <i>new_alias</i> = <i>typename</i></code></td> |
| 137 <td>Allow parameterized typedefs</td> |
| 138 <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias (u
sing syntax)</a></td> |
| 139 <td></td> |
| 140 </tr> |
| 141 |
| 142 <tr> |
| 143 <td>Alignment Features</td> |
| 144 <td> |
| 145 <code>alignas</code> specifier, |
| 146 <code>std::alignment_of<T></code>, |
| 147 <code>std::aligned_union<Size, ...Types></code> and |
| 148 <code>std::max_align_t</code></td> |
| 149 <td>Object alignment</td> |
| 150 <td><a href="http://en.cppreference.com/w/cpp/types/alignment_of">std::alignment
_of</a></td> |
| 151 <td></td> |
| 152 </tr> |
| 153 |
| 154 <tr> |
| 155 <td>Attributes</td> |
| 156 <td><code>[[<i>attribute_name</i>]]</code></td> |
| 157 <td>Attaches properties to declarations that |
| 158 specific compiler implementations may use.</td> |
| 159 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz
ed-attributes/"> |
| 160 C++11 generalized attributes</a></td> |
| 161 <td></td> |
| 162 </tr> |
| 163 |
| 164 <tr> |
| 165 <td>Automatic Types</td> |
| 166 <td><code>auto</code></td> |
| 167 <td>Automatic type deduction</td> |
| 168 <td><a href="http://go/totw:4"> |
| 169 Tip of the Week #4: Use <code>const auto&</code> and |
| 170 <code>auto</code> to replace complex declarations</a></td> |
| 171 <td><a |
| 172 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto">Goo
gle |
| 173 Style Guide on <code>auto</code></a></td> |
| 174 </tr> |
| 175 |
| 176 <tr> |
| 177 <td>Constant Expressions</td> |
| 178 <td><code>constexpr</code></td> |
| 179 <td>Compile-time constant expressions</td> |
| 180 <td><a href="http://go/totw:57"> |
| 181 Tip of the Week #57: <code>constexpr</code> is forever</a></td> |
| 182 <td>Not supported in MSVS2013. <a |
| 183 href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#constexpr
">Google |
| 184 Style Guide on <code>constexpr</code></a></td> |
| 185 </tr> |
| 186 |
| 187 <tr> |
| 188 <td>Declared Type Accessor</td> |
| 189 <td><code>decltype(<i>expression</i>)</code></td> |
| 190 <td>Provides a means to determine the type of an expression at compile-time, |
| 191 useful most often in templates.</td> |
| 192 <td><a href="http://en.cppreference.com/w/cpp/language/decltype"> |
| 193 decltype specifier</a></td> |
| 194 <td></td> |
| 195 </tr> |
| 196 |
| 197 <tr> |
| 198 <td>Default Function Creation</td> |
| 199 <td><code><i>Function</i>(<i>arguments</i>) = default;</code></td> |
| 200 <td>Instructs the compiler to generate a default version |
| 201 of the indicated function</td> |
| 202 <td><a href="http://stackoverflow.com/questions/823935/whats-the-point-in-defaul
ting-functions-in-c11"> |
| 203 What's the point in defaulting functions in C++11?</a></td> |
| 204 <td></td> |
| 205 </tr> |
| 206 |
| 207 <tr> |
| 208 <td>Default Function Template Arguments</td> |
| 209 <td><code>template <typename T = <i>type</i>> <br /> |
| 210 <i>type</i> <i>Function</i>(T <i>var</i>) {}</code></td> |
| 211 <td>Allow function templates, like classes, to have default arguments</td> |
| 212 <td><a href="http://stackoverflow.com/questions/2447458/default-template-argumen
ts-for-function-templates"> |
| 213 Default Template Arguments for Function Templates</a></td> |
| 214 <td></td> |
| 215 </tr> |
| 216 |
| 217 <tr> |
| 218 <td>Delegated Constructors</td> |
| 219 <td><code>Class() : Class(0) {}</code><br /> |
| 220 <code>Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0)</code></td> |
| 221 <td>Allow overloaded constructors to use common initialization code</td> |
| 222 <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"> |
| 223 Introduction to the C++11 feature: delegating constructors</a></td> |
| 224 <td></td> |
| 225 </tr> |
| 226 |
| 227 <tr> |
| 228 <td>Enumerated Type Classes</td> |
| 229 <td><code>enum class <i>classname</i></code></td> |
| 230 <td>Provide enums as full classes, with no implicit |
| 231 conversion to booleans or integers</td> |
| 232 <td><a href="http://stackoverflow.com/questions/6936030/do-we-really-need-enum-c
lass-in-c11"> |
| 233 enum-class</a></td> |
| 234 <td></td> |
| 235 </tr> |
| 236 |
| 237 <tr> |
| 238 <td>Exception Features</td> |
| 239 <td><code>noexcept</code>, <code>exception_ptr</code>, |
| 240 <code>current_exception()</code>, <code>rethrow_exception</code>, |
| 241 and <code>nested_exception</code></td> |
| 242 <td>Enhancements to exception throwing and handling</td> |
| 243 <td><a href="http://en.cppreference.com/w/cpp/error/exception"> |
| 244 std::exception</a></td> |
| 245 <td>Exceptions are banned by the |
| 246 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Except
ions"> |
| 247 C++ Style Guide</a>.</td> |
| 248 </tr> |
| 249 |
| 250 <tr> |
| 251 <td>Explicit Conversion Operators</td> |
| 252 <td><code>explicit operator <i>type</i>() { |
| 253 <br /> // code<br /> }</code></td> |
| 254 <td>Allows conversion operators that cannot be implicitly invoked</td> |
| 255 <td><a href="http://en.cppreference.com/w/cpp/language/explicit"> |
| 256 explicit specifier</a></td> |
| 257 <td></td> |
| 258 </tr> |
| 259 |
| 260 <tr> |
| 261 <td>Final Declarations</td> |
| 262 <td><code>final</code></td> |
| 263 <td>Indicates that a class or function is final and cannot be overridden</td> |
| 264 <td><a href="http://go/totw:54"> |
| 265 Tip of the Week #54: Controlling Your Inheritance</a></td> |
| 266 <td><code>FINAL</code> is already widely used in the codebase.</td> |
| 267 </tr> |
| 268 |
| 269 <tr> |
| 270 <td>Function Local Variable</td> |
| 271 <td><code>__func__</code></td> |
| 272 <td>Provides a local variable of the name of the enclosing |
| 273 function for logging purposes</td> |
| 274 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=
338"> |
| 275 The __func__ Predeclared Identifier is Coming to C++</a></td> |
| 276 <td></td> |
| 277 </tr> |
| 278 |
| 279 <tr> |
| 280 <td>Function Suppression</td> |
| 281 <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> |
| 282 <td>Suppresses the implementation of a function, especially a |
| 283 synthetic function such as a copy constructor</td> |
| 284 <td>TODO: documentation link</td> |
| 285 <td></td> |
| 286 </tr> |
| 287 |
| 288 <tr> |
| 289 <td>(Uniform) Initialization Syntax</td> |
| 290 <td><code><i>type</i> <i>name</i> { [<i>value</i> ..., <i>value</i>]};</code></t
d> |
| 291 <td>Allows any object of primitive, aggregate or class |
| 292 type to be initialized using brace syntax</td> |
| 293 <td><a href="http://go/totw:58"> |
| 294 Tip of the Week #58: Initializer Lists and the Uniform Initialization Syntax</a>
</td> |
| 295 <td></td> |
| 296 </tr> |
| 297 |
| 298 <tr> |
| 299 <td>Inline Namespaces</td> |
| 300 <td><code>inline</code></td> |
| 301 <td>Allows better versioning of namespaces</td> |
| 302 <td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a>
</td> |
| 303 <td>Under investigation, unclear how it will work with |
| 304 components</td> |
| 305 </tr> |
| 306 |
| 307 <tr> |
| 308 <td>Lambda Expressions</td> |
| 309 <td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</cod
e></td> |
| 310 <td>Anonymous functions</td> |
| 311 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions<
/a></td> |
| 312 <td>No default captures (<a href="https://google-styleguide.googlecode.com/svn/t
runk/cppguide.html#Lambda_expressions">Google Style Guide</a>).</td> |
| 313 </tr> |
| 314 |
| 315 <tr> |
| 316 <td><code>long long</code> Type</td> |
| 317 <td><code>long long <i>var</i>= <i>value</i>;</code></td> |
| 318 <td>An integer of at least 64 bits</td> |
| 319 <td><a href="http://en.cppreference.com/w/cpp/language/types"> |
| 320 Fundamental types</a></td> |
| 321 <td></td> |
| 322 </tr> |
| 323 |
| 324 <tr> |
| 325 <td>Non-Static Class Member Initializers</td> |
| 326 <td> |
| 327 <code> |
| 328 class C {<br /> |
| 329 <i>type</i> <i>var</i> = <i>value</i>;<br/> |
| 330 C() // copy-initializes <i>var</i><br/> |
| 331 </code> |
| 332 <td>Allows non-static class members to be initialized at their definitions (outs
ide constructors)</td> |
| 333 <td><a href="http://go/totw:61"> |
| 334 Tip of the Week #58: Non-Static Class Member Initializers</a> and |
| 335 <a href="http://en.cppreference.com/w/cpp/language/data_members"> |
| 336 Non-static data members</a></td> |
| 337 <td></td> |
| 338 </tr> |
| 339 |
| 340 <tr> |
| 341 <td>Null Pointer Constant</td> |
| 342 <td><code>nullptr</code></td> |
| 343 <td>Declares a type-safe null pointer</td> |
| 344 <td><a href="http://go/totw:39"> |
| 345 Tip of the Week #39: Prefer C++11’s nullptr to NULL or 0</a></td> |
| 346 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#0_
and_nullptr/NULL">Google Style Guidwe</a>. |
| 347 </td> |
| 348 </tr> |
| 349 |
| 350 <tr> |
| 351 <td>Overrides</td> |
| 352 <td><code>override</code></td> |
| 353 <td>Indicates that a class or function overrides a base implementation</td> |
| 354 <td><a href="http://go/totw:54"> |
| 355 Tip of the Week #54: Controlling Your Inheritance</a></td> |
| 356 <td><code>OVERRIDE</code> is already widely used in the codebase.</td> |
| 357 </tr> |
| 358 |
| 359 <tr> |
| 360 <td>Range-Based For Loops</td> |
| 361 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> |
| 362 <td>Facilitates a more concise syntax for iterating over the elements |
| 363 of a container (or a range of iterators) in a <code>for</code> loop</td> |
| 364 <td>TODO: documentation link/a></td> |
| 365 <td></td> |
| 366 </tr> |
| 367 |
| 368 <tr> |
| 369 <td>Raw String Literals</td> |
| 370 <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> |
| 371 <td>Allows a string to be encoded without any escape |
| 372 sequences, easing parsing in regex expressions, for example</td> |
| 373 <td>TODO: documentation linkRaw String Literals</a></td> |
| 374 <td></td> |
| 375 </tr> |
| 376 |
| 377 <tr> |
| 378 <td>Rvalue References (and Move Semantics)</td> |
| 379 <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)</cod
e></td> |
| 380 <td>Reference that only binds to a temporary object</td> |
| 381 <td>TODO: documentation linkstruction and assignment</a></td> |
| 382 <td></td> |
| 383 </tr> |
| 384 |
| 385 <tr> |
| 386 <td>Static Assertions</td> |
| 387 <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td> |
| 388 <td>Tests compile-time conditions</td> |
| 389 <td><<a href="http://en.cppreference.com/w/cpp/language/static_assert">Static As
sertion</a></td> |
| 390 <td></td> |
| 391 </tr> |
| 392 |
| 393 <tr> |
| 394 <td>Union Class Members</td> |
| 395 <td><code>union <i>name</i> { <i>class</i> <i>var</i>}</code></td> |
| 396 <td>Allows class type members</td> |
| 397 <td><a href="http://en.cppreference.com/w/cpp/language/union"> |
| 398 Union declarations</a></td> |
| 399 <td></td> |
| 400 </tr> |
| 401 |
| 402 <tr> |
| 403 <td>User-Defined Literals</td> |
| 404 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
| 405 <td>Allows user-defined literal expressions</td> |
| 406 <td>TODO: documentation link</td> |
| 407 <td></td> |
| 408 </tr> |
| 409 |
| 410 <tr> |
| 411 <td>UTF-8 String Literals</td> |
| 412 <td><code>u8"<i>string</i>"</code></td> |
| 413 <td>Enforces UTF-8 encoding on all string literals</td> |
| 414 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal"> |
| 415 string literal</a></td> |
| 416 <td></td> |
| 417 </tr> |
| 418 |
| 419 <tr> |
| 420 <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td> |
| 421 <td><code>char16_t</code> and <code>char32_t</code></td> |
| 422 <td>Provides character types for handling 16-bit |
| 423 and 32-bit code units (useful for encoding |
| 424 UTF-16 and UTF-32 string data)</td> |
| 425 <td><a href="http://en.cppreference.com/w/cpp/language/types"> |
| 426 Fundamental types</a></td> |
| 427 <td>Non-UTF-8 text is banned by the |
| 428 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Non-AS
CII_Characters"> |
| 429 C++ Style Guide</a>. However, may be useful for |
| 430 consuming non-ASCII data.</td> |
| 431 </tr> |
| 432 |
| 433 |
| 434 <tr> |
| 435 <td>Variadic Macros</td> |
| 436 <td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code>
</td> |
| 437 <td>Allows macros that accept a variable number of arguments</td> |
| 438 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons
tandard"> |
| 439 Are Variadic macros nonstandard?</a></td> |
| 440 <td></td> |
| 441 </tr> |
| 442 |
| 443 <tr> |
| 444 <td>Variadic Templates</td> |
| 445 <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> |
| 446 <td>Allows templates that accept a variable number of arguments</td> |
| 447 <td>TODO: documentation link</td> |
| 448 <td></td> |
| 449 </tr> |
| 450 |
| 451 </tbody> |
| 452 </table> |
| 453 |
| 454 <h3 id="blacklist_stdlib">C++11 Standard Library features</h3> |
| 455 |
| 456 <details> |
| 457 |
| 458 <p><summary class="note">All C++11 <strong>Standard Library features are current
ly |
| 459 banned</strong>, because they are not supported on all of our toolchains yet. |
| 460 In particular, chromium/android is currently using STLport, and chromium/mac is |
| 461 currently using libstdc++4.2, which predate C++11. |
| 462 </summary></p> |
| 463 |
| 464 <table id="banned_stdlib" class="unlined striped"> |
| 465 |
| 466 <tbody> |
| 467 <tr> |
| 468 <th style='width:240px;'>Feature</th> |
| 469 <th style='width:240px;'>Snippet</th> |
| 470 <th style='width:240px;'>Description</th> |
| 471 <th style='width:240px;'>Documentation Link</th> |
| 472 <th style='width:240px;'>Style Guide Usage</th> |
| 473 </tr> |
| 474 |
| 475 <tr> |
| 476 <td>Address Retrieval</td> |
| 477 <td><code>std::addressof()</code></td> |
| 478 <td>Obtains the address of an object even with overloaded <code>operator&</c
ode></td> |
| 479 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</
a></td> |
| 480 <td>Usage should be rare as |
| 481 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Operat
or_Overloading"> |
| 482 Operator Overloading</a> is rare and <code>&s;</code> |
| 483 should suffice in most cases. May be preferable |
| 484 over <code>&s;</code> for performing object |
| 485 identity checks.</td> |
| 486 </tr> |
| 487 |
| 488 <tr> |
| 489 <td>Aligned Storage</td> |
| 490 <td><code>std::aligned_storage<Size, Align>::type</code></td> |
| 491 <td>Declare uninitialized storage having a specified alignment.</td> |
| 492 <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligne
d_storage</a></td> |
| 493 <td>Note: <code>std::aligned_storage</code> is allowed, but some other C++11 |
| 494 alignment features are still disallowed.</td> |
| 495 </tr> |
| 496 |
| 497 <tr> |
| 498 <td>Allocator Traits</td> |
| 499 <td><code>std::allocator_traits</code></td> |
| 500 <td>Provides an interface for accessing custom allocators</td> |
| 501 <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits"> |
| 502 std::allocator_traits</a></td> |
| 503 <td>Usage should be rare.</td> |
| 504 </tr> |
| 505 |
| 506 <tr> |
| 507 <td>Atomics</td> |
| 508 <td><code>std::atomic</code> and others in <code><atomic></code></td> |
| 509 <td>Fine-grained atomic types and operations</td> |
| 510 <td><a href="http://en.cppreference.com/w/cpp/atomic"><atomic></a></td> |
| 511 <td></td> |
| 512 </tr> |
| 513 |
| 514 <tr> |
| 515 <td>Arrays</td> |
| 516 <td><code>std::array</code></td> |
| 517 <td>A fixed-size replacement for built-in arrays, with STL support</td> |
| 518 <td><a href="http://en.cppreference.com/w/cpp/container/array"> |
| 519 std::array</a></td> |
| 520 <td></td> |
| 521 </tr> |
| 522 |
| 523 <tr> |
| 524 <td>Begin and End Non-Member Functions</td> |
| 525 <td><code>std::begin()</code> and <code>std::end()</code></td> |
| 526 <td>Allows use of free functions on any container, including |
| 527 built-in arrays</td> |
| 528 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin"> |
| 529 std::begin</a> and |
| 530 <a href="http://en.cppreference.com/w/cpp/iterator/end"> |
| 531 std::end</a></td> |
| 532 <td>Useful for built-in arrays.</td> |
| 533 </tr> |
| 534 |
| 535 <tr> |
| 536 <td>Bind Operations</td> |
| 537 <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
| 538 <td>Declares a function object bound to certain arguments</td> |
| 539 <td>TODO: documentation link</td> |
| 540 <td></td> |
| 541 </tr> |
| 542 |
| 543 <tr> |
| 544 <td>C Floating-Point Environment</td> |
| 545 <td><code><cfenv></code></td> |
| 546 <td>Provides floating point status flags and control modes for C-compatible code
</td> |
| 547 <td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library hea
der <cfenv></a></td> |
| 548 <td>Compilers do not support use</td> |
| 549 </tr> |
| 550 |
| 551 <tr> |
| 552 <td>Chrono Library</td> |
| 553 <td><code><chrono></code></td> |
| 554 <td>Provides a standard date and time library</td> |
| 555 <td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a
></td> |
| 556 <td></td> |
| 557 </tr> |
| 558 |
| 559 <tr> |
| 560 <td>Complex Inverse Trigonometric and Hyperbolic Functions</td> |
| 561 <td>Functions within <code><complex></code></td> |
| 562 <td>Adds inverse trigonomentric and hyperbolic non-member functions to |
| 563 the <code><complex></code> library.</td> |
| 564 <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a><
/td> |
| 565 <td></td> |
| 566 </tr> |
| 567 |
| 568 <tr> |
| 569 <td>Conditional Type Selection</td> |
| 570 <td><code>std::enable_if</code> and <code>std::conditional</code></td> |
| 571 <td>Enables compile-time conditional type selection</td> |
| 572 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if"> |
| 573 std::enable_if</a> and |
| 574 <a href="http://en.cppreference.com/w/cpp/types/conditional"> |
| 575 conditional</a></td> |
| 576 <td></td> |
| 577 </tr> |
| 578 |
| 579 <tr> |
| 580 <td>Constant Iterator Methods on Containers</td> |
| 581 <td><code>std::cbegin()</code> and <code>std::cend()</code></td> |
| 582 <td>Enforces iteration methods that don't change container contents</td> |
| 583 <td>TODO: documentation link</td> |
| 584 <td></td> |
| 585 </tr> |
| 586 |
| 587 <tr> |
| 588 <td>Construct Elements in Containers</td> |
| 589 <td><code>emplace()</code>,<code>emplace_back()</code>, |
| 590 <code>emplace_front()</code>, <code>emplace_hint()</code></td> |
| 591 <td>Constructs elements directly within a container without a copy |
| 592 or a move</td> |
| 593 <td>TODO: documentation link</td> |
| 594 <td>Use where element construction within a container |
| 595 is needed.</td> |
| 596 </tr> |
| 597 |
| 598 <tr> |
| 599 <td>Container Compaction Functions</td> |
| 600 <td><code>std::vector::shrink_to_fit()</code>, |
| 601 <code>std::deque::shrink_to_fit()</code>, and |
| 602 <code>std::string::shrink_to_fit()</code></td> |
| 603 <td>Requests the removal of unused space |
| 604 in the container</td> |
| 605 <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit"> |
| 606 std::vector::shrink_to_fit</a>, |
| 607 <a href="http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit"> |
| 608 std::deque::shrink_to_fit</a>, and |
| 609 <a href="http://en.cppreference.com/w/cpp/string/basic_string/shrink_to_fit"> |
| 610 std::basic_string::shrink_to_fit</a></td> |
| 611 <td></td> |
| 612 </tr> |
| 613 |
| 614 <tr> |
| 615 <td>Date/Time String Formatting Specifiers</td> |
| 616 <td><code>std::strftime()</code></td> |
| 617 <td>Converts date and time information into a |
| 618 formatted string using new specifiers</td> |
| 619 <td><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime"> |
| 620 std::strftime</a></td> |
| 621 <td></td> |
| 622 </tr> |
| 623 |
| 624 <tr> |
| 625 <td>Function Return Type Deduction</td> |
| 626 <td><code>std::result_of<<i>Functor(ArgTypes...)</i>></code></td> |
| 627 <td>Extracts the return type from the type signature of |
| 628 a function call invocation at compile-time.</td> |
| 629 <td><a href="http://en.cppreference.com/w/cpp/types/result_of"> |
| 630 std::result_of</a></td> |
| 631 <td> |
| 632 <a href="http://stackoverflow.com/questions/15486951/why-does-stdresult-of-take-
an-unrelated-function-type-as-a-type-argument"> |
| 633 Why does std::result_of take an (unrelated) function type as a type argument? |
| 634 </a></td> |
| 635 </tr> |
| 636 |
| 637 <tr> |
| 638 <td>Function Objects</td> |
| 639 <td><code>std::function</code></td> |
| 640 <td>Wraps a standard polymorphic function</td> |
| 641 <td>TODO: documentation link</td> |
| 642 <td></td> |
| 643 </tr> |
| 644 |
| 645 <tr> |
| 646 <td>Forward Lists</td> |
| 647 <td><code>std::forward_list</code></td> |
| 648 <td>Provides an efficient singly linked list</td> |
| 649 <td><a href="http://en.cppreference.com/w/cpp/container/forward_list"> |
| 650 std::forward_list</a></td> |
| 651 <td></td> |
| 652 </tr> |
| 653 |
| 654 <tr> |
| 655 <td>Gamma Natural Log</td> |
| 656 <td><code>std::lgamma()</code></td> |
| 657 <td>Computes the natural log of the gamma of a |
| 658 floating point value</td> |
| 659 <td><a href="http://en.cppreference.com/w/cpp/numeric/math/lgamma"> |
| 660 std::lgamma</a></td> |
| 661 <td></td> |
| 662 </tr> |
| 663 |
| 664 <tr> |
| 665 <td>Garbage Collection Features</td> |
| 666 <td><code>std::{un}declare_reachable()</code> and |
| 667 <code>std::{un}declare_no_pointers()</code></td> |
| 668 <td>Enables garbage collection implementations</td> |
| 669 <td><a href="http://en.cppreference.com/w/cpp/memory/gc/declare_reachable"> |
| 670 std::declare_reachable</a> |
| 671 and <a href="http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers"> |
| 672 std::declare_no_pointers</a></td> |
| 673 <td></td> |
| 674 </tr> |
| 675 |
| 676 <tr> |
| 677 <td>Heap Validation</td> |
| 678 <td><code>std::is_heap()</code></td> |
| 679 <td>Checks whether an iterator range is in fact a heap</td> |
| 680 <td>TODO: documentation link</td> |
| 681 <td></td> |
| 682 </tr> |
| 683 |
| 684 <tr> |
| 685 <td>Is Nan</td> |
| 686 <td><code>std::isnan()</code></td> |
| 687 <td>Determines if a floating point value is not-a-number</td> |
| 688 <td><a href="http://en.cppreference.com/w/cpp/numeric/math/isnan">std::isnan</a>
</td> |
| 689 <td></td> |
| 690 </tr> |
| 691 |
| 692 <tr> |
| 693 <td>Iterator Operators</td> |
| 694 <td><code>std::next()</code> and <code>std::prev()</code></td> |
| 695 <td>Copies an iterator and increments or decrements the copy by |
| 696 some value</td> |
| 697 <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a> |
| 698 and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> |
| 699 </td> |
| 700 <td></td> |
| 701 </tr> |
| 702 |
| 703 <tr> |
| 704 <td>Initializer Lists</td> |
| 705 <td><code>std::initializer_list<T></code></td> |
| 706 <td>Allows containers to be initialized with aggregate elements</td> |
| 707 <td><a href="http://go/totw:58"> |
| 708 Tip of the Week #58: Initializer Lists and the Uniform Initialization Syntax</a>
</td> |
| 709 <td></td> |
| 710 </tr> |
| 711 |
| 712 <tr> |
| 713 <td>Move Semantics</td> |
| 714 <td><code>std::move()</code></td> |
| 715 <td>Facilitates efficient move operations</td> |
| 716 <td><a href="http://en.cppreference.com/w/cpp/utility/move"> |
| 717 <code>std::move</code> reference</a></td> |
| 718 <td></td> |
| 719 </tr> |
| 720 |
| 721 <tr> |
| 722 <td>Pointer Traits Class Template</td> |
| 723 <td><code>std::pointer_traits</code></td> |
| 724 <td>Provides a standard way to access properties |
| 725 of pointers and pointer-like types</td> |
| 726 <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits"> |
| 727 std::pointer_traits</a></td> |
| 728 <td>Useful for determining the element type |
| 729 pointed at by a (possibly smart) pointer.</td> |
| 730 </tr> |
| 731 |
| 732 <tr> |
| 733 <td>Random Number Generators</td> |
| 734 <td>Functions within <code><random></code></td> |
| 735 <td>Random number generation algorithms and utilities</td> |
| 736 <td><a href="http://en.cppreference.com/w/cpp/numeric/random"> |
| 737 Pseudo-random number generation</a></td> |
| 738 <td></td> |
| 739 </tr> |
| 740 |
| 741 <tr> |
| 742 <td>Ratio Template Class</td> |
| 743 <td><code>std::ratio<<i>numerator</i>, <i>denominator</i>></code></td> |
| 744 <td>Provides compile-time rational numbers</td> |
| 745 <td>TODO: documentation link</td> |
| 746 <td></td> |
| 747 </tr> |
| 748 |
| 749 <tr> |
| 750 <td>Reference Wrapper Classes</td> |
| 751 <td><code>std::reference_wrapper</code> and |
| 752 <code>std::ref()</code>, <code>std::cref()</code></td> |
| 753 <td>Allows you to wrap a reference within a standard |
| 754 object (and use those within containers)</td> |
| 755 <td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=
217"> |
| 756 Reference Wrappers</a></td> |
| 757 <td></td> |
| 758 </tr> |
| 759 |
| 760 <tr> |
| 761 <td>Regex Library</td> |
| 762 <td><code><regex></code></td> |
| 763 <td>Provides a standard regular expressions library</td> |
| 764 <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library
</a></td> |
| 765 <td></td> |
| 766 </tr> |
| 767 |
| 768 <tr> |
| 769 <td>Shared Pointers</td> |
| 770 <td><code>std::shared_ptr</code></td> |
| 771 <td>Allows shared ownership of a pointer through reference counts</td> |
| 772 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr
</a></td> |
| 773 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ow
nership_and_Smart_Pointers"> |
| 774 Ownership and Smart Pointers</a></td> |
| 775 </tr> |
| 776 |
| 777 <tr> |
| 778 <td>Soft Program Exits</td> |
| 779 <td><code>std::at_quick_exit()</code> |
| 780 and <code>std::quick_exit()</code></td> |
| 781 <td>Allows registration of functions to be called upon exit, |
| 782 allowing cleaner program exit than <code>abort()</code> or |
| 783 <code>exit</code></td> |
| 784 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit"> |
| 785 std:quick_exit</a></td> |
| 786 <td></td> |
| 787 </tr> |
| 788 |
| 789 <tr> |
| 790 <td>String Direct Reference Functions</td> |
| 791 <td><code>std::string::front()</code> and <code>std::string::back()</code></td> |
| 792 <td>Returns a reference to the front or back of a string</td> |
| 793 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front"> |
| 794 std::basic_string::front</a> and |
| 795 <a href="http://en.cppreference.com/w/cpp/string/basic_string/back"> |
| 796 std::basic_string::back</a></td> |
| 797 <td></td> |
| 798 </tr> |
| 799 |
| 800 <tr> |
| 801 <td>String to Number Functions</td> |
| 802 <td><code>std::stoi()</code>, <code>std::stol()</code>, |
| 803 <code>std::stoul()</code>, <code>std::stoll</code>, <code>std::stoull()</code>, |
| 804 <code>std::stof()</code>, <code>std::stod()</code>, <code>std::stold()</code>, |
| 805 and <code>std::to_string()</code></td> |
| 806 <td>Converts strings to numbers</td> |
| 807 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol"> |
| 808 std::stoi, std::stol, std::stoll</a>, |
| 809 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stoul"> |
| 810 std::stoul, std::stoull</a>, and |
| 811 <a href="http://en.cppreference.com/w/cpp/string/basic_string/stof"> |
| 812 std::stof, std::stod, std::stold</a> </td> |
| 813 <td></td> |
| 814 </tr> |
| 815 |
| 816 <tr> |
| 817 <td>STL Algorithms</td> |
| 818 <td>Functions within <code><algorithm></code>.</td> |
| 819 <td>Enhancements to the set of STL algorithms</td> |
| 820 <td><a href="http://go/totw:21"> |
| 821 Tip of the Week #21: New C++11 STL Algorithms</a>. See |
| 822 the <a href="http://en.cppreference.com/w/cpp/algorithm"> |
| 823 Algorithms library</a> for a complete list.</td> |
| 824 <td></td> |
| 825 </tr> |
| 826 |
| 827 <tr> |
| 828 <td>System Errors</td> |
| 829 <td><code><system_error></code></td> |
| 830 <td>Provides a standard system error library</td> |
| 831 <td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_er
ror</a></td> |
| 832 <td></td> |
| 833 </tr> |
| 834 |
| 835 <tr> |
| 836 <td>Trailing Return Types</td> |
| 837 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> |
| 838 <td>Allows trailing function return value syntax</td> |
| 839 <td><a href="http://en.cppreference.com/w/cpp/language/function"> |
| 840 Declaring functions</a></td> |
| 841 <td></td> |
| 842 </tr> |
| 843 |
| 844 <tr> |
| 845 <td>Thread Library</td> |
| 846 <td><code><thread> support, including <future>, |
| 847 <mutex>, <condition_variable></code></td> |
| 848 <td>Provides a standard mulitthreading library using <code>std::thread</code> an
d associates</td> |
| 849 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a>
</td> |
| 850 <td></td> |
| 851 </tr> |
| 852 |
| 853 <tr> |
| 854 <td>Tuples</td> |
| 855 <td><code>std::tuple</code></td> |
| 856 <td>A fixed-size ordered collection of values of mixed types</td> |
| 857 <td>TODO: documentation link</td> |
| 858 <td></td> |
| 859 </tr> |
| 860 |
| 861 <tr> |
| 862 <td>Type-Generic Math Functions</td> |
| 863 <td>Functions within <code><ctgmath></code></td> |
| 864 <td>Provides a means to call real or complex functions |
| 865 based on the type of arguments</td> |
| 866 <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath"> |
| 867 Standard library header <ctgmath></a></td> |
| 868 <td></td> |
| 869 </tr> |
| 870 |
| 871 <tr> |
| 872 <td>Type Info Enhancements</td> |
| 873 <td><code>std::type_index</code> and <code>std::type_info::hash_code()</code></t
d> |
| 874 <td>Allows type information (most often within containers) |
| 875 that can be copied, assigned, or hashed</td> |
| 876 <td><a href="http://en.cppreference.com/w/cpp/types/type_index"> |
| 877 std::type_index</a> and |
| 878 <a href="http://en.cppreference.com/w/cpp/types/type_info/hash_code"> |
| 879 std::type_info::hash_code</a></td> |
| 880 <td><code>std::type_index</code> is a thin wrapper for |
| 881 <code>std::type_info</code>, allowing you to use it directly |
| 882 within both associative and unordered containers</td> |
| 883 </tr> |
| 884 |
| 885 <tr> |
| 886 <td>Type Traits</td> |
| 887 <td>Class templates within <code><type_traits></code></td> |
| 888 <td>Allows compile-time inspection of the properties of types</td> |
| 889 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits"> |
| 890 Standard library header <type_traits></a></td> |
| 891 <td></td> |
| 892 </tr> |
| 893 |
| 894 <tr> |
| 895 <td>Unique Pointers</td> |
| 896 <td><code>std::unique_ptr<<i>type</i>></code></td> |
| 897 <td>Defines a pointer with clear and unambiguous ownership</td> |
| 898 <td>TODO: documentation link</td> |
| 899 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ow
nership_and_Smart_Pointers"> |
| 900 Ownership and Smart Pointers</a></td> |
| 901 </tr> |
| 902 |
| 903 <tr> |
| 904 <td>Unordered Associative Containers</td> |
| 905 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, |
| 906 <code>std::unordered_multiset</code>, and <code>std::unordered_multimap</code></
td> |
| 907 <td>Allows efficient containers of key/value pairs</td> |
| 908 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor
dered_map</a> |
| 909 and <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unor
dered_set</a> |
| 910 </td> |
| 911 <td></td> |
| 912 </tr> |
| 913 |
| 914 <tr> |
| 915 <td>Variadic Copy Macro</td> |
| 916 <td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> |
| 917 <td>Makes a copy of the variadic function arguments</td> |
| 918 <td></td> |
| 919 <td></td> |
| 920 </tr> |
| 921 |
| 922 <tr> |
| 923 <td>Weak Pointers</td> |
| 924 <td><code>std::weak_ptr</code></td> |
| 925 <td>Allows a weak reference to a <code>std::shared_ptr</code></td> |
| 926 <td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr"> |
| 927 std::weak_ptr</a></td> |
| 928 <td><a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ow
nership_and_Smart_Pointers"> |
| 929 Ownership and Smart Pointers</a></td> |
| 930 </tr> |
| 931 |
| 932 <tr> |
| 933 <td>Wide String Support</td> |
| 934 <td><code>std::wstring_convert</code>, |
| 935 <code>std::wbuffer_convert</code>. |
| 936 <code>std::codecvt_utf8</code>, <code>std::codecvt_utf16</code>, |
| 937 and <code>std::codecvt_utf8_utf16</code></td> |
| 938 <td>Converts between string encodings</td> |
| 939 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert"> |
| 940 std::wstring_convert</a>, |
| 941 <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert"> |
| 942 std::wbuffer_convert</a>, |
| 943 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf8"> |
| 944 std::codecvt_utf8</a>, |
| 945 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf16"> |
| 946 std::codecvt_utf16</a>, and |
| 947 <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf8_utf16"> |
| 948 std::codecvt_utf8_utf16</a> |
| 949 </td> |
| 950 <td>Non-UTF-8 text is banned by the |
| 951 <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Non-AS
CII_Characters"> |
| 952 C++ Style Guide</a>. However, may be useful for |
| 953 consuming non-ASCII data.</td> |
| 954 </tr> |
| 955 |
| 956 </tbody> |
| 957 </table> |
| 958 |
| 959 </details> |
| 960 |
| 961 </div> |
| 962 </body> |
| 963 </html> |
OLD | NEW |