Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 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"> |
bratell | 85e14ac | 2014-12-17 17:26:38 | [diff] [blame] | 10 | <title>C++11 use in Chromium</title> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 11 | <link rel="stylesheet" href="c++11.css"> |
| 12 | <style> |
| 13 | table tbody tr td:first-child { |
| 14 | font-weight: bold; |
| 15 | font-size: 110%; |
| 16 | } |
| 17 | </style> |
| 18 | </head> |
| 19 | <body> |
| 20 | <div id="content"> |
| 21 | <h1>C++11 use in Chromium</h1> |
| 22 | |
| 23 | <p><i>This document lives at src/styleguide/c++/c++11.html in a Chromium |
| 24 | checkout.</i></p> |
| 25 | |
| 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 |
| 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 |
| 30 | more restrictive if they need to compile on more toolchains than Chromium.</p> |
| 31 | |
brettw | 196290a | 2016-07-07 03:52:16 | [diff] [blame] | 32 | <p>This page comprises part of the more general |
| 33 | <a href="https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md">Chromium C++ style guide</a>.</p> |
| 34 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 35 | <p>You can propose to make a feature available or to ban a |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 36 | feature by sending an email to <a |
| 37 | href="https://groups.google.com/a/chromium.org/forum/#!forum/cxx">[email protected]</a>. |
| 38 | Ideally include a short blurb on what the feature is, and why you think it |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 39 | should or should not be allowed. Ideally, the list will arrive at some |
brettw | 196290a | 2016-07-07 03:52:16 | [diff] [blame] | 40 | consensus and you can request review for a change to this file. If |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 41 | there's no consensus, <code>src/styleguide/c++/OWNERS</code> get to decide -- |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 42 | for divisive features, we expect the decision to be to not use the feature yet |
| 43 | and possibly discuss it again a few months later, when we have more experience |
| 44 | with the language.</p> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 45 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 46 | <h2>Table of Contents</h2> |
| 47 | <ol class="toc"> |
| 48 | <li>Allowed Features<ol> |
| 49 | <li><a href="#core-whitelist">Language</a></li> |
| 50 | <li><a href="#library-whitelist">Library</a></li> |
| 51 | </ol></li> |
| 52 | <li>Banned Features<ol> |
| 53 | <li><a href="#core-blacklist">Language</a></li> |
| 54 | <li><a href="#library-blacklist">Library</a></li> |
| 55 | </ol></li> |
| 56 | <li>To Be Discussed<ol> |
| 57 | <li><a href="#core-review">Language</a></li> |
| 58 | <li><a href="#library-review">Library</a></li> |
| 59 | </ol></li> |
| 60 | </ol> |
| 61 | |
| 62 | <h2 id="whitelist"><a name="core-whitelist"></a>C++11 Allowed Features</h2> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 63 | |
| 64 | <p>The following features are currently allowed.</p> |
| 65 | |
| 66 | <table id="whitelist_lang_list" class="unlined striped"> |
| 67 | <tbody> |
| 68 | |
| 69 | <tr> |
| 70 | <th style='width:220px;'>Feature</th> |
| 71 | <th style='width:260px;'>Snippet</th> |
| 72 | <th style='width:240px;'>Description</th> |
| 73 | <th style='width:240px;'>Documentation Link</th> |
| 74 | <th style='width:240px;'>Notes and Discussion Thread</th> |
| 75 | </tr> |
| 76 | |
| 77 | <tr> |
pkasting | f527948 | 2016-07-27 02:18:20 | [diff] [blame] | 78 | <td>__func__ Local Variable</td> |
| 79 | <td><code>__func__</code></td> |
| 80 | <td>Provides a local variable containing the name of the enclosing function</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 81 | <td><a href="http://en.cppreference.com/w/cpp/language/function#func">__func__</a></td> |
pkasting | f527948 | 2016-07-27 02:18:20 | [diff] [blame] | 82 | <td>Use instead of the non-standard <code>__FUNCTION__</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discussion thread</a></td> |
| 83 | </tr> |
| 84 | |
| 85 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 86 | <td>Angle Bracket Parsing in Templates</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 87 | <td><code>>></code> for <code>> ></code>, <code><::</code> for <code>< ::</code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 88 | <td>More intuitive parsing of template parameters</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 89 | <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brackets-pitfall-what-is-the-c11-fix">C++ templates angle brackets pitfall</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 90 | <td>Recommended to increase readability. Approved without discussion.</td> |
| 91 | </tr> |
| 92 | |
| 93 | <tr> |
ericrk | 491cd20 | 2015-12-01 01:09:16 | [diff] [blame] | 94 | <td>Arrays</td> |
| 95 | <td><code>std::array</code></td> |
| 96 | <td>A fixed-size replacement for built-in arrays, with STL support</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 97 | <td><a href="http://en.cppreference.com/w/cpp/container/array">std::array</a></td> |
ericrk | 491cd20 | 2015-12-01 01:09:16 | [diff] [blame] | 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 and is more widely used. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/pVRQCRWHEU8">Discussion thread</a>.</td> |
| 99 | </tr> |
| 100 | |
| 101 | <tr> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 102 | <td>Automatic Types</td> |
| 103 | <td><code>auto</code></td> |
| 104 | <td>Automatic type deduction</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 105 | <td><a href="http://en.cppreference.com/w/cpp/language/auto">auto specifier</a></td> |
| 106 | <td><a href="https://google.github.io/styleguide/cppguide.html#auto">Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.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> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 107 | </tr> |
| 108 | |
| 109 | <tr> |
pkasting | ce246fa | 2016-04-14 17:54:08 | [diff] [blame] | 110 | <td>Constant Expressions</td> |
| 111 | <td><code>constexpr</code></td> |
| 112 | <td>Compile-time constant expressions</td> |
| 113 | <td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr specifier</a></td> |
| 114 | <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://google.github.io/styleguide/cppguide.html#Use_of_constexpr">Google Style Guide</a></td> |
| 115 | </tr> |
| 116 | |
| 117 | <tr> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 118 | <td>Declared Type Accessor</td> |
| 119 | <td><code>decltype(<i>expression</i>)</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 120 | <td>Provides a means to determine the type of an expression at compile-time, useful most often in templates.</td> |
| 121 | <td><a href="http://en.cppreference.com/w/cpp/language/decltype">decltype specifier</a></td> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 122 | <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td> |
| 123 | </tr> |
| 124 | |
| 125 | <tr> |
mdempsky | 2319bef | 2014-11-07 05:25:12 | [diff] [blame] | 126 | <td>Default Function Creation</td> |
| 127 | <td><code><i>Function</i>(<i>arguments</i>) = default;</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 128 | <td>Instructs the compiler to generate a default version of the indicated function</td> |
| 129 | <td><a href="http://stackoverflow.com/questions/823935/whats-the-point-in-defaulting-functions-in-c11">What's the point in defaulting functions in C++11?</a></td> |
| 130 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/qgU4mh_MpGA">Discussion thread</a></td> |
mdempsky | 2319bef | 2014-11-07 05:25:12 | [diff] [blame] | 131 | </tr> |
| 132 | |
| 133 | <tr> |
vmpstr | fcdc338e | 2015-12-09 19:51:08 | [diff] [blame] | 134 | <td>Default Function Template Arguments</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 135 | <td><code>template <typename T = <i>type</i>><br /> |
| 136 | <i>type</i> <i>Function</i>(T <i>var</i>) {}</code></td> |
vmpstr | fcdc338e | 2015-12-09 19:51:08 | [diff] [blame] | 137 | <td>Allow function templates, like classes, to have default arguments</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 138 | <td><a href="http://stackoverflow.com/questions/2447458/default-template-arguments-for-function-templates">Default Template Arguments for Function Templates</a></td> |
vmpstr | fcdc338e | 2015-12-09 19:51:08 | [diff] [blame] | 139 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/9KtaAsome-o">Discussion thread</a></td> |
| 140 | </tr> |
| 141 | |
| 142 | <tr> |
andersr | 127772e | 2014-11-07 17:02:52 | [diff] [blame] | 143 | <td>Delegated Constructors</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 144 | <td><code>Class() : Class(0) {}<br /> |
| 145 | Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0) {}</code></td> |
andersr | 127772e | 2014-11-07 17:02:52 | [diff] [blame] | 146 | <td>Allow overloaded constructors to use common initialization code</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 147 | <td><a href="https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/introduction_to_the_c_11_feature_delegating_constructors?lang=en">Introduction to the C++11 feature: delegating constructors</a></td> |
andersr | 127772e | 2014-11-07 17:02:52 | [diff] [blame] | 148 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/0zVA8Ctx3Xo">Discussion thread</a></td> |
| 149 | </tr> |
| 150 | |
| 151 | <tr> |
thakis | b8fbe31 | 2014-10-29 01:30:42 | [diff] [blame] | 152 | <td>Enumerated Type Classes and Enum Bases</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 153 | <td><code>enum class <i>classname</i><br /> |
| 154 | enum class <i>classname</i> : <i>base-type</i><br /> |
| 155 | enum <i>enumname</i> : <i>base-type</i></code></td> |
| 156 | <td>Provide enums as full classes, with no implicit conversion to booleans or integers. Provide an explicit underlying type for enum classes and regular enums.</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 157 | <td><a href="http://en.cppreference.com/w/cpp/language/enum">enumeration declaration</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 158 | <td>Enum classes are still enums and follow enum naming rules (which means SHOUTY_CASE in the <a href="http://www.chromium.org/developers/coding-style#Naming">Chromium Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/Q5WmkAImanc">Discussion thread</a></td> |
mdempsky | 4f2d410 | 2014-10-20 17:31:27 | [diff] [blame] | 159 | </tr> |
| 160 | |
| 161 | <tr> |
jbroman | e18d3148 | 2016-04-13 18:06:47 | [diff] [blame] | 162 | <td>Explicit Conversion Operators</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 163 | <td><code>explicit operator <i>type</i>() { ... }</code></td> |
jbroman | e18d3148 | 2016-04-13 18:06:47 | [diff] [blame] | 164 | <td>Allows conversion operators that cannot be implicitly invoked</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 165 | <td><a href="http://en.cppreference.com/w/cpp/language/explicit">explicit specifier</a></td> |
jbroman | e18d3148 | 2016-04-13 18:06:47 | [diff] [blame] | 166 | <td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromium.org/d/msg/chromium-dev/zGF1SrQ-1HQ/BAiC12vwPeEJ">Discussion thread</a></td> |
| 167 | </tr> |
| 168 | |
| 169 | <tr> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 170 | <td>Final Specifier</td> |
| 171 | <td><code>final</code></td> |
| 172 | <td> Indicates that a class or function is final and cannot be overridden</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 173 | <td><a href="http://en.cppreference.com/w/cpp/language/final">final specifier</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 174 | <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 175 | </tr> |
| 176 | |
| 177 | <tr> |
mdempsky | 2319bef | 2014-11-07 05:25:12 | [diff] [blame] | 178 | <td>Function Suppression</td> |
| 179 | <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 180 | <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 181 | <td><a href="http://en.cppreference.com/w/cpp/language/function#Deleted_functions">Deleted functions</a></td> |
mdempsky | 2319bef | 2014-11-07 05:25:12 | [diff] [blame] | 182 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/i1o7-RNRnMs">Discussion thread</a></td> |
| 183 | </tr> |
| 184 | |
| 185 | <tr> |
thakis | a907c31 | 2014-11-04 23:38:06 | [diff] [blame] | 186 | <td>Lambda Expressions</td> |
| 187 | <td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</code></td> |
| 188 | <td>Anonymous functions</td> |
| 189 | <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td> |
scheib | ea2f9d51 | 2016-09-30 21:01:26 | [diff] [blame] | 190 | <td>Do not bind or store capturing lambdas outside the lifetime of the stack frame they are defined in. Captureless lambdas can be used with <code>base::Callback</code>, such as <code>base::Bind([](int j){}, i);</code>, because they offer protection against a large class of object lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&]</code> – <a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. |
| 191 | </td> |
thakis | a907c31 | 2014-11-04 23:38:06 | [diff] [blame] | 192 | </tr> |
| 193 | |
| 194 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 195 | <td>Local Types as Template Arguments</td> |
pkasting | 0fcb776 | 2016-04-29 00:44:37 | [diff] [blame] | 196 | <td><code>void func() {<br /> |
| 197 | class Pred {<br /> |
| 198 | public:<br /> |
| 199 | bool operator()(const T&) { ... }<br /> |
| 200 | };<br /> |
| 201 | std::remove_if(vec.begin(), vec.end(), Pred());</code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 202 | <td>Allows local and unnamed types as template arguments</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 203 | <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> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 204 | <td>Usage should be rare. Approved without discussion.</td> |
| 205 | </tr> |
| 206 | |
| 207 | <tr> |
pkasting | c6a6ebf1 | 2016-10-31 20:38:40 | [diff] [blame^] | 208 | <td>Noexcept Specifier</td> |
| 209 | <td><code>void f() noexcept</code></td> |
| 210 | <td>Specifies that a function will not throw exceptions</td> |
| 211 | <td><a href="http://en.cppreference.com/w/cpp/language/noexcept_spec">noexcept specifier</a></td> |
| 212 | <td>Chromium compiles without exception support, but there are still cases where explicitly marking a function as <code>noexcept</code> may be necessary to compile, or for performance reasons. Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a></td> |
| 213 | </tr> |
| 214 | |
| 215 | <tr> |
hashimoto | 42a14e86 | 2015-01-22 15:21:41 | [diff] [blame] | 216 | <td>Non-Static Class Member Initializers</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 217 | <td><code>class C {<br /> |
| 218 | <i>type</i> <i>var</i> = <i>value</i>;<br /> |
| 219 | C() // copy-initializes <i>var</i></code> |
hashimoto | 42a14e86 | 2015-01-22 15:21:41 | [diff] [blame] | 220 | <td>Allows non-static class members to be initialized at their definitions (outside constructors)</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 221 | <td><a href="http://en.cppreference.com/w/cpp/language/data_members">Non-static data members</a></td> |
| 222 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB-DySA4V0">Discussion thread</a></td> |
hashimoto | 42a14e86 | 2015-01-22 15:21:41 | [diff] [blame] | 223 | </tr> |
| 224 | |
| 225 | <tr> |
danakj | 8bc9fc1 | 2014-09-24 20:45:29 | [diff] [blame] | 226 | <td>Null Pointer Constant</td> |
| 227 | <td><code>nullptr</code></td> |
| 228 | <td>Declares a type-safe null pointer</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 229 | <td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr, the pointer literal</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 230 | <td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread</a>. <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/NULL">Google Style Guide</a>. <code>std::nullptr_t</code> can be used too.</td> |
danakj | 8bc9fc1 | 2014-09-24 20:45:29 | [diff] [blame] | 231 | </tr> |
| 232 | |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 233 | <tr> |
| 234 | <td>Override Specifier</td> |
| 235 | <td><code>override</code></td> |
| 236 | <td>Indicates that a class or function overrides a base implementation</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 237 | <td><a href="http://en.cppreference.com/w/cpp/language/override">override specifier</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 238 | <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 239 | </tr> |
| 240 | |
| 241 | <tr> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 242 | <td>Range-Based For Loops</td> |
| 243 | <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 244 | <td>Facilitates a more concise syntax for iterating over the elements of a container (or a range of iterators) in a <code>for</code> loop</td> |
| 245 | <td><a href="http://en.cppreference.com/w/cpp/language/range-for">Range-based for loop</a></td> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 246 | <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/chromium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread</a></td> |
| 247 | </tr> |
| 248 | |
| 249 | <tr> |
danakj | 2c5aee9 | 2015-12-07 20:40:27 | [diff] [blame] | 250 | <td>Rvalue References</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 251 | <td><code>T(T&& t)</code> and <code>T& operator=(T&& t)<br/><br/> |
| 252 | template <typename T><br/>void Function(T&& t) { ... }</code></td> |
danakj | 2c5aee9 | 2015-12-07 20:40:27 | [diff] [blame] | 253 | <td>Reference that only binds to a temporary object</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 254 | <td><a href="http://en.cppreference.com/w/cpp/language/reference#Rvalue_references">Rvalue references</a></td> |
dcheng | 1a2fd6cd | 2016-06-07 21:39:12 | [diff] [blame] | 255 | <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 not be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN in most cases. <a href="https://groups.google.com/a/chromium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/Q526tkruXpM">Another discussion thread</a>.</td> |
danakj | 2c5aee9 | 2015-12-07 20:40:27 | [diff] [blame] | 256 | </tr> |
| 257 | |
| 258 | <tr> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 259 | <td>Standard Integers</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 260 | <td>Typedefs within <code><stdint.h></code> and <code><inttypes></code></td> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 261 | <td>Provides fixed-size integers independent of platforms</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 262 | <td><a href="http://en.cppreference.com/w/cpp/header/cstdint">Standard library header <cstdint></a></td> |
dcheng | 5f98d33 | 2014-09-24 22:12:10 | [diff] [blame] | 263 | <td>Already in common use in the codebase. Approved without discussion.</td> |
| 264 | </tr> |
| 265 | |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 266 | <tr> |
| 267 | <td>Static Assertions</td> |
| 268 | <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td> |
| 269 | <td>Tests compile-time conditions</td> |
| 270 | <td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Assertion</a></td> |
| 271 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/POISBQEhGzU">Discussion thread</a></td> |
| 272 | </tr> |
| 273 | |
| 274 | <tr> |
mikhail.pozdnyakov | bac79705 | 2016-05-16 15:48:10 | [diff] [blame] | 275 | <td>Trailing Return Types</td> |
| 276 | <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> |
| 277 | <td>Allows trailing function return value syntax</td> |
| 278 | <td><a href="http://en.cppreference.com/w/cpp/language/function">Declaring functions</a></td> |
| 279 | <td>Use only where it considerably improves readability. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/OQyYSfH9m2M">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/Lkp0nubVd0Q">Another discussion thread.</a></td> |
| 280 | </tr> |
| 281 | |
| 282 | <tr> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 283 | <td>Type Aliases ("using" instead of "typedef")</td> |
| 284 | <td><code>using <i>new_alias</i> = <i>typename</i></code></td> |
| 285 | <td>Allows parameterized typedefs</td> |
| 286 | <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias, alias template</a></td> |
| 287 | <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/8dOAMzgR4ao">Discussion thread</a></td> |
| 288 | </tr> |
| 289 | |
| 290 | <tr> |
pkasting | 0fcb776 | 2016-04-29 00:44:37 | [diff] [blame] | 291 | <td>Uniform Initialization Syntax</td> |
| 292 | <td><code><i>type</i> <i>name</i> {[<i>value</i> ..., <i>value</i>]};</code></td> |
| 293 | <td>Allows any object of primitive, aggregate or class type to be initialized using brace syntax</td> |
| 294 | <td><a href="http://www.stroustrup.com/C++11FAQ.html#uniform-init">Uniform initialization syntax and semantics</a></td> |
| 295 | <td>See the <a href="https://www.chromium.org/developers/coding-style/cpp-dos-and-donts?pli=1#TOC-Variable-initialization">Chromium C++ Dos And Don'ts guidance</a> on when to use this. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/GF96FshwHLw">Discussion thread</a></td> |
| 296 | </tr> |
| 297 | |
| 298 | <tr> |
kwiberg | 882859a | 2016-08-16 09:42:21 | [diff] [blame] | 299 | <td>Union Class Members</td> |
| 300 | <td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td> |
| 301 | <td>Allows class type members</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 302 | <td><a href="http://en.cppreference.com/w/cpp/language/union">Union declaration</a></td> |
kwiberg | 882859a | 2016-08-16 09:42:21 | [diff] [blame] | 303 | <td>Usage should be rare.</td> |
| 304 | </tr> |
| 305 | |
| 306 | <tr> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 307 | <td>Variadic Macros</td> |
| 308 | <td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code></td> |
| 309 | <td>Allows macros that accept a variable number of arguments</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 310 | <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nonstandard">Are Variadic macros nonstandard?</a></td> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 311 | <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> |
| 312 | </tr> |
| 313 | |
| 314 | <tr> |
| 315 | <td>Variadic Templates</td> |
| 316 | <td><code>template <<i>typename</i> ... <i>arg</i>></code></td> |
| 317 | <td>Allows templates that accept a variable number of arguments</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 318 | <td><a href="http://en.cppreference.com/w/cpp/language/parameter_pack">Parameter pack</a></td> |
avi | 906dbd5c | 2014-09-26 22:11:42 | [diff] [blame] | 319 | <td>Usage should be rare. Use instead of .pump files. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/6ItymeMXpMc">Discussion thread</a></td> |
Nico Weber | 3537d87 | 2014-09-25 19:10:04 | [diff] [blame] | 320 | </tr> |
| 321 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 322 | </tbody> |
| 323 | </table> |
| 324 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 325 | <h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Features</h2> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 326 | |
| 327 | <p>The following library features are currently allowed.</p> |
| 328 | |
| 329 | <table id="whitelist_lib_list" class="unlined striped"> |
| 330 | <tbody> |
| 331 | |
| 332 | <tr> |
| 333 | <th style='width:240px;'>Feature or Library</th> |
| 334 | <th style='width:240px;'>Snippet</th> |
| 335 | <th style='width:240px;'>Description</th> |
| 336 | <th style='width:240px;'>Documentation Link</th> |
| 337 | <th style='width:240px;'>Notes</th> |
| 338 | </tr> |
| 339 | |
| 340 | <tr> |
davidben | 4507eaa | 2015-11-19 19:07:06 | [diff] [blame] | 341 | <td>Access to underlying <code>std::vector</code> data</td> |
| 342 | <td><code>v.data()</code></td> |
| 343 | <td>Returns a pointer to a <code>std::vector</code>'s underlying data, accounting for empty vectors.</td> |
| 344 | <td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector::data</a></td> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 345 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtbzok">Discussion thread</a></td> |
davidben | 4507eaa | 2015-11-19 19:07:06 | [diff] [blame] | 346 | </tr> |
| 347 | |
| 348 | <tr> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 349 | <td>Algorithms</td> |
| 350 | <td>All C++11 features in <code><algorithm></code>:<br/> |
| 351 | <code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/> |
| 352 | <code>find_if_not</code><br/> |
| 353 | <code>copy_if</code>, <code>copy_n</code><br/> |
| 354 | <code>move</code>, <code>move_backward</code> (see note)<br/> |
| 355 | <code>shuffle</code><br/> |
| 356 | <code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point</code><br/> |
| 357 | <code>is_sorted</code>, <code>is_sorted_until</code><br/> |
| 358 | <code>is_heap</code>, <code>is_heap_until</code><br/> |
| 359 | <code>minmax</code>, <code>minmax_element</code><br/> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 360 | <code>is_permutation<br/></td> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 361 | <td>Safe and performant implementations of common algorithms</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 362 | <td><a href="http://en.cppreference.com/w/cpp/header/algorithm">Standard library header <algorithm></a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 363 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1IuHk">Discussion thread</a><br/> Note that <algorithm> contains a range-based <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 without it that is more readable. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 364 | </tr> |
| 365 | |
| 366 | <tr> |
ruuda | b425288a | 2015-11-23 21:46:57 | [diff] [blame] | 367 | <td>Begin and End Non-Member Functions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 368 | <td><code>std::begin()</code>, <code>std::end()</code></td> |
pkasting | a234a07 | 2016-02-11 01:35:53 | [diff] [blame] | 369 | <td>Allows use of free functions on any container, including fixed-size arrays</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 370 | <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> |
| 371 | <td>Useful for fixed-size arrays. Note that non-member <code>cbegin()</code> and <code>cend()</code> are not available until C++14. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td> |
ruuda | b425288a | 2015-11-23 21:46:57 | [diff] [blame] | 372 | </tr> |
| 373 | |
| 374 | <tr> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 375 | <td>Conditional Type Selection</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 376 | <td><code>std::enable_if</code>, <code>std::conditional</code></td> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 377 | <td>Enables compile-time conditional type selection</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 378 | <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> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 379 | <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td> |
| 380 | </tr> |
| 381 | |
| 382 | <tr> |
pkasting | a234a07 | 2016-02-11 01:35:53 | [diff] [blame] | 383 | <td>Constant Iterator Methods on Containers</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 384 | <td>E.g. <code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></td> |
pkasting | a234a07 | 2016-02-11 01:35:53 | [diff] [blame] | 385 | <td>Allows more widespread use of <code>const_iterator</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 386 | <td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vector::cbegin</a>, <a href="http://en.cppreference.com/w/cpp/container/vector/end">std::vector::cend<a></td> |
| 387 | <td>Applies to all containers, not just <code>vector</code>. Consider using <code>const_iterator</code> over <code>iterator</code> where possible for the same reason as using <code>const</code> variables and functions where possible; see Effective 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> |
pkasting | a234a07 | 2016-02-11 01:35:53 | [diff] [blame] | 388 | </tr> |
| 389 | |
| 390 | <tr> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 391 | <td>Containers containing move-only types</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 392 | <td><code>vector<scoped_ptr></code></td> |
| 393 | <td>Enables containers that contain move-only types like <code>scoped_ptr</code></td> |
| 394 | <td>TODO</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 395 | <td>Prefer over <a href="http://crbug.com/554289">ScopedVector</a>.</td> |
| 396 | </tr> |
| 397 | |
| 398 | <tr> |
| 399 | <td>Declared Type As Value</td> |
| 400 | <td><code>std::declval<<i>class</i>>()</code></td> |
| 401 | <td>Converts a type to a reference of the type to allow use of members of the type without constructing it in templates.</td> |
| 402 | <td><a href="http://en.cppreference.com/w/cpp/utility/declval">std::declval</a></td> |
| 403 | <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/ku6lYjk0-OU/discussion">Discussion thread</a></td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 404 | </tr> |
jsbell | a882f62 | 2015-11-13 02:02:14 | [diff] [blame] | 405 | |
| 406 | <tr> |
pkasting | 53121c4 | 2016-02-04 22:14:36 | [diff] [blame] | 407 | <td>Emplacement methods for containers</td> |
| 408 | <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</code>, <code>emplace_hint()</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 409 | <td>Constructs elements directly within a container without a copy or a move. Less verbose than <code>push_back()</code> due to not naming the type being constructed.</td> |
pkasting | 53121c4 | 2016-02-04 22:14:36 | [diff] [blame] | 410 | <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back">std::vector::emplace_back</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 411 | <td><code>std::map::emplace()</code> is not yet available on all libstdc++ versions 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 movable 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>; sometimes 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> |
pkasting | 53121c4 | 2016-02-04 22:14:36 | [diff] [blame] | 412 | </tr> |
| 413 | |
| 414 | <tr> |
davidben | 411d3f7 | 2016-01-22 01:41:41 | [diff] [blame] | 415 | <td>Forwarding references</td> |
| 416 | <td><code>std::forward()</code></td> |
| 417 | <td>Perfectly forwards arguments (including rvalues)</td> |
pkasting | 0fcb776 | 2016-04-29 00:44:37 | [diff] [blame] | 418 | <td><a href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 419 | <td>Allowed, though usage should be rare (primarily for forwarding constructor arguments, or in carefully reviewed library code). <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/-O7euklhSxs/discussion">Discussion thread</a> |
davidben | 411d3f7 | 2016-01-22 01:41:41 | [diff] [blame] | 420 | </td> |
| 421 | </tr> |
| 422 | |
| 423 | <tr> |
pkasting | 0fcb776 | 2016-04-29 00:44:37 | [diff] [blame] | 424 | <td>Initializer Lists</td> |
| 425 | <td><code>std::initializer_list<T></code></td> |
| 426 | <td>Allows containers to be initialized with aggregate elements</td> |
| 427 | <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list">std::initializer_list</a></td> |
| 428 | <td>Be cautious adding new constructors which take these, as they can hide non-initializer_list constructors in undesirable ways; see Effective Modern C++ Item 7 for more.</td> |
| 429 | </tr> |
| 430 | |
| 431 | <tr> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 432 | <td>Math functions</td> |
| 433 | <td>All C++11 features in <code><cmath></code>, e.g.:<br/> |
| 434 | <code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/> |
| 435 | <code>float_t</code>, <code>double_t</code><br/> |
| 436 | <code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/> |
| 437 | <code>isinf</code>, <code>isnan</code><br/></td> |
| 438 | <td>Useful for math-related code</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 439 | <td><a href="http://en.cppreference.com/w/cpp/header/cmath">Standard library header <cmath></a></td> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 440 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></td> |
| 441 | </tr> |
| 442 | |
| 443 | <tr> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 444 | <td>Move Iterator Adaptor</td> |
| 445 | <td><code>std::make_move_iterator()</code></td> |
| 446 | <td>Wraps an iterator so that it moves objects instead of copying them.</td> |
| 447 | <td><a href="http://en.cppreference.com/w/cpp/iterator/make_move_iterator">std::make_move_iterator</a></td> |
| 448 | <td>Useful to move objects between containers that contain move-only types like <code>scoped_ptr</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/lccnUljOHQU">Discussion thread</a></td> |
vmpstr | f484f72 | 2015-11-16 23:10:31 | [diff] [blame] | 449 | </tr> |
| 450 | |
vmpstr | c52317f | 2015-11-18 08:43:26 | [diff] [blame] | 451 | <tr> |
pkasting | 2f966af | 2015-12-06 01:52:18 | [diff] [blame] | 452 | <td>Move Semantics</td> |
| 453 | <td><code>std::move()</code></td> |
| 454 | <td>Facilitates efficient move operations</td> |
pkasting | 0fcb776 | 2016-04-29 00:44:37 | [diff] [blame] | 455 | <td><a href="http://en.cppreference.com/w/cpp/utility/move">std::move</a></td> |
danakj | 2c5aee9 | 2015-12-07 20:40:27 | [diff] [blame] | 456 | <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJFdbM'>Discussion thread</a></td> |
vmpstr | c52317f | 2015-11-18 08:43:26 | [diff] [blame] | 457 | </tr> |
| 458 | |
| 459 | <tr> |
pkasting | 9022cb4 | 2016-02-05 00:08:56 | [diff] [blame] | 460 | <td>String Direct Reference Functions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 461 | <td><code>std::string::front()</code>, <code>std::string::back()</code></td> |
pkasting | 9022cb4 | 2016-02-05 00:08:56 | [diff] [blame] | 462 | <td>Returns a reference to the front or back of a string</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 463 | <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front">std::basic_string::front</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/back">std::basic_string::back</a></td> |
pkasting | 9022cb4 | 2016-02-05 00:08:56 | [diff] [blame] | 464 | <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAYCV4">Discussion thread</a></td> |
| 465 | </tr> |
| 466 | |
| 467 | <tr> |
vmpstr | c52317f | 2015-11-18 08:43:26 | [diff] [blame] | 468 | <td>Type Traits</td> |
pkasting | 3adbbcc | 2016-02-04 01:52:38 | [diff] [blame] | 469 | <td>All C++11 features in <code><type_traits></code> except for aligned storage (see separate item), e.g.:<br/> |
| 470 | <code>integral_constant</code><br/> |
| 471 | <code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scalar</code><br/> |
| 472 | <code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/> |
| 473 | <code>is_default_constructible</code>, <code>is_move_constructible</code>, <code>is_copy_assignable</code><br/> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 474 | <code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></td> |
vmpstr | c52317f | 2015-11-18 08:43:26 | [diff] [blame] | 475 | <td>Allows compile-time inspection of the properties of types</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 476 | <td><a href="http://en.cppreference.com/w/cpp/header/type_traits">Standard library header <type_traits></a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 477 | <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'>Discussion thread</a></td> |
vmpstr | c52317f | 2015-11-18 08:43:26 | [diff] [blame] | 478 | </tr> |
| 479 | |
ricea | 5db2dfe | 2015-12-04 14:26:46 | [diff] [blame] | 480 | <tr> |
dcheng | 7bebfa46 | 2016-04-03 23:15:25 | [diff] [blame] | 481 | <td>Tuples</td> |
pkasting | 00ebe86 | 2016-05-11 01:48:50 | [diff] [blame] | 482 | <td>All C++11 features in <code><tuple></code>, e.g. <code>std::tie</code> and <code>std::tuple</code>.</td> |
dcheng | 7bebfa46 | 2016-04-03 23:15:25 | [diff] [blame] | 483 | <td>A fixed-size ordered collection of values of mixed types</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 484 | <td><a href="http://en.cppreference.com/w/cpp/header/tuple">Standard library header <tuple></a></td> |
tzik | ec749b1 | 2016-06-24 00:33:47 | [diff] [blame] | 485 | <td>Use <code>base::get</code> instead of <code>std::get</code> in case the <code>std::tuple</code> may be a rvalue-reference. |
| 486 | <code>std::get</code> in <=libstdc++-4.6 misses an overload for rvalue-reference of a tuple, and <code>base::get</code> complements it. </td> |
dcheng | 7bebfa46 | 2016-04-03 23:15:25 | [diff] [blame] | 487 | </tr> |
| 488 | |
| 489 | <tr> |
davidben | 411d3f7 | 2016-01-22 01:41:41 | [diff] [blame] | 490 | <td>Unordered Associative Containers</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 491 | <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, <code>std::unordered_multiset</code>, <code>std::unordered_multimap</code></td> |
davidben | 411d3f7 | 2016-01-22 01:41:41 | [diff] [blame] | 492 | <td>Allows efficient containers of key/value pairs</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 493 | <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unordered_map</a>, <a href="http://en.cppreference.com/w/cpp/container/unordered_set">std::unordered_set</a></td> |
| 494 | <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>std::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td> |
davidben | 411d3f7 | 2016-01-22 01:41:41 | [diff] [blame] | 495 | </tr> |
| 496 | |
tzik | 9ca30219 | 2016-02-11 10:24:45 | [diff] [blame] | 497 | <tr> |
dcheng | 7bebfa46 | 2016-04-03 23:15:25 | [diff] [blame] | 498 | <td>Unique Pointers</td> |
| 499 | <td><code>std::unique_ptr<<i>type</i>></code></td> |
| 500 | <td>A smart pointer with sole ownership of the owned object.</td> |
| 501 | <td><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">std::unique_ptr</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 502 | <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="https://groups.google.com/a/chromium.org/d/msg/cxx/aT2wsBLKvzI/oZuZ718oAwAJ">Discussion 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>std::unique_ptr</code></a> and is going away shortly.</td> |
tzik | 9ca30219 | 2016-02-11 10:24:45 | [diff] [blame] | 503 | </tr> |
| 504 | |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 505 | </tbody> |
| 506 | </table> |
| 507 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 508 | <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> |
| 509 | |
| 510 | <p>This section lists features that are not allowed to be used yet. |
| 511 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 512 | <h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 513 | |
mdempsky | 33bafda | 2014-10-30 23:14:52 | [diff] [blame] | 514 | <p>This section lists C++11 features that are not allowed in the Chromium |
Nico Weber | cea20a8 | 2014-09-25 17:46:51 | [diff] [blame] | 515 | codebase. |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 516 | </p> |
| 517 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 518 | <table id="banned_list" class="unlined striped"> |
| 519 | <tbody> |
| 520 | |
| 521 | <tr> |
| 522 | <th style='width:240px;'>Feature or Library</th> |
| 523 | <th style='width:240px;'>Snippet</th> |
| 524 | <th style='width:240px;'>Description</th> |
| 525 | <th style='width:240px;'>Documentation Link</th> |
Nico Weber | cea20a8 | 2014-09-25 17:46:51 | [diff] [blame] | 526 | <th style='width:240px;'>Notes</th> |
| 527 | </tr> |
| 528 | |
| 529 | <tr> |
yutak | 175dd5b | 2015-12-08 21:51:24 | [diff] [blame] | 530 | <td>Alignment Features</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 531 | <td><code>alignas</code> specifier, <code>alignof</code> operator</td> |
yutak | 175dd5b | 2015-12-08 21:51:24 | [diff] [blame] | 532 | <td>Object alignment</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 533 | <td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas specifier</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof operator</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 534 | <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.com/a/chromium.org/d/msg/cxx/rwXN02jzzq0/CpUc1ZzMBQAJ">Discussion thread</a></td> |
yutak | 175dd5b | 2015-12-08 21:51:24 | [diff] [blame] | 535 | </tr> |
| 536 | |
| 537 | <tr> |
mdempsky | 33bafda | 2014-10-30 23:14:52 | [diff] [blame] | 538 | <td>Inherited Constructors</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 539 | <td><code>class Derived : Base {<br /> |
| 540 | using Base::Base;<br /> |
| 541 | };</code></td> |
mdempsky | 33bafda | 2014-10-30 23:14:52 | [diff] [blame] | 542 | <td>Allow derived classes to inherit constructors from base classes</td> |
| 543 | <td><a href="http://en.cppreference.com/w/cpp/language/using_declaration">Using-declaration</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 544 | <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.com/a/chromium.org/d/msg/chromium-dev/BULzgIKZ-Ao/PLO7_GoVNvYJ">Discussion thread</a></td> |
mdempsky | 33bafda | 2014-10-30 23:14:52 | [diff] [blame] | 545 | </tr> |
| 546 | |
| 547 | <tr> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 548 | <td><code>long long</code> Type</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 549 | <td><code>long long <i>var</i> = <i>value</i>;</code></td> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 550 | <td>An integer of at least 64 bits</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 551 | <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td> |
| 552 | <td>Use a stdint.h type if you need a 64bit number. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread</a></td> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 553 | </tr> |
| 554 | |
| 555 | <tr> |
| 556 | <td>Raw String Literals</td> |
| 557 | <td><code>string <i>var</i>=R"(<i>raw_string</i>)";</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 558 | <td>Allows a string to be encoded without any escape sequences, easing parsing in regex expressions, for example</td> |
| 559 | <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string literal</a></td> |
brucedawson | d174d80 | 2015-11-06 18:37:54 | [diff] [blame] | 560 | <td>Causes incorrect line numbers in MSVS2013 and gcc. Reevaluate once that works. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/2kWQHbbuMHI">Discussion thread</a></td> |
thakis | 12bfc74 | 2014-10-28 04:37:49 | [diff] [blame] | 561 | </tr> |
| 562 | |
| 563 | <tr> |
Nico Weber | cea20a8 | 2014-09-25 17:46:51 | [diff] [blame] | 564 | <td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td> |
| 565 | <td><code>char16_t</code> and <code>char32_t</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 566 | <td>Provides character types for handling 16-bit and 32-bit code units (useful for encoding UTF-16 and UTF-32 string data)</td> |
| 567 | <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td> |
| 568 | <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> |
Nico Weber | cea20a8 | 2014-09-25 17:46:51 | [diff] [blame] | 569 | </tr> |
| 570 | |
| 571 | <tr> |
| 572 | <td>UTF-8, UTF-16, UTF-32 String Literals</td> |
| 573 | <td><code>u8"<i>string</i>", u"<i>string</i>", U"<i>string</i>"</code></td> |
| 574 | <td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 575 | <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string literal</a></td> |
| 576 | <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/gcoUbcjfsII">Discussion thread</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 577 | </tr> |
| 578 | |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 579 | <tr> |
| 580 | <td>Ref-qualified Member Functions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 581 | <td><code>class T {<br /> |
| 582 | void f() & {}<br /> |
| 583 | void f() && {}<br /> |
| 584 | };<br /> |
| 585 | t.f(); // first<br /> |
| 586 | T().f(); // second<br /> |
| 587 | std::move(t).f(); // second</code></td> |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 588 | <td>Allows class member functions to only bind to |this| as an rvalue or lvalue.</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 589 | <td><a href="http://en.cppreference.com/w/cpp/language/member_functions#const-.2C_volatile-.2C_and_ref-qualified_member_functions">const-, volatile-, and ref-qualified member functions</a></td> |
| 590 | <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a>. May only be used in Chromium with explicit approval from <code>styleguide/c++/OWNERS</code>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/gowclr2LPQA/discussion">Discussion Thread</a></td> |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 591 | </tr> |
| 592 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 593 | </tbody> |
| 594 | </table> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 595 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 596 | <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library Features</h3> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 597 | |
| 598 | <p>This section lists C++11 library features that are not allowed in the Chromium codebase.</p> |
| 599 | |
| 600 | <table id="blacklist_lib_list" class="unlined striped"> |
| 601 | <tbody> |
| 602 | |
| 603 | <tr> |
| 604 | <th style='width:240px;'>Feature</th> |
| 605 | <th style='width:240px;'>Snippet</th> |
| 606 | <th style='width:240px;'>Description</th> |
| 607 | <th style='width:240px;'>Documentation Link</th> |
| 608 | <th style='width:240px;'>Notes</th> |
| 609 | </tr> |
| 610 | |
| 611 | <tr> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 612 | <td>Date and time utilities</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 613 | <td><code><chrono></code></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 614 | <td>A standard date and time library</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 615 | <td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 616 | <td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the <code>base/</code> classes.</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 617 | </tr> |
| 618 | |
| 619 | <tr> |
pkasting | c6a6ebf1 | 2016-10-31 20:38:40 | [diff] [blame^] | 620 | <td>Exceptions</td> |
| 621 | <td><code><exception></code></td> |
| 622 | <td>Enhancements to exception throwing and handling</td> |
| 623 | <td><a href="http://en.cppreference.com/w/cpp/header/exception">Standard library header <exception></a></td> |
| 624 | <td>Exceptions are banned by the <a href="https://google.github.io/styleguide/cppguide.html#Exceptions">Google Style Guide</a> and disabled in Chromium compiles. Note that the <code>noexcept</code> specifier is explicitly allowed above. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a></td> |
| 625 | </tr> |
| 626 | |
| 627 | <tr> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 628 | <td>Regular Expressions</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 629 | <td><code><regex></code></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 630 | <td>A standard regular expressions library</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 631 | <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library</a></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 632 | <td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 633 | </tr> |
| 634 | |
| 635 | <tr> |
| 636 | <td>Thread Library</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 637 | <td><code><thread></code> and related headers, including<br /> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 638 | <code><future></code>, <code><mutex></code>, <code><condition_variable></code></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 639 | <td>Provides a standard multithreading library using <code>std::thread</code> and associates</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 640 | <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 641 | <td>Overlaps with many classes in <code>base/</code>. Keep using the <code>base/</code> classes for now. <code>base::Thread</code> is tightly coupled to <code>MessageLoop</code> which would make it hard to replace. We should investigate using standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td> |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 642 | </tr> |
| 643 | |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 644 | <tr> |
| 645 | <td>Atomics</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 646 | <td><code><atomic></code></td> |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 647 | <td>Fine-grained atomic types and operations</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 648 | <td><a href="http://en.cppreference.com/w/cpp/atomic">Atomic operations library</a></td> |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 649 | <td>Use in tcmalloc has caused <a href="http://crbug.com/572525">performance regressions</a>. Banned until we understand this better. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/Ej3RAiaI44s/discussion">Discussion Thread</a></td> |
| 650 | </tr> |
| 651 | |
| 652 | <tr> |
| 653 | <td>Shared Pointers</td> |
| 654 | <td><code>std::shared_ptr</code></td> |
| 655 | <td>Allows shared ownership of a pointer through reference counts</td> |
| 656 | <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 657 | <td>Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature. <a href="https://google.github.io/styleguide/cppguide.html#Ownership_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> |
jbroman | d21995c5 | 2016-01-07 23:43:54 | [diff] [blame] | 658 | </tr> |
| 659 | |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 660 | </tbody> |
| 661 | </table> |
| 662 | |
| 663 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 664 | <h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discussed</h3> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 665 | |
| 666 | <p>The following C++ language features are currently disallowed. |
| 667 | See the top of this page on how to propose moving a feature from this list |
| 668 | into the allowed or banned sections. Note that not all of these features |
| 669 | work in all our compilers yet.</p> |
| 670 | |
| 671 | <table id="blacklist_review_list" class="unlined striped"> |
| 672 | <tbody> |
| 673 | |
| 674 | <tr> |
| 675 | <th style='width:240px;'>Feature</th> |
| 676 | <th style='width:240px;'>Snippet</th> |
| 677 | <th style='width:240px;'>Description</th> |
| 678 | <th style='width:240px;'>Documentation Link</th> |
| 679 | <th style='width:240px;'>Notes</th> |
| 680 | </tr> |
| 681 | |
| 682 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 683 | <td>Attributes</td> |
| 684 | <td><code>[[<i>attribute_name</i>]]</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 685 | <td>Attaches properties to declarations that specific compiler implementations may use.</td> |
| 686 | <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generalized-attributes/">C++11 generalized attributes</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 687 | <td></td> |
| 688 | </tr> |
| 689 | |
| 690 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 691 | <td>Inline Namespaces</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 692 | <td><code>inline namespace foo { ... }</code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 693 | <td>Allows better versioning of namespaces</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 694 | <td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces">Inline namespaces</a></td> |
| 695 | <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Namespaces">Google Style Guide</a>. Unclear how it will work with components.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 696 | </tr> |
| 697 | |
| 698 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 699 | <td>User-Defined Literals</td> |
| 700 | <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
| 701 | <td>Allows user-defined literal expressions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 702 | <td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-defined literals</a></td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 703 | <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">Google Style Guide</a>.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 704 | </tr> |
| 705 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 706 | </tbody> |
| 707 | </table> |
| 708 | |
danakj | 4fd49fe4 | 2015-11-18 20:54:16 | [diff] [blame] | 709 | <h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Library Features To Be Discussed</h3> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 710 | |
Nico Weber | c8eb8ca | 2015-11-11 00:23:34 | [diff] [blame] | 711 | <p>The following C++ library features are currently disallowed. See the top of this page on how to propose moving a feature from this list into the allowed or banned sections. Note that not all of these features work in all our compilers yet.</p> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 712 | |
| 713 | <table id="banned_stdlib" class="unlined striped"> |
| 714 | |
| 715 | <tbody> |
| 716 | <tr> |
| 717 | <th style='width:240px;'>Feature</th> |
| 718 | <th style='width:240px;'>Snippet</th> |
| 719 | <th style='width:240px;'>Description</th> |
| 720 | <th style='width:240px;'>Documentation Link</th> |
| 721 | <th style='width:240px;'>Style Guide Usage</th> |
| 722 | </tr> |
| 723 | |
| 724 | <tr> |
| 725 | <td>Address Retrieval</td> |
| 726 | <td><code>std::addressof()</code></td> |
| 727 | <td>Obtains the address of an object even with overloaded <code>operator&</code></td> |
| 728 | <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 729 | <td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">operator overloading</a> is rare and <code>&</code> should suffice in most cases. May be preferable over <code>&</code> for performing object identity checks.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 730 | </tr> |
| 731 | |
| 732 | <tr> |
| 733 | <td>Aligned Storage</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 734 | <td><code>std::aligned_storage<Size, Align>::type</code><br /> |
| 735 | <code>std::alignment_of<T></code>, <code>std::aligned_union<Size, ...Types></code> <code>std::max_align_t</code></td> |
danakj | 715179fc | 2015-11-12 05:32:18 | [diff] [blame] | 736 | <td>Declare uninitialized storage having a specified alignment, or determine alignments.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 737 | <td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligned_storage</a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 738 | <td><code>std::aligned_storage</code> and <code>std::aligned_union</code> are disallowed in google3 over concerns about compatibility with internal cross-compiling toolchains.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 739 | </tr> |
| 740 | |
| 741 | <tr> |
| 742 | <td>Allocator Traits</td> |
| 743 | <td><code>std::allocator_traits</code></td> |
| 744 | <td>Provides an interface for accessing custom allocators</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 745 | <td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">std::allocator_traits</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 746 | <td>Usage should be rare.</td> |
| 747 | </tr> |
| 748 | |
| 749 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 750 | <td>Bind Operations</td> |
| 751 | <td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
| 752 | <td>Declares a function object bound to certain arguments</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 753 | <td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 754 | <td></td> |
| 755 | </tr> |
| 756 | |
| 757 | <tr> |
| 758 | <td>C Floating-Point Environment</td> |
danakj | 715179fc | 2015-11-12 05:32:18 | [diff] [blame] | 759 | <td><code><cfenv></code>, <code><fenv.h></code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 760 | <td>Provides floating point status flags and control modes for C-compatible code</td> |
| 761 | <td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library header <cfenv></a></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 762 | <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> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 763 | </tr> |
| 764 | |
| 765 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 766 | <td>Complex Inverse Trigonometric and Hyperbolic Functions</td> |
| 767 | <td>Functions within <code><complex></code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 768 | <td>Adds inverse trigonomentric and hyperbolic non-member functions to the <code><complex></code> library.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 769 | <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a></td> |
| 770 | <td></td> |
| 771 | </tr> |
| 772 | |
| 773 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 774 | <td>Container Compaction Functions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 775 | <td><code>std::vector::shrink_to_fit()</code>, <code>std::deque::shrink_to_fit()</code>, <code>std::string::shrink_to_fit()</code></td> |
| 776 | <td>Requests the removal of unused space in the container</td> |
| 777 | <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit">std::vector::shrink_to_fit</a>, <a href="http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit">std::deque::shrink_to_fit</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/shrink_to_fit">std::basic_string::shrink_to_fit</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 778 | <td></td> |
| 779 | </tr> |
| 780 | |
| 781 | <tr> |
| 782 | <td>Date/Time String Formatting Specifiers</td> |
| 783 | <td><code>std::strftime()</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 784 | <td>Converts date and time information into a formatted string using new specifiers</td> |
| 785 | <td><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime">std::strftime</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 786 | <td></td> |
| 787 | </tr> |
| 788 | |
| 789 | <tr> |
| 790 | <td>Function Return Type Deduction</td> |
| 791 | <td><code>std::result_of<<i>Functor(ArgTypes...)</i>></code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 792 | <td>Extracts the return type from the type signature of a function call invocation at compile-time.</td> |
| 793 | <td><a href="http://en.cppreference.com/w/cpp/types/result_of">std::result_of</a></td> |
| 794 | <td><a href="http://stackoverflow.com/questions/15486951/why-does-stdresult-of-take-an-unrelated-function-type-as-a-type-argument">Why does std::result_of take an (unrelated) function type as a type argument?</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 795 | </tr> |
| 796 | |
| 797 | <tr> |
| 798 | <td>Function Objects</td> |
| 799 | <td><code>std::function</code></td> |
| 800 | <td>Wraps a standard polymorphic function</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 801 | <td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std::function</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 802 | <td></td> |
| 803 | </tr> |
| 804 | |
| 805 | <tr> |
| 806 | <td>Forward Lists</td> |
| 807 | <td><code>std::forward_list</code></td> |
| 808 | <td>Provides an efficient singly linked list</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 809 | <td><a href="http://en.cppreference.com/w/cpp/container/forward_list">std::forward_list</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 810 | <td></td> |
| 811 | </tr> |
| 812 | |
| 813 | <tr> |
| 814 | <td>Gamma Natural Log</td> |
| 815 | <td><code>std::lgamma()</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 816 | <td>Computes the natural log of the gamma of a floating point value</td> |
| 817 | <td><a href="http://en.cppreference.com/w/cpp/numeric/math/lgamma">std::lgamma</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 818 | <td></td> |
| 819 | </tr> |
| 820 | |
| 821 | <tr> |
| 822 | <td>Garbage Collection Features</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 823 | <td><code>std::{un}declare_reachable()</code>, <code>std::{un}declare_no_pointers()</code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 824 | <td>Enables garbage collection implementations</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 825 | <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/declare_no_pointers">std::declare_no_pointers</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 826 | <td></td> |
| 827 | </tr> |
| 828 | |
| 829 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 830 | <td>Iterator Operators</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 831 | <td><code>std::next()</code>, <code>std::prev()</code></td> |
| 832 | <td>Copies an iterator and increments or decrements the copy by some value</td> |
| 833 | <td><a href="http://en.cppreference.com/w/cpp/iterator/next">std::next</a>, <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 834 | <td></td> |
| 835 | </tr> |
| 836 | |
| 837 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 838 | <td>Pointer Traits Class Template</td> |
| 839 | <td><code>std::pointer_traits</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 840 | <td>Provides a standard way to access properties of pointers and pointer-like types</td> |
| 841 | <td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits">std::pointer_traits</a></td> |
| 842 | <td>Useful for determining the element type pointed at by a (possibly smart) pointer.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 843 | </tr> |
| 844 | |
| 845 | <tr> |
| 846 | <td>Random Number Generators</td> |
| 847 | <td>Functions within <code><random></code></td> |
| 848 | <td>Random number generation algorithms and utilities</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 849 | <td><a href="http://en.cppreference.com/w/cpp/numeric/random">Pseudo-random number generation</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 850 | <td></td> |
| 851 | </tr> |
| 852 | |
| 853 | <tr> |
| 854 | <td>Ratio Template Class</td> |
| 855 | <td><code>std::ratio<<i>numerator</i>, <i>denominator</i>></code></td> |
| 856 | <td>Provides compile-time rational numbers</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 857 | <td><a href="http://en.cppreference.com/w/cpp/numeric/ratio/ratio">std::ratio</a></td> |
| 858 | <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-heavy interface style.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 859 | </tr> |
| 860 | |
| 861 | <tr> |
| 862 | <td>Reference Wrapper Classes</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 863 | <td><code>std::reference_wrapper</code> and <code>std::ref()</code>, <code>std::cref()</code></td> |
| 864 | <td>Allows you to wrap a reference within a standard object (and use those within containers)</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 865 | <td><a href="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper">std::reference_wrapper</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 866 | <td></td> |
| 867 | </tr> |
| 868 | |
| 869 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 870 | <td>Soft Program Exits</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 871 | <td><code>std::at_quick_exit()</code>, <code>std::quick_exit()</code></td> |
| 872 | <td>Allows registration of functions to be called upon exit, allowing cleaner program exit than <code>abort()</code> or <code>exit</code></td> |
| 873 | <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">std:quick_exit</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 874 | <td></td> |
| 875 | </tr> |
| 876 | |
| 877 | <tr> |
dcheng | 2d4220ae | 2016-07-26 08:58:46 | [diff] [blame] | 878 | <td>String-Number Conversion Functions</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 879 | <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()</code></td> |
dcheng | 2d4220ae | 2016-07-26 08:58:46 | [diff] [blame] | 880 | <td>Converts strings to/from numbers</td> |
| 881 | <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">std::stoi, std::stol, std::stoll</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_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>, <a href="http://en.cppreference.com/w/cpp/string/basic_string/to_string">std::to_string</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 882 | <td></td> |
| 883 | </tr> |
| 884 | |
| 885 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 886 | <td>System Errors</td> |
| 887 | <td><code><system_error></code></td> |
| 888 | <td>Provides a standard system error library</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 889 | <td><a href="http://en.cppreference.com/w/cpp/header/system_error">Standard library header <system_error></a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 890 | <td></td> |
| 891 | </tr> |
| 892 | |
| 893 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 894 | <td>Type-Generic Math Functions</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 895 | <td><code><ctgmath></code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 896 | <td>Provides a means to call real or complex functions based on the type of arguments</td> |
| 897 | <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library header <ctgmath></a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 898 | <td></td> |
| 899 | </tr> |
| 900 | |
| 901 | <tr> |
| 902 | <td>Type Info Enhancements</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 903 | <td><code>std::type_index</code>, <code>std::type_info::hash_code()</code></td> |
| 904 | <td>Allows type information (most often within containers) that can be copied, assigned, or hashed</td> |
| 905 | <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::type_info::hash_code</a></td> |
| 906 | <td><code>std::type_index</code> is a thin wrapper for <code>std::type_info</code>, allowing you to use it directly within both associative and unordered containers</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 907 | </tr> |
| 908 | |
| 909 | <tr> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 910 | <td>Variadic Copy Macro</td> |
| 911 | <td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> |
| 912 | <td>Makes a copy of the variadic function arguments</td> |
pkasting | 7f0693b3 | 2016-10-31 20:27:50 | [diff] [blame] | 913 | <td><a href="http://en.cppreference.com/w/cpp/utility/variadic/va_copy">va_copy</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 914 | <td></td> |
| 915 | </tr> |
| 916 | |
| 917 | <tr> |
| 918 | <td>Weak Pointers</td> |
| 919 | <td><code>std::weak_ptr</code></td> |
| 920 | <td>Allows a weak reference to a <code>std::shared_ptr</code></td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 921 | <td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr">std::weak_ptr</a></td> |
| 922 | <td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers">Ownership and Smart Pointers</a></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 923 | </tr> |
| 924 | |
| 925 | <tr> |
| 926 | <td>Wide String Support</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 927 | <td><code>std::wstring_convert</code>, <code>std::wbuffer_convert</code><br /> |
| 928 | <code>std::codecvt_utf8</code>, <code>std::codecvt_utf16</code>, <code>std::codecvt_utf8_utf16</code></td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 929 | <td>Converts between string encodings</td> |
pkasting | 07c0959a | 2016-04-14 22:16:43 | [diff] [blame] | 930 | <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert">std::wstring_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/codecvt_utf8">std::codecvt_utf8</a>, <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf16">std::codecvt_utf16</a>, <a href="http://en.cppreference.com/w/cpp/locale/codecvt_utf8_utf16">std::codecvt_utf8_utf16</a></td> |
| 931 | <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 useful for consuming non-ASCII data.</td> |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 932 | </tr> |
| 933 | |
| 934 | </tbody> |
| 935 | </table> |
| 936 | |
Nico Weber | 019d40f | 2014-09-23 20:21:59 | [diff] [blame] | 937 | </div> |
| 938 | </body> |
| 939 | </html> |