Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: styleguide/c++/c++11.html

Issue 2466103002: Styleguide cleanup part 3. (Closed)
Patch Set: Reword Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2014 The Chromium Authors. All rights reserved. 3 Copyright 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <head> 8 <head>
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <title>C++11 use in Chromium</title> 10 <title>C++11 use in Chromium</title>
11 <link rel="stylesheet" href="c++11.css"> 11 <link rel="stylesheet" href="c++11.css">
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 <td>More intuitive parsing of template parameters</td> 88 <td>More intuitive parsing of template parameters</td>
89 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack ets-pitfall-what-is-the-c11-fix">C++ templates angle brackets pitfall</a></td> 89 <td><a href="http://stackoverflow.com/questions/15785496/c-templates-angle-brack ets-pitfall-what-is-the-c11-fix">C++ templates angle brackets pitfall</a></td>
90 <td>Recommended to increase readability. Approved without discussion.</td> 90 <td>Recommended to increase readability. Approved without discussion.</td>
91 </tr> 91 </tr>
92 92
93 <tr> 93 <tr>
94 <td>Arrays</td> 94 <td>Arrays</td>
95 <td><code>std::array</code></td> 95 <td><code>std::array</code></td>
96 <td>A fixed-size replacement for built-in arrays, with STL support</td> 96 <td>A fixed-size replacement for built-in arrays, with STL support</td>
97 <td><a href="http://en.cppreference.com/w/cpp/container/array">std::array</a></t d> 97 <td><a href="http://en.cppreference.com/w/cpp/container/array">std::array</a></t d>
98 <td>Useful in performance-critical situations, with small, fixed-size arrays. In most cases, consider std::vector instead. std::vector is cheaper to std::move a nd is more widely used. <a href="https://groups.google.com/a/chromium.org/forum/ #!topic/cxx/pVRQCRWHEU8">Discussion thread</a>.</td> 98 <td>Useful in performance-critical situations, with small, fixed-size arrays. In most cases, consider std::vector instead. std::vector is cheaper to std::move a nd is more widely used. <a href="https://groups.google.com/a/chromium.org/forum/ #!topic/cxx/pVRQCRWHEU8">Discussion thread</a></td>
99 </tr> 99 </tr>
100 100
101 <tr> 101 <tr>
102 <td>Automatic Types</td> 102 <td>Automatic Types</td>
103 <td><code>auto</code></td> 103 <td><code>auto</code></td>
104 <td>Automatic type deduction</td> 104 <td>Automatic type deduction</td>
105 <td><a href="http://en.cppreference.com/w/cpp/language/auto">auto specifier</a>< /td> 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 Styl e Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chr omium-dev/OQyYSfH9m2M">Discussion thread</a>. <a href="https://groups.google.com /a/chromium.org/forum/#!topic/chromium-dev/5-Bt3BJzAo0">Another discussion threa d</a>.</td> 106 <td><a href="https://google.github.io/styleguide/cppguide.html#auto">Google Styl e Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chr omium-dev/OQyYSfH9m2M">Discussion thread</a>. <a href="https://groups.google.com /a/chromium.org/forum/#!topic/chromium-dev/5-Bt3BJzAo0">Another discussion threa d</a></td>
107 </tr> 107 </tr>
108 108
109 <tr> 109 <tr>
110 <td>Constant Expressions</td> 110 <td>Constant Expressions</td>
111 <td><code>constexpr</code></td> 111 <td><code>constexpr</code></td>
112 <td>Compile-time constant expressions</td> 112 <td>Compile-time constant expressions</td>
113 <td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr spec ifier</a></td> 113 <td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr spec ifier</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://g oogle.github.io/styleguide/cppguide.html#Use_of_constexpr">Google Style Guide</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://g oogle.github.io/styleguide/cppguide.html#Use_of_constexpr">Google Style Guide</a >. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/BE9xLUI-V ww">Discussion thread</a></td>
115 </tr> 115 </tr>
116 116
117 <tr> 117 <tr>
118 <td>Declared Type Accessor</td> 118 <td>Declared Type Accessor</td>
119 <td><code>decltype(<i>expression</i>)</code></td> 119 <td><code>decltype(<i>expression</i>)</code></td>
120 <td>Provides a means to determine the type of an expression at compile-time, use ful most often in templates.</td> 120 <td>Provides a means to determine the type of an expression at compile-time, use ful most often in templates.</td>
121 <td><a href="http://en.cppreference.com/w/cpp/language/decltype">decltype specif ier</a></td> 121 <td><a href="http://en.cppreference.com/w/cpp/language/decltype">decltype specif ier</a></td>
122 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td> 122 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td>
123 </tr> 123 </tr>
124 124
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 <td>Provide enums as full classes, with no implicit conversion to booleans or in tegers. Provide an explicit underlying type for enum classes and regular enums.< /td> 156 <td>Provide enums as full classes, with no implicit conversion to booleans or in tegers. Provide an explicit underlying type for enum classes and regular enums.< /td>
157 <td><a href="http://en.cppreference.com/w/cpp/language/enum">enumeration declara tion</a></td> 157 <td><a href="http://en.cppreference.com/w/cpp/language/enum">enumeration declara tion</a></td>
158 <td>Enum classes are still enums and follow enum naming rules (which means SHOUT Y_CASE in the <a href="http://www.chromium.org/developers/coding-style#Naming">C hromium Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/Q5WmkAImanc">Discussion thread</a></td> 158 <td>Enum classes are still enums and follow enum naming rules (which means SHOUT Y_CASE in the <a href="http://www.chromium.org/developers/coding-style#Naming">C hromium Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/Q5WmkAImanc">Discussion thread</a></td>
159 </tr> 159 </tr>
160 160
161 <tr> 161 <tr>
162 <td>Explicit Conversion Operators</td> 162 <td>Explicit Conversion Operators</td>
163 <td><code>explicit operator <i>type</i>() { ... }</code></td> 163 <td><code>explicit operator <i>type</i>() { ... }</code></td>
164 <td>Allows conversion operators that cannot be implicitly invoked</td> 164 <td>Allows conversion operators that cannot be implicitly invoked</td>
165 <td><a href="http://en.cppreference.com/w/cpp/language/explicit">explicit specif ier</a></td> 165 <td><a href="http://en.cppreference.com/w/cpp/language/explicit">explicit specif ier</a></td>
166 <td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromi um.org/d/msg/chromium-dev/zGF1SrQ-1HQ/BAiC12vwPeEJ">Discussion thread</a></td> 166 <td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromi um.org/forum/#!topic/chromium-dev/zGF1SrQ-1HQ">Discussion thread</a></td>
167 </tr> 167 </tr>
168 168
169 <tr> 169 <tr>
170 <td>Final Specifier</td> 170 <td>Final Specifier</td>
171 <td><code>final</code></td> 171 <td><code>final</code></td>
172 <td> Indicates that a class or function is final and cannot be overridden</td> 172 <td> Indicates that a class or function is final and cannot be overridden</td>
173 <td><a href="http://en.cppreference.com/w/cpp/language/final">final specifier</a ></td> 173 <td><a href="http://en.cppreference.com/w/cpp/language/final">final specifier</a ></td>
174 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> 174 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td>
175 </tr> 175 </tr>
176 176
177 <tr> 177 <tr>
178 <td>Function Suppression</td> 178 <td>Function Suppression</td>
179 <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> 179 <td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td>
180 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> 180 <td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td>
181 <td><a href="http://en.cppreference.com/w/cpp/language/function#Deleted_function s">Deleted functions</a></td> 181 <td><a href="http://en.cppreference.com/w/cpp/language/function#Deleted_function s">Deleted functions</a></td>
182 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td> 182 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /i1o7-RNRnMs">Discussion thread</a></td>
183 </tr> 183 </tr>
184 184
185 <tr> 185 <tr>
186 <td>Lambda Expressions</td> 186 <td>Lambda Expressions</td>
187 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td> 187 <td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</cod e></td>
188 <td>Anonymous functions</td> 188 <td>Anonymous functions</td>
189 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td> 189 <td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions< /a></td>
190 <td>Do not bind or store capturing lambdas outside the lifetime of the stack fra me they are defined in. Captureless lambdas can be used with <code>base::Callbac k</code>, such as <code>base::Bind([](int j){}, i);</code>, because they offer p rotection against a large class of object lifetime mistakes. Don't use default c aptures (<code>[=]</code>, <code>[&amp;]</code> &ndash; <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 us e them immediately, such as those in <code>&lt;algorithm&gt;</code>. <a href="ht tps://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">D iscussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#! topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. 190 <td>Lambdas are typically useful as a parameter to methods or functions that wil l use them immediately, such as those in <code>&lt;algorithm&gt;</code>. Be care ful with default captures (<code>[=]</code>, <code>[&amp;]</code>), and do not b ind or store any capturing lambdas outside the lifetime of the stack frame they are defined in; use <code>base::Callback</code> for this instead, as it helps pr event object lifetime mistakes. (Captureless lambdas can be used with <code>base ::Bind</code> as they do not have the same risks.) <a href="https://google.githu b.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>. <a hre f="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnc iQ">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/for um/#!topic/cxx/QxjsPELDYdQ">Another discussion thread</a> (about captureless lam bdas and <code>base::Bind</code>).</td>
191 </td>
192 </tr> 191 </tr>
193 192
194 <tr> 193 <tr>
195 <td>Local Types as Template Arguments</td> 194 <td>Local Types as Template Arguments</td>
196 <td><code>void func() {<br /> 195 <td><code>void func() {<br />
197 &nbsp;&nbsp;class Pred {<br /> 196 &nbsp;&nbsp;class Pred {<br />
198 &nbsp;&nbsp;&nbsp;public:<br /> 197 &nbsp;&nbsp;&nbsp;public:<br />
199 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br /> 198 &nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br />
200 &nbsp;&nbsp;};<br /> 199 &nbsp;&nbsp;};<br />
201 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td> 200 &nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td>
(...skipping 18 matching lines...) Expand all
220 <td>Allows non-static class members to be initialized at their definitions (outs ide constructors)</td> 219 <td>Allows non-static class members to be initialized at their definitions (outs ide constructors)</td>
221 <td><a href="http://en.cppreference.com/w/cpp/language/data_members">Non-static data members</a></td> 220 <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> 221 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /zqB-DySA4V0">Discussion thread</a></td>
223 </tr> 222 </tr>
224 223
225 <tr> 224 <tr>
226 <td>Null Pointer Constant</td> 225 <td>Null Pointer Constant</td>
227 <td><code>nullptr</code></td> 226 <td><code>nullptr</code></td>
228 <td>Declares a type-safe null pointer</td> 227 <td>Declares a type-safe null pointer</td>
229 <td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr, the poi nter literal</a></td> 228 <td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr, the poi nter literal</a></td>
230 <td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://groups.goo gle.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread </a>. <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/N ULL">Google Style Guide</a>. <code>std::nullptr_t</code> can be used too.</td> 229 <td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://google.git hub.io/styleguide/cppguide.html#0_and_nullptr/NULL">Google Style Guide</a>. <a h ref="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJH zxLg">Discussion thread</a></td>
231 </tr> 230 </tr>
232 231
233 <tr> 232 <tr>
234 <td>Override Specifier</td> 233 <td>Override Specifier</td>
235 <td><code>override</code></td> 234 <td><code>override</code></td>
236 <td>Indicates that a class or function overrides a base implementation</td> 235 <td>Indicates that a class or function overrides a base implementation</td>
237 <td><a href="http://en.cppreference.com/w/cpp/language/override">override specif ier</a></td> 236 <td><a href="http://en.cppreference.com/w/cpp/language/override">override specif ier</a></td>
238 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> 237 <td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td>
239 </tr> 238 </tr>
240 239
241 <tr> 240 <tr>
242 <td>Range-Based For Loops</td> 241 <td>Range-Based For Loops</td>
243 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td> 242 <td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td>
244 <td>Facilitates a more concise syntax for iterating over the elements of a conta iner (or a range of iterators) in a <code>for</code> loop</td> 243 <td>Facilitates a more concise syntax for iterating over the elements of a conta iner (or a range of iterators) in a <code>for</code> loop</td>
245 <td><a href="http://en.cppreference.com/w/cpp/language/range-for">Range-based fo r loop</a></td> 244 <td><a href="http://en.cppreference.com/w/cpp/language/range-for">Range-based fo r loop</a></td>
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/ch romium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread</a></td> 245 <td>As a rule of thumb, use <code>for (const auto& ...)</code>, <code>for (auto& ...)</code>, or <code>for (<i>concrete type</i> ...)</code>. For pointers, use <code>for (auto* ...)</code> to make clear that the copy of the loop variable is intended, and only a pointer is copied. <a href="https://groups.google.com/a/ch romium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread</a></td>
247 </tr> 246 </tr>
248 247
249 <tr> 248 <tr>
250 <td>Rvalue References</td> 249 <td>Rvalue References</td>
251 <td><code>T(T&amp;&amp; t)</code> and <code>T&amp; operator=(T&amp;&amp; t)<br/> <br/> 250 <td><code>T(T&amp;&amp; t)</code> and <code>T&amp; operator=(T&amp;&amp; t)<br/> <br/>
252 template &lt;typename T&gt;<br/>void Function(T&& t) { ... }</code></td> 251 template &lt;typename T&gt;<br/>void Function(T&& t) { ... }</code></td>
253 <td>Reference that only binds to a temporary object</td> 252 <td>Reference that only binds to a temporary object</td>
254 <td><a href="http://en.cppreference.com/w/cpp/language/reference#Rvalue_referenc es">Rvalue references</a></td> 253 <td><a href="http://en.cppreference.com/w/cpp/language/reference#Rvalue_referenc es">Rvalue references</a></td>
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 n ot be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN in mos t 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/chromiu m.org/d/topic/cxx/Q526tkruXpM">Another discussion thread</a>.</td> 254 <td>Only use these to define move constructors and move assignment operators, an d 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://google. github.io/styleguide/cppguide.html#Rvalue_references">Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/UnRaO Rb4TSw">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org /forum/#!topic/cxx/Q526tkruXpM">Another discussion thread</a></td>
256 </tr> 255 </tr>
257 256
258 <tr> 257 <tr>
259 <td>Standard Integers</td> 258 <td>Standard Integers</td>
260 <td>Typedefs within <code>&lt;stdint.h&gt;</code> and <code>&lt;inttypes&gt;</co de></td> 259 <td>Typedefs within <code>&lt;stdint.h&gt;</code> and <code>&lt;inttypes&gt;</co de></td>
261 <td>Provides fixed-size integers independent of platforms</td> 260 <td>Provides fixed-size integers independent of platforms</td>
262 <td><a href="http://en.cppreference.com/w/cpp/header/cstdint">Standard library h eader &lt;cstdint&gt;</a></td> 261 <td><a href="http://en.cppreference.com/w/cpp/header/cstdint">Standard library h eader &lt;cstdint&gt;</a></td>
263 <td>Already in common use in the codebase. Approved without discussion.</td> 262 <td>Approved without discussion. Required by the <a href="http://google.github.i o/styleguide/cppguide.html#Integer_Types">Google Style Guide</a>.</td>
264 </tr> 263 </tr>
265 264
266 <tr> 265 <tr>
267 <td>Static Assertions</td> 266 <td>Static Assertions</td>
268 <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td> 267 <td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td>
269 <td>Tests compile-time conditions</td> 268 <td>Tests compile-time conditions</td>
270 <td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Ass ertion</a></td> 269 <td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Ass ertion</a></td>
271 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /POISBQEhGzU">Discussion thread</a></td> 270 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /POISBQEhGzU">Discussion thread</a></td>
272 </tr> 271 </tr>
273 272
274 <tr> 273 <tr>
275 <td>Trailing Return Types</td> 274 <td>Trailing Return Types</td>
276 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td> 275 <td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td>
277 <td>Allows trailing function return value syntax</td> 276 <td>Allows trailing function return value syntax</td>
278 <td><a href="http://en.cppreference.com/w/cpp/language/function">Declaring funct ions</a></td> 277 <td><a href="http://en.cppreference.com/w/cpp/language/function">Declaring funct ions</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 th read</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/Lk p0nubVd0Q">Another discussion thread.</a></td> 278 <td>Use only where it considerably improves readability. <a href="https://groups .google.com/a/chromium.org/forum/#!topic/chromium-dev/OQyYSfH9m2M">Discussion th read</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/Lk p0nubVd0Q">Another discussion thread</a></td>
280 </tr> 279 </tr>
281 280
282 <tr> 281 <tr>
283 <td>Type Aliases ("using" instead of "typedef")</td> 282 <td>Type Aliases ("using" instead of "typedef")</td>
284 <td><code>using <i>new_alias</i> = <i>typename</i></code></td> 283 <td><code>using <i>new_alias</i> = <i>typename</i></code></td>
285 <td>Allows parameterized typedefs</td> 284 <td>Allows parameterized typedefs</td>
286 <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias, a lias template</a></td> 285 <td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias, a lias 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/8dOAMz gR4ao">Discussion thread</a></td> 286 <td>Use instead of typedef, unless the header needs to be compatible with C. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8dOAMz gR4ao">Discussion thread</a></td>
288 </tr> 287 </tr>
289 288
290 <tr> 289 <tr>
291 <td>Uniform Initialization Syntax</td> 290 <td>Uniform Initialization Syntax</td>
292 <td><code><i>type</i> <i>name</i> {[<i>value</i> ..., <i>value</i>]};</code></td > 291 <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 us ing brace syntax</td> 292 <td>Allows any object of primitive, aggregate or class type to be initialized us ing brace syntax</td>
294 <td><a href="http://www.stroustrup.com/C++11FAQ.html#uniform-init">Uniform initi alization syntax and semantics</a></td> 293 <td><a href="http://www.stroustrup.com/C++11FAQ.html#uniform-init">Uniform initi alization syntax and semantics</a></td>
295 <td>See the <a href="https://www.chromium.org/developers/coding-style/cpp-dos-an d-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> 294 <td>See the <a href="https://www.chromium.org/developers/coding-style/cpp-dos-an d-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> 295 </tr>
297 296
298 <tr> 297 <tr>
299 <td>Union Class Members</td> 298 <td>Union Class Members</td>
300 <td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td> 299 <td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td>
301 <td>Allows class type members</td> 300 <td>Allows class type members</td>
302 <td><a href="http://en.cppreference.com/w/cpp/language/union">Union declaration< /a></td> 301 <td><a href="http://en.cppreference.com/w/cpp/language/union">Union declaration< /a></td>
303 <td>Usage should be rare.</td> 302 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/3oK78s1ntgU">Discussion thread</a></td>
304 </tr> 303 </tr>
305 304
306 <tr> 305 <tr>
307 <td>Variadic Macros</td> 306 <td>Variadic Macros</td>
308 <td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code> </td> 307 <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> 308 <td>Allows macros that accept a variable number of arguments</td>
310 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons tandard">Are Variadic macros nonstandard?</a></td> 309 <td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nons tandard">Are Variadic macros nonstandard?</a></td>
311 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td> 310 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/foru m/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td>
312 </tr> 311 </tr>
313 312
(...skipping 13 matching lines...) Expand all
327 <p>The following library features are currently allowed.</p> 326 <p>The following library features are currently allowed.</p>
328 327
329 <table id="whitelist_lib_list" class="unlined striped"> 328 <table id="whitelist_lib_list" class="unlined striped">
330 <tbody> 329 <tbody>
331 330
332 <tr> 331 <tr>
333 <th style='width:240px;'>Feature or Library</th> 332 <th style='width:240px;'>Feature or Library</th>
334 <th style='width:240px;'>Snippet</th> 333 <th style='width:240px;'>Snippet</th>
335 <th style='width:240px;'>Description</th> 334 <th style='width:240px;'>Description</th>
336 <th style='width:240px;'>Documentation Link</th> 335 <th style='width:240px;'>Documentation Link</th>
337 <th style='width:240px;'>Notes</th> 336 <th style='width:240px;'>Notes and Discussion Thread</th>
338 </tr> 337 </tr>
339 338
340 <tr> 339 <tr>
341 <td>Access to underlying <code>std::vector</code> data</td> 340 <td>Access to underlying <code>std::vector</code> data</td>
342 <td><code>v.data()</code></td> 341 <td><code>v.data()</code></td>
343 <td>Returns a pointer to a <code>std::vector</code>'s underlying data, accountin g for empty vectors.</td> 342 <td>Returns a pointer to a <code>std::vector</code>'s underlying data, accountin g for empty vectors.</td>
344 <td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector ::data</a></td> 343 <td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector ::data</a></td>
345 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtb zok">Discussion thread</a></td> 344 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtb zok">Discussion thread</a></td>
346 </tr> 345 </tr>
347 346
348 <tr> 347 <tr>
349 <td>Algorithms</td> 348 <td>Algorithms</td>
350 <td>All C++11 features in <code>&lt;algorithm&gt;</code>:<br/> 349 <td>All C++11 features in <code>&lt;algorithm&gt;</code>:<br/>
351 <code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/> 350 <code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/>
352 <code>find_if_not</code><br/> 351 <code>find_if_not</code><br/>
353 <code>copy_if</code>, <code>copy_n</code><br/> 352 <code>copy_if</code>, <code>copy_n</code><br/>
354 <code>move</code>, <code>move_backward</code> (see note)<br/> 353 <code>move</code>, <code>move_backward</code> (see note)<br/>
355 <code>shuffle</code><br/> 354 <code>shuffle</code><br/>
356 <code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point< /code><br/> 355 <code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point< /code><br/>
357 <code>is_sorted</code>, <code>is_sorted_until</code><br/> 356 <code>is_sorted</code>, <code>is_sorted_until</code><br/>
358 <code>is_heap</code>, <code>is_heap_until</code><br/> 357 <code>is_heap</code>, <code>is_heap_until</code><br/>
359 <code>minmax</code>, <code>minmax_element</code><br/> 358 <code>minmax</code>, <code>minmax_element</code><br/>
360 <code>is_permutation<br/></td> 359 <code>is_permutation<br/></td>
361 <td>Safe and performant implementations of common algorithms</td> 360 <td>Safe and performant implementations of common algorithms</td>
362 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm">Standard library header &lt;algorithm&gt;</a></td> 361 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm">Standard library header &lt;algorithm&gt;</a></td>
363 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/> Note that &lt;algorithm&gt; contains a range-bas ed <code>move</code> method. This is allowed, but because people may confuse it with the single-arg <code>std::move</code>, there is often a way to write code w ithout it that is more readable. <a href='https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td> 362 <td>Note that &lt;algorithm&gt; contains a range-based <code>move</code> method. This is allowed, but because people may confuse it with the single-arg <code>st d::move</code>, there is often a way to write code without it that is more reada ble. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1 IuHk">Discussion thread</a>. <a href='https://groups.google.com/a/chromium.org/f orum/#!topic/cxx/8WzmtYrZvQ8'>Another discussion thread</a></td>
364 </tr> 363 </tr>
365 364
366 <tr> 365 <tr>
367 <td>Begin and End Non-Member Functions</td> 366 <td>Begin and End Non-Member Functions</td>
368 <td><code>std::begin()</code>, <code>std::end()</code></td> 367 <td><code>std::begin()</code>, <code>std::end()</code></td>
369 <td>Allows use of free functions on any container, including fixed-size arrays</ td> 368 <td>Allows use of free functions on any container, including fixed-size arrays</ td>
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> 369 <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.goog le.com/a/chromium.org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a>< /td> 370 <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.goog le.com/a/chromium.org/forum/#!topic/cxx/5iFNE8P5qT4">Discussion thread</a></td>
372 </tr> 371 </tr>
373 372
374 <tr> 373 <tr>
375 <td>Conditional Type Selection</td> 374 <td>Conditional Type Selection</td>
376 <td><code>std::enable_if</code>, <code>std::conditional</code></td> 375 <td><code>std::enable_if</code>, <code>std::conditional</code></td>
377 <td>Enables compile-time conditional type selection</td> 376 <td>Enables compile-time conditional type selection</td>
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> 377 <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>
379 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td> 378 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td>
380 </tr> 379 </tr>
381 380
382 <tr> 381 <tr>
383 <td>Constant Iterator Methods on Containers</td> 382 <td>Constant Iterator Methods on Containers</td>
384 <td>E.g. <code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></t d> 383 <td>E.g. <code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></t d>
385 <td>Allows more widespread use of <code>const_iterator</code></td> 384 <td>Allows more widespread use of <code>const_iterator</code></td>
386 <td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vecto r::cbegin</a>, <a href="http://en.cppreference.com/w/cpp/container/vector/end">s td::vector::cend<a></td> 385 <td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vecto r::cbegin</a>, <a href="http://en.cppreference.com/w/cpp/container/vector/end">s td::vector::cend<a></td>
387 <td>Applies to all containers, not just <code>vector</code>. Consider using <cod e>const_iterator</code> over <code>iterator</code> where possible for the same r eason as using <code>const</code> variables and functions where possible; see Ef fective Modern C++ item 13 for motivation. <a href="https://groups.google.com/a/ chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discussion thread</a></td> 386 <td>Applies to all containers, not just <code>vector</code>. Consider using <cod e>const_iterator</code> over <code>iterator</code> where possible for the same r eason as using <code>const</code> variables and functions where possible; see Ef fective Modern C++ item 13. <a href="https://groups.google.com/a/chromium.org/fo rum/#!topic/cxx/cS83F_buqLM">Discussion thread</a></td>
388 </tr> 387 </tr>
389 388
390 <tr> 389 <tr>
391 <td>Containers containing move-only types</td>
392 <td><code>vector&lt;scoped_ptr&gt;</code></td>
393 <td>Enables containers that contain move-only types like <code>scoped_ptr</code> </td>
394 <td>TODO</td>
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> 390 <td>Declared Type As Value</td>
400 <td><code>std::declval&lt;<i>class</i>&gt;()</code></td> 391 <td><code>std::declval&lt;<i>class</i>&gt;()</code></td>
401 <td>Converts a type to a reference of the type to allow use of members of the ty pe without constructing it in templates.</td> 392 <td>Converts a type to a reference of the type to allow use of members of the ty pe without constructing it in templates.</td>
402 <td><a href="http://en.cppreference.com/w/cpp/utility/declval">std::declval</a>< /td> 393 <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/to pic/cxx/ku6lYjk0-OU/discussion">Discussion thread</a></td> 394 <td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/d/to pic/cxx/ku6lYjk0-OU/discussion">Discussion thread</a></td>
404 </tr> 395 </tr>
405 396
406 <tr> 397 <tr>
407 <td>Emplacement methods for containers</td> 398 <td>Emplacement methods for containers</td>
408 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td> 399 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td>
409 <td>Constructs elements directly within a container without a copy or a move. Le ss verbose than <code>push_back()</code> due to not naming the type being constr ucted.</td> 400 <td>Constructs elements directly within a container without a copy or a move. Le ss verbose than <code>push_back()</code> due to not naming the type being constr ucted.</td>
410 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back ">std::vector::emplace_back</a></td> 401 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back ">std::vector::emplace_back</a></td>
411 <td><code>std::map::emplace()</code> is not yet available on all libstdc++ versi ons we support. When using emplacement for performance reasons, your type should probably be movable (since e.g. a vector of it might be resized); given a movab le type, then, consider whether you really need to avoid the move done by <code> push_back()</code>. For readability concerns, treat like <code>auto</code>; some times the brevity over <code>push_back()</code> is a win, sometimes a loss. <a h ref="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/m3cblzEta7A">Dis cussion thread</a></td> 402 <td><code>std::map::emplace()</code> is not yet available on all libstdc++ versi ons we support. When using emplacement for performance reasons, your type should probably be movable (since e.g. a vector of it might be resized); given a movab le type, then, consider whether you really need to avoid the move done by <code> push_back()</code>. For readability concerns, treat like <code>auto</code>; some times the brevity over <code>push_back()</code> is a win, sometimes a loss. <a h ref="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/m3cblzEta7A">Dis cussion thread</a></td>
412 </tr> 403 </tr>
413 404
414 <tr> 405 <tr>
415 <td>Forwarding references</td> 406 <td>Forwarding references</td>
416 <td><code>std::forward()</code></td> 407 <td><code>std::forward()</code></td>
417 <td>Perfectly forwards arguments (including rvalues)</td> 408 <td>Perfectly forwards arguments (including rvalues)</td>
418 <td><a href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< /td> 409 <td><a href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< /td>
419 <td>Allowed, though usage should be rare (primarily for forwarding constructor a rguments, or in carefully reviewed library code). <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/-O7euklhSxs/discussion">Discussion thread</a> 410 <td>Allowed, though usage should be rare (primarily for forwarding constructor a rguments, or in carefully reviewed library code). <a href="https://groups.google .com/a/chromium.org/forum/#!topic/cxx/-O7euklhSxs">Discussion thread</a>
420 </td> 411 </td>
421 </tr> 412 </tr>
422 413
423 <tr> 414 <tr>
424 <td>Initializer Lists</td> 415 <td>Initializer Lists</td>
425 <td><code>std::initializer_list&lt;T&gt;</code></td> 416 <td><code>std::initializer_list&lt;T&gt;</code></td>
426 <td>Allows containers to be initialized with aggregate elements</td> 417 <td>Allows containers to be initialized with aggregate elements</td>
427 <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list">std::ini tializer_list</a></td> 418 <td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list">std::ini tializer_list</a></td>
428 <td>Be cautious adding new constructors which take these, as they can hide non-i nitializer_list constructors in undesirable ways; see Effective Modern C++ Item 7 for more.</td> 419 <td>Be cautious adding new constructors which take these, as they can hide non-i nitializer_list constructors in undesirable ways; see Effective Modern C++ Item 7. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/TQQ-L51_n aM">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/for um/#!topic/cxx/UpiCpuu9UNc">Another discussion thread</a></td>
429 </tr> 420 </tr>
430 421
431 <tr> 422 <tr>
432 <td>Math functions</td> 423 <td>Math functions</td>
433 <td>All C++11 features in <code>&lt;cmath&gt;</code>, e.g.:<br/> 424 <td>All C++11 features in <code>&lt;cmath&gt;</code>, e.g.:<br/>
434 <code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/> 425 <code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/>
435 <code>float_t</code>, <code>double_t</code><br/> 426 <code>float_t</code>, <code>double_t</code><br/>
436 <code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/ > 427 <code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/ >
437 <code>isinf</code>, <code>isnan</code><br/></td> 428 <code>isinf</code>, <code>isnan</code><br/></td>
438 <td>Useful for math-related code</td> 429 <td>Useful for math-related code</td>
439 <td><a href="http://en.cppreference.com/w/cpp/header/cmath">Standard library hea der &lt;cmath&gt;</a></td> 430 <td><a href="http://en.cppreference.com/w/cpp/header/cmath">Standard library hea der &lt;cmath&gt;</a></td>
440 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXM eUk">Discussion thread</a></td> 431 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXM eUk">Discussion thread</a></td>
441 </tr> 432 </tr>
442 433
443 <tr> 434 <tr>
444 <td>Move Iterator Adaptor</td> 435 <td>Move Iterator Adaptor</td>
445 <td><code>std::make_move_iterator()</code></td> 436 <td><code>std::make_move_iterator()</code></td>
446 <td>Wraps an iterator so that it moves objects instead of copying them.</td> 437 <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> 438 <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> 439 <td>Useful to move objects between containers that contain move-only types like <code>std::unique_ptr</code>. <a href="https://groups.google.com/a/chromium.org/ forum/#!topic/cxx/lccnUljOHQU">Discussion thread</a></td>
449 </tr> 440 </tr>
450 441
451 <tr> 442 <tr>
452 <td>Move Semantics</td> 443 <td>Move Semantics</td>
453 <td><code>std::move()</code></td> 444 <td><code>std::move()</code></td>
454 <td>Facilitates efficient move operations</td> 445 <td>Facilitates efficient move operations</td>
455 <td><a href="http://en.cppreference.com/w/cpp/utility/move">std::move</a></td> 446 <td><a href="http://en.cppreference.com/w/cpp/utility/move">std::move</a></td>
456 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td> 447 <td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJF dbM'>Discussion thread</a></td>
457 </tr> 448 </tr>
458 449
459 <tr> 450 <tr>
451 <td>Null Pointer Type</td>
452 <td><code>std::nullptr_t</code></td>
453 <td>Allows referencing the type of <code>nullptr</code>, e.g. in templates</td>
454 <td><a href="http://en.cppreference.com/w/cpp/types/nullptr_t">std::nullptr_t</a ></td>
455 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev /UNaXc8R7eJ0">Discussion thread</a></td>
456 </tr>
457
458 <tr>
460 <td>String Direct Reference Functions</td> 459 <td>String Direct Reference Functions</td>
461 <td><code>std::string::front()</code>, <code>std::string::back()</code></td> 460 <td><code>std::string::front()</code>, <code>std::string::back()</code></td>
462 <td>Returns a reference to the front or back of a string</td> 461 <td>Returns a reference to the front or back of a string</td>
463 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front">std::ba sic_string::front</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_st ring/back">std::basic_string::back</a></td> 462 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/front">std::ba sic_string::front</a>, <a href="http://en.cppreference.com/w/cpp/string/basic_st ring/back">std::basic_string::back</a></td>
464 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAY CV4">Discussion thread</a></td> 463 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAY CV4">Discussion thread</a></td>
465 </tr> 464 </tr>
466 465
467 <tr> 466 <tr>
468 <td>Type Traits</td> 467 <td>Type Traits</td>
469 <td>All C++11 features in <code>&lt;type_traits&gt;</code> except for aligned st orage (see separate item), e.g.:<br/> 468 <td>All C++11 features in <code>&lt;type_traits&gt;</code> except for aligned st orage (see separate item), e.g.:<br/>
470 <code>integral_constant</code><br/> 469 <code>integral_constant</code><br/>
471 <code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scala r</code><br/> 470 <code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scala r</code><br/>
472 <code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/> 471 <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/> 472 <code>is_default_constructible</code>, <code>is_move_constructible</code>, <code >is_copy_assignable</code><br/>
474 <code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></t d> 473 <code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></t d>
475 <td>Allows compile-time inspection of the properties of types</td> 474 <td>Allows compile-time inspection of the properties of types</td>
476 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits">Standard libra ry header &lt;type_traits&gt;</a></td> 475 <td><a href="http://en.cppreference.com/w/cpp/header/type_traits">Standard libra ry header &lt;type_traits&gt;</a></td>
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'>Discus sion thread</a></td> 476 <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 hre f='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discu ssion thread</a></td>
478 </tr> 477 </tr>
479 478
480 <tr> 479 <tr>
481 <td>Tuples</td> 480 <td>Tuples</td>
482 <td>All C++11 features in <code>&lt;tuple&gt;</code>, e.g. <code>std::tie</code> and <code>std::tuple</code>.</td> 481 <td>All C++11 features in <code>&lt;tuple&gt;</code>, e.g. <code>std::tie</code> and <code>std::tuple</code>.</td>
483 <td>A fixed-size ordered collection of values of mixed types</td> 482 <td>A fixed-size ordered collection of values of mixed types</td>
484 <td><a href="http://en.cppreference.com/w/cpp/header/tuple">Standard library hea der &lt;tuple&gt;</a></td> 483 <td><a href="http://en.cppreference.com/w/cpp/header/tuple">Standard library hea der &lt;tuple&gt;</a></td>
485 <td>Use <code>base::get</code> instead of <code>std::get</code> in case the <cod e>std::tuple</code> may be a rvalue-reference. 484 <td>libstdc++ 4.6 has a bug where <code>std::get</code> can return an lvalue-ref erence when it should return an rvalue-reference. <code>base::get</code> can be used to avoid this. <a href="https://groups.google.com/a/chromium.org/forum/#!to pic/cxx/0NnCRmMY1xY">Discussion thread</a>. <a href="https://groups.google.com/a /chromium.org/forum/#!topic/cxx/VA7Ej2IWS2w">Another discussion thread</a></td>
486 <code>std::get</code> in &lt;=libstdc++-4.6 misses an overload for rvalue-refere nce of a tuple, and <code>base::get</code> complements it. </td>
487 </tr> 485 </tr>
488 486
489 <tr> 487 <tr>
490 <td>Unordered Associative Containers</td> 488 <td>Unordered Associative Containers</td>
491 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, <code>std: :unordered_multiset</code>, <code>std::unordered_multimap</code></td> 489 <td><code>std::unordered_set</code>, <code>std::unordered_map</code>, <code>std: :unordered_multiset</code>, <code>std::unordered_multimap</code></td>
492 <td>Allows efficient containers of key/value pairs</td> 490 <td>Allows efficient containers of key/value pairs</td>
493 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a>, <a href="http://en.cppreference.com/w/cpp/container/unordered_set ">std::unordered_set</a></td> 491 <td><a href="http://en.cppreference.com/w/cpp/container/unordered_map">std::unor dered_map</a>, <a href="http://en.cppreference.com/w/cpp/container/unordered_set ">std::unordered_set</a></td>
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>st d::hash</code> for custom types. <a href="https://groups.google.com/a/chromium.o rg/forum/#!topic/cxx/nCdjQqnouO4">Discussion thread</a>.</td> 492 <td>Specify custom hashers instead of specializing <code>std::hash</code> for cu stom types. <a href="https://google.github.io/styleguide/cppguide.html#std_hash" >Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum /#!topic/cxx/nCdjQqnouO4">Discussion thread</a></td>
495 </tr> 493 </tr>
496 494
497 <tr> 495 <tr>
498 <td>Unique Pointers</td> 496 <td>Unique Pointers</td>
499 <td><code>std::unique_ptr&lt;<i>type</i>&gt;</code></td> 497 <td><code>std::unique_ptr&lt;<i>type</i>&gt;</code></td>
500 <td>A smart pointer with sole ownership of the owned object.</td> 498 <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> 499 <td><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">std::unique_ptr </a></td>
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="htt ps://groups.google.com/a/chromium.org/d/msg/cxx/aT2wsBLKvzI/oZuZ718oAwAJ">Discus sion thread</a>. <code>scoped_ptr</code> is a <a href="https://groups.google.com /a/chromium.org/d/msg/chromium-dev/roY78iTblYc/bb8nYsxfCgAJ">typedef for <code>s td::unique_ptr</code></a> and is going away shortly.</td> 500 <td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Sma rt_Pointers">Google Style Guide</a>. <a href="https://groups.google.com/a/chromi um.org/forum/#!topic/cxx/aT2wsBLKvzI">Discussion thread</a></td>
503 </tr> 501 </tr>
504 502
505 </tbody> 503 </tbody>
506 </table> 504 </table>
507 505
508 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2> 506 <h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2>
509 507
510 <p>This section lists features that are not allowed to be used yet. 508 <p>This section lists features that are not allowed to be used yet.
511 509
512 <h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3 > 510 <h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3 >
513 511
514 <p>This section lists C++11 features that are not allowed in the Chromium 512 <p>This section lists C++11 features that are not allowed in the Chromium
515 codebase. 513 codebase.
516 </p> 514 </p>
517 515
518 <table id="banned_list" class="unlined striped"> 516 <table id="banned_list" class="unlined striped">
519 <tbody> 517 <tbody>
520 518
521 <tr> 519 <tr>
522 <th style='width:240px;'>Feature or Library</th> 520 <th style='width:240px;'>Feature or Library</th>
523 <th style='width:240px;'>Snippet</th> 521 <th style='width:240px;'>Snippet</th>
524 <th style='width:240px;'>Description</th> 522 <th style='width:240px;'>Description</th>
525 <th style='width:240px;'>Documentation Link</th> 523 <th style='width:240px;'>Documentation Link</th>
526 <th style='width:240px;'>Notes</th> 524 <th style='width:240px;'>Notes and Discussion Thread</th>
527 </tr> 525 </tr>
528 526
529 <tr> 527 <tr>
530 <td>Inline Namespaces</td> 528 <td>Inline Namespaces</td>
531 <td><code>inline namespace foo { ... }</code></td> 529 <td><code>inline namespace foo { ... }</code></td>
532 <td>Allows better versioning of namespaces</td> 530 <td>Allows better versioning of namespaces</td>
533 <td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespac es">Inline namespaces</a></td> 531 <td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespac es">Inline namespaces</a></td>
534 <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Nam espaces">Google Style Guide</a>. Unclear how it will work with components.</td> 532 <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Nam espaces">Google Style Guide</a>. Unclear how it will work with components.</td>
535 </tr> 533 </tr>
536 534
537 <tr> 535 <tr>
538 <td><code>long long</code> Type</td> 536 <td><code>long long</code> Type</td>
539 <td><code>long long <i>var</i> = <i>value</i>;</code></td> 537 <td><code>long long <i>var</i> = <i>value</i>;</code></td>
540 <td>An integer of at least 64 bits</td> 538 <td>An integer of at least 64 bits</td>
541 <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types< /a></td> 539 <td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types< /a></td>
542 <td>Use a stdint.h type if you need a 64bit number. <a href="https://groups.goog le.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread< /a></td> 540 <td>Use a stdint.h type if you need a 64bit number. <a href="https://groups.goog le.com/a/chromium.org/forum/#!topic/chromium-dev/RxugZ-pIDxk">Discussion thread< /a></td>
543 </tr> 541 </tr>
544 542
545 <tr> 543 <tr>
546 <td>Ref-qualified Member Functions</td> 544 <td>Ref-qualified Member Functions</td>
547 <td><code>class T {<br /> 545 <td><code>class T {<br />
548 &nbsp;&nbsp;void f() & {}<br /> 546 &nbsp;&nbsp;void f() & {}<br />
549 &nbsp;&nbsp;void f() && {}<br /> 547 &nbsp;&nbsp;void f() && {}<br />
550 };<br /> 548 };<br />
551 t.f();&nbsp;&nbsp;// first<br /> 549 t.f();&nbsp;&nbsp;// first<br />
552 T().f();&nbsp;&nbsp;// second<br /> 550 T().f();&nbsp;&nbsp;// second<br />
553 std::move(t).f();&nbsp;&nbsp;// second</code></td> 551 std::move(t).f();&nbsp;&nbsp;// second</code></td>
554 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td> 552 <td>Allows class member functions to only bind to |this| as an rvalue or lvalue. </td>
555 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions#const-.2 C_volatile-.2C_and_ref-qualified_member_functions">const-, volatile-, and ref-qu alified member functions</a></td> 553 <td><a href="http://en.cppreference.com/w/cpp/language/member_functions#const-.2 C_volatile-.2C_and_ref-qualified_member_functions">const-, volatile-, and ref-qu alified member functions</a></td>
556 <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/ch romium.org/d/topic/cxx/gowclr2LPQA/discussion">Discussion Thread</a></td> 554 <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/ch romium.org/forum/#!topic/cxx/gowclr2LPQA">Discussion Thread</a></td>
557 </tr> 555 </tr>
558 556
559 <tr> 557 <tr>
560 <td>User-Defined Literals</td> 558 <td>User-Defined Literals</td>
561 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> 559 <td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td>
562 <td>Allows user-defined literal expressions</td> 560 <td>Allows user-defined literal expressions</td>
563 <td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-define d literals</a></td> 561 <td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-define d literals</a></td>
564 <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Ope rator_Overloading">Google Style Guide</a>.</td> 562 <td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Ope rator_Overloading">Google Style Guide</a>.</td>
565 </tr> 563 </tr>
566 564
567 </tbody> 565 </tbody>
568 </table> 566 </table>
569 567
570 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3> 568 <h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library F eatures</h3>
571 569
572 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p> 570 <p>This section lists C++11 library features that are not allowed in the Chromiu m codebase.</p>
573 571
574 <table id="blacklist_lib_list" class="unlined striped"> 572 <table id="blacklist_lib_list" class="unlined striped">
575 <tbody> 573 <tbody>
576 574
577 <tr> 575 <tr>
578 <th style='width:240px;'>Feature</th> 576 <th style='width:240px;'>Feature</th>
579 <th style='width:240px;'>Snippet</th> 577 <th style='width:240px;'>Snippet</th>
580 <th style='width:240px;'>Description</th> 578 <th style='width:240px;'>Description</th>
581 <th style='width:240px;'>Documentation Link</th> 579 <th style='width:240px;'>Documentation Link</th>
582 <th style='width:240px;'>Notes</th> 580 <th style='width:240px;'>Notes and Discussion Thread</th>
583 </tr> 581 </tr>
584 582
585 <tr> 583 <tr>
586 <td>Atomics</td> 584 <td>Atomics</td>
587 <td><code>&lt;atomic&gt;</code></td> 585 <td><code>&lt;atomic&gt;</code></td>
588 <td>Fine-grained atomic types and operations</td> 586 <td>Fine-grained atomic types and operations</td>
589 <td><a href="http://en.cppreference.com/w/cpp/atomic">Atomic operations library< /a></td> 587 <td><a href="http://en.cppreference.com/w/cpp/atomic">Atomic operations library< /a></td>
590 <td>Use in tcmalloc has caused <a href="http://crbug.com/572525">performance reg ressions</a>. Banned until we understand this better. <a href="https://groups.go ogle.com/a/chromium.org/d/topic/cxx/Ej3RAiaI44s/discussion">Discussion Thread</a ></td> 588 <td>Use in tcmalloc has caused <a href="http://crbug.com/572525">performance reg ressions</a>. Banned until we understand this better. <a href="https://groups.go ogle.com/a/chromium.org/forum/#!topic/cxx/Ej3RAiaI44s">Discussion Thread</a></td >
591 </tr> 589 </tr>
592 590
593 <tr> 591 <tr>
594 <td>Date and time utilities</td> 592 <td>Date and time utilities</td>
595 <td><code>&lt;chrono&gt;</code></td> 593 <td><code>&lt;chrono&gt;</code></td>
596 <td>A standard date and time library</td> 594 <td>A standard date and time library</td>
597 <td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a ></td> 595 <td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a ></td>
598 <td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the < code>base/</code> classes.</td> 596 <td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the < code>base/</code> classes.</td>
599 </tr> 597 </tr>
600 598
(...skipping 11 matching lines...) Expand all
612 <td>A standard regular expressions library</td> 610 <td>A standard regular expressions library</td>
613 <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library </a></td> 611 <td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library </a></td>
614 <td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td> 612 <td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td>
615 </tr> 613 </tr>
616 614
617 <tr> 615 <tr>
618 <td>Shared Pointers</td> 616 <td>Shared Pointers</td>
619 <td><code>std::shared_ptr</code></td> 617 <td><code>std::shared_ptr</code></td>
620 <td>Allows shared ownership of a pointer through reference counts</td> 618 <td>Allows shared ownership of a pointer through reference counts</td>
621 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td> 619 <td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr </a></td>
622 <td>Needs a lot more evaluation for Chromium, and there isn't enough of a push f or this feature. <a href="https://google.github.io/styleguide/cppguide.html#Owne rship_and_Smart_Pointers">Google Style Guide</a>. <a href="https://groups.google .com/a/chromium.org/d/topic/cxx/aT2wsBLKvzI/discussion">Discussion Thread</a>.</ td> 620 <td>Needs a lot more evaluation for Chromium, and there isn't enough of a push f or this feature. <a href="https://google.github.io/styleguide/cppguide.html#Owne rship_and_Smart_Pointers">Google Style Guide</a>. <a href="https://groups.google .com/a/chromium.org/forum/#!topic/cxx/aT2wsBLKvzI">Discussion Thread</a></td>
623 </tr> 621 </tr>
624 622
625 <tr> 623 <tr>
626 <td>Thread Library</td> 624 <td>Thread Library</td>
627 <td><code>&lt;thread&gt;</code> and related headers, including<br /> 625 <td><code>&lt;thread&gt;</code> and related headers, including<br />
628 <code>&lt;future&gt;</code>, <code>&lt;mutex&gt;</code>, <code>&lt;condition_var iable&gt;</code></td> 626 <code>&lt;future&gt;</code>, <code>&lt;mutex&gt;</code>, <code>&lt;condition_var iable&gt;</code></td>
629 <td>Provides a standard multithreading library using <code>std::thread</code> an d associates</td> 627 <td>Provides a standard multithreading library using <code>std::thread</code> an d associates</td>
630 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td> 628 <td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a> </td>
631 <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>M essageLoop</code> which would make it hard to replace. We should investigate usi ng standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td> 629 <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>M essageLoop</code> which would make it hard to replace. We should investigate usi ng standard mutexes, or unique_lock, etc. to replace our locking/synchronization classes.</td>
632 </tr> 630 </tr>
(...skipping 10 matching lines...) Expand all
643 work in all our compilers yet.</p> 641 work in all our compilers yet.</p>
644 642
645 <table id="blacklist_review_list" class="unlined striped"> 643 <table id="blacklist_review_list" class="unlined striped">
646 <tbody> 644 <tbody>
647 645
648 <tr> 646 <tr>
649 <th style='width:240px;'>Feature</th> 647 <th style='width:240px;'>Feature</th>
650 <th style='width:240px;'>Snippet</th> 648 <th style='width:240px;'>Snippet</th>
651 <th style='width:240px;'>Description</th> 649 <th style='width:240px;'>Description</th>
652 <th style='width:240px;'>Documentation Link</th> 650 <th style='width:240px;'>Documentation Link</th>
653 <th style='width:240px;'>Notes</th> 651 <th style='width:240px;'>Notes and Discussion Thread</th>
654 </tr> 652 </tr>
655 653
656 <tr> 654 <tr>
657 <td>Alignment Features</td> 655 <td>Alignment Features</td>
658 <td><code>alignas</code> specifier, <code>alignof</code> operator</td> 656 <td><code>alignas</code> specifier, <code>alignof</code> operator</td>
659 <td>Object alignment</td> 657 <td>Object alignment</td>
660 <td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas specifie r</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof opera tor</a></td> 658 <td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas specifie r</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof opera tor</a></td>
661 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/d/msg/cxx/rwXN02jzzq0/CpUc1ZzMBQAJ">Discussion thread</a></td> 659 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/forum/#!topic/cxx/rwXN02jzzq0">Discussion thread</a></td>
662 </tr> 660 </tr>
663 661
664 <tr> 662 <tr>
665 <td>Attributes</td> 663 <td>Attributes</td>
666 <td><code>[[<i>attribute_name</i>]]</code></td> 664 <td><code>[[<i>attribute_name</i>]]</code></td>
667 <td>Attaches properties to declarations that specific compiler implementations m ay use.</td> 665 <td>Attaches properties to declarations that specific compiler implementations m ay use.</td>
668 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz ed-attributes/">C++11 generalized attributes</a></td> 666 <td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generaliz ed-attributes/">C++11 generalized attributes</a></td>
669 <td></td> 667 <td></td>
670 </tr> 668 </tr>
671 669
672 <tr> 670 <tr>
673 <td>Inherited Constructors</td> 671 <td>Inherited Constructors</td>
674 <td><code>class Derived : Base {<br /> 672 <td><code>class Derived : Base {<br />
675 &nbsp;&nbsp;using Base::Base;<br /> 673 &nbsp;&nbsp;using Base::Base;<br />
676 };</code></td> 674 };</code></td>
677 <td>Allow derived classes to inherit constructors from base classes</td> 675 <td>Allow derived classes to inherit constructors from base classes</td>
678 <td><a href="http://en.cppreference.com/w/cpp/language/using_declaration">Using- declaration</a></td> 676 <td><a href="http://en.cppreference.com/w/cpp/language/using_declaration">Using- declaration</a></td>
679 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/d/msg/chromium-dev/BULzgIKZ-Ao/PLO7_GoVNvYJ">Discussion thread< /a></td> 677 <td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.co m/a/chromium.org/forum/#!topic/chromium-dev/BULzgIKZ-Ao">Discussion thread</a></ td>
680 </tr> 678 </tr>
681 679
682 <tr> 680 <tr>
683 <td>Raw String Literals</td> 681 <td>Raw String Literals</td>
684 <td><code>string <i>var</i>=R&quot;(<i>raw_string</i>)&quot;;</code></td> 682 <td><code>string <i>var</i>=R&quot;(<i>raw_string</i>)&quot;;</code></td>
685 <td>Allows a string to be encoded without any escape sequences, easing parsing i n regex expressions, for example</td> 683 <td>Allows a string to be encoded without any escape sequences, easing parsing i n regex expressions, for example</td>
686 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string li teral</a></td> 684 <td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string li teral</a></td>
687 <td>Causes incorrect line numbers in MSVS2013 and gcc. Reevaluate once that work s. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ 2kWQHbbuMHI">Discussion thread</a></td> 685 <td>Causes incorrect line numbers in MSVS2013 and gcc. Reevaluate once that work s. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ 2kWQHbbuMHI">Discussion thread</a></td>
688 </tr> 686 </tr>
689 687
(...skipping 21 matching lines...) Expand all
711 <p>The following C++ library features are currently disallowed. See the top of t his page on how to propose moving a feature from this list into the allowed or b anned sections. Note that not all of these features work in all our compilers ye t.</p> 709 <p>The following C++ library features are currently disallowed. See the top of t his page on how to propose moving a feature from this list into the allowed or b anned sections. Note that not all of these features work in all our compilers ye t.</p>
712 710
713 <table id="banned_stdlib" class="unlined striped"> 711 <table id="banned_stdlib" class="unlined striped">
714 712
715 <tbody> 713 <tbody>
716 <tr> 714 <tr>
717 <th style='width:240px;'>Feature</th> 715 <th style='width:240px;'>Feature</th>
718 <th style='width:240px;'>Snippet</th> 716 <th style='width:240px;'>Snippet</th>
719 <th style='width:240px;'>Description</th> 717 <th style='width:240px;'>Description</th>
720 <th style='width:240px;'>Documentation Link</th> 718 <th style='width:240px;'>Documentation Link</th>
721 <th style='width:240px;'>Style Guide Usage</th> 719 <th style='width:240px;'>Notes</th>
722 </tr> 720 </tr>
723 721
724 <tr> 722 <tr>
725 <td>Address Retrieval</td> 723 <td>Address Retrieval</td>
726 <td><code>std::addressof()</code></td> 724 <td><code>std::addressof()</code></td>
727 <td>Obtains the address of an object even with overloaded <code>operator&amp;</c ode></td> 725 <td>Obtains the address of an object even with overloaded <code>operator&amp;</c ode></td>
728 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</ a></td> 726 <td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</ a></td>
729 <td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguid e.html#Operator_Overloading">operator overloading</a> is rare and <code>&amp;</c ode> should suffice in most cases. May be preferable over <code>&amp;</code> for performing object identity checks.</td> 727 <td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguid e.html#Operator_Overloading">operator overloading</a> is rare and <code>&amp;</c ode> should suffice in most cases. May be preferable over <code>&amp;</code> for performing object identity checks.</td>
730 </tr> 728 </tr>
731 729
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 <td>Extracts the return type from the type signature of a function call invocati on at compile-time.</td> 790 <td>Extracts the return type from the type signature of a function call invocati on at compile-time.</td>
793 <td><a href="http://en.cppreference.com/w/cpp/types/result_of">std::result_of</a ></td> 791 <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-t ake-an-unrelated-function-type-as-a-type-argument">Why does std::result_of take an (unrelated) function type as a type argument?</a></td> 792 <td><a href="http://stackoverflow.com/questions/15486951/why-does-stdresult-of-t ake-an-unrelated-function-type-as-a-type-argument">Why does std::result_of take an (unrelated) function type as a type argument?</a></td>
795 </tr> 793 </tr>
796 794
797 <tr> 795 <tr>
798 <td>Function Objects</td> 796 <td>Function Objects</td>
799 <td><code>std::function</code></td> 797 <td><code>std::function</code></td>
800 <td>Wraps a standard polymorphic function</td> 798 <td>Wraps a standard polymorphic function</td>
801 <td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std:: function</a></td> 799 <td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std:: function</a></td>
802 <td></td> 800 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oID NuA">Discussion thread</a></td>
803 </tr> 801 </tr>
804 802
805 <tr> 803 <tr>
806 <td>Forward Lists</td> 804 <td>Forward Lists</td>
807 <td><code>std::forward_list</code></td> 805 <td><code>std::forward_list</code></td>
808 <td>Provides an efficient singly linked list</td> 806 <td>Provides an efficient singly linked list</td>
809 <td><a href="http://en.cppreference.com/w/cpp/container/forward_list">std::forwa rd_list</a></td> 807 <td><a href="http://en.cppreference.com/w/cpp/container/forward_list">std::forwa rd_list</a></td>
810 <td></td> 808 <td></td>
811 </tr> 809 </tr>
812 810
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 <td>Allows registration of functions to be called upon exit, allowing cleaner pr ogram exit than <code>abort()</code> or <code>exit</code></td> 870 <td>Allows registration of functions to be called upon exit, allowing cleaner pr ogram 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:qu ick_exit</a></td> 871 <td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">std:qu ick_exit</a></td>
874 <td></td> 872 <td></td>
875 </tr> 873 </tr>
876 874
877 <tr> 875 <tr>
878 <td>String-Number Conversion Functions</td> 876 <td>String-Number Conversion Functions</td>
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()</c ode></td> 877 <td><code>std::stoi()</code>, <code>std::stol()</code>, <code>std::stoul()</code >, <code>std::stoll</code>, <code>std::stoull()</code>, <code>std::stof()</code> , <code>std::stod()</code>, <code>std::stold()</code>, <code>std::to_string()</c ode></td>
880 <td>Converts strings to/from numbers</td> 878 <td>Converts strings to/from numbers</td>
881 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">std::sto i, std::stol, std::stoll</a>, <a href="http://en.cppreference.com/w/cpp/string/b asic_string/stoul">std::stoul, std::stoull</a>, <a href="http://en.cppreference. com/w/cpp/string/basic_string/stof">std::stof, std::stod, std::stold</a>, <a hre f="http://en.cppreference.com/w/cpp/string/basic_string/to_string">std::to_strin g</a></td> 879 <td><a href="http://en.cppreference.com/w/cpp/string/basic_string/stol">std::sto i, std::stol, std::stoll</a>, <a href="http://en.cppreference.com/w/cpp/string/b asic_string/stoul">std::stoul, std::stoull</a>, <a href="http://en.cppreference. com/w/cpp/string/basic_string/stof">std::stof, std::stod, std::stold</a>, <a hre f="http://en.cppreference.com/w/cpp/string/basic_string/to_string">std::to_strin g</a></td>
882 <td></td> 880 <td>May be useful to <a href="https://bugs.chromium.org/p/chromium/issues/detail ?id=593512">replace dmg_fp</a>.</td>
883 </tr> 881 </tr>
884 882
885 <tr> 883 <tr>
886 <td>System Errors</td> 884 <td>System Errors</td>
887 <td><code>&lt;system_error&gt;</code></td> 885 <td><code>&lt;system_error&gt;</code></td>
888 <td>Provides a standard system error library</td> 886 <td>Provides a standard system error library</td>
889 <td><a href="http://en.cppreference.com/w/cpp/header/system_error">Standard libr ary header &lt;system_error&gt;</a></td> 887 <td><a href="http://en.cppreference.com/w/cpp/header/system_error">Standard libr ary header &lt;system_error&gt;</a></td>
890 <td></td> 888 <td></td>
891 </tr> 889 </tr>
892 890
893 <tr> 891 <tr>
894 <td>Type-Generic Math Functions</td> 892 <td>Type-Generic Math Functions</td>
895 <td><code>&lt;ctgmath&gt;</code></td> 893 <td><code>&lt;ctgmath&gt;</code></td>
896 <td>Provides a means to call real or complex functions based on the type of argu ments</td> 894 <td>Provides a means to call real or complex functions based on the type of argu ments</td>
897 <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library h eader &lt;ctgmath&gt;</a></td> 895 <td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library h eader &lt;ctgmath&gt;</a></td>
898 <td></td> 896 <td></td>
899 </tr> 897 </tr>
900 898
901 <tr> 899 <tr>
902 <td>Type Info Enhancements</td> 900 <td>Type Info Enhancements</td>
903 <td><code>std::type_index</code>, <code>std::type_info::hash_code()</code></td> 901 <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, a ssigned, or hashed</td> 902 <td>Allows type information (most often within containers) that can be copied, a ssigned, 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::t ype_info::hash_code</a></td> 903 <td><a href="http://en.cppreference.com/w/cpp/types/type_index">std::type_index< /a>, <a href="http://en.cppreference.com/w/cpp/types/type_info/hash_code">std::t ype_info::hash_code</a></td>
906 <td><code>std::type_index</code> is a thin wrapper for <code>std::type_info</cod e>, allowing you to use it directly within both associative and unordered contai ners</td> 904 <td><code>std::type_index</code> is a thin wrapper for <code>std::type_info</cod e>, allowing you to use it directly within both associative and unordered contai ners.</td>
907 </tr> 905 </tr>
908 906
909 <tr> 907 <tr>
910 <td>Variadic Copy Macro</td> 908 <td>Variadic Copy Macro</td>
911 <td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> 909 <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> 910 <td>Makes a copy of the variadic function arguments</td>
913 <td><a href="http://en.cppreference.com/w/cpp/utility/variadic/va_copy">va_copy< /a></td> 911 <td><a href="http://en.cppreference.com/w/cpp/utility/variadic/va_copy">va_copy< /a></td>
914 <td></td> 912 <td></td>
915 </tr> 913 </tr>
916 914
(...skipping 13 matching lines...) Expand all
930 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert">std::wstri ng_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert ">std::wbuffer_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/cod ecvt_utf8">std::codecvt_utf8</a>, <a href="http://en.cppreference.com/w/cpp/loca le/codecvt_utf16">std::codecvt_utf16</a>, <a href="http://en.cppreference.com/w/ cpp/locale/codecvt_utf8_utf16">std::codecvt_utf8_utf16</a></td> 928 <td><a href="http://en.cppreference.com/w/cpp/locale/wstring_convert">std::wstri ng_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/wbuffer_convert ">std::wbuffer_convert</a>, <a href="http://en.cppreference.com/w/cpp/locale/cod ecvt_utf8">std::codecvt_utf8</a>, <a href="http://en.cppreference.com/w/cpp/loca le/codecvt_utf16">std::codecvt_utf16</a>, <a href="http://en.cppreference.com/w/ cpp/locale/codecvt_utf8_utf16">std::codecvt_utf8_utf16</a></td>
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 use ful for consuming non-ASCII data.</td> 929 <td>Non-UTF-8 text is banned by the <a href="https://google.github.io/styleguide /cppguide.html#Non-ASCII_Characters">Google Style Guide</a>. However, may be use ful for consuming non-ASCII data.</td>
932 </tr> 930 </tr>
933 931
934 </tbody> 932 </tbody>
935 </table> 933 </table>
936 934
937 </div> 935 </div>
938 </body> 936 </body>
939 </html> 937 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698