blob: b83449f05a047542fe1276351e1708d17437926e [file] [log] [blame]
pkastinga92fd062016-11-02 22:38:581<!DOCTYPE html>
Nico Weber019d40f2014-09-23 20:21:592<!--
3Copyright 2014 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7<html>
8<head>
9<meta charset="utf-8">
bratell85e14ac2014-12-17 17:26:3810<title>C++11 use in Chromium</title>
Nico Weber019d40f2014-09-23 20:21:5911<link rel="stylesheet" href="c++11.css">
12<style>
13table 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
pkastingfc30cf42016-11-04 00:49:0324checkout and is part of the more general
25<a href="https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md">
26Chromium C++ style guide</a>.</i></p>
Nico Weber019d40f2014-09-23 20:21:5927
pkastingfc30cf42016-11-04 00:49:0328<p>This summarizes the new and updated features in C++11 (for both the language
29itself and the Standard Library) from the perspective of what's allowed in
30Chromium. When applicable, it contains pointers to more detailed information.
31This Guide applies to Chromium and its subprojects, though subprojects can
32choose to be more restrictive if necessary for toolchain support.</p>
Nico Weber019d40f2014-09-23 20:21:5933
pkastingfc30cf42016-11-04 00:49:0334<p>You can propose changing the status of a feature by sending an email to
35<a href="https://groups.google.com/a/chromium.org/forum/#!forum/cxx">
36[email protected]</a>. Include a short blurb on what the feature is and why you
37think it should or should not be allowed, along with links to any relevant
38previous discussion. If the list arrives at some consensus, send a codereview to
39change this file accordingly, linking to your discussion thread.</p>
Nico Weber019d40f2014-09-23 20:21:5940
danakj4fd49fe42015-11-18 20:54:1641<h2>Table of Contents</h2>
42<ol class="toc">
43<li>Allowed Features<ol>
44 <li><a href="#core-whitelist">Language</a></li>
45 <li><a href="#library-whitelist">Library</a></li>
46</ol></li>
47<li>Banned Features<ol>
48 <li><a href="#core-blacklist">Language</a></li>
49 <li><a href="#library-blacklist">Library</a></li>
50</ol></li>
51<li>To Be Discussed<ol>
52 <li><a href="#core-review">Language</a></li>
53 <li><a href="#library-review">Library</a></li>
54</ol></li>
55</ol>
56
57<h2 id="whitelist"><a name="core-whitelist"></a>C++11 Allowed Features</h2>
Nico Weber019d40f2014-09-23 20:21:5958
59<p>The following features are currently allowed.</p>
60
61<table id="whitelist_lang_list" class="unlined striped">
62<tbody>
63
64<tr>
65<th style='width:220px;'>Feature</th>
66<th style='width:260px;'>Snippet</th>
67<th style='width:240px;'>Description</th>
68<th style='width:240px;'>Documentation Link</th>
69<th style='width:240px;'>Notes and Discussion Thread</th>
70</tr>
71
72<tr>
pkastingf5279482016-07-27 02:18:2073<td>__func__ Local Variable</td>
74<td><code>__func__</code></td>
75<td>Provides a local variable containing the name of the enclosing function</td>
pkasting7f0693b32016-10-31 20:27:5076<td><a href="http://en.cppreference.com/w/cpp/language/function#func">__func__</a></td>
pkastingf5279482016-07-27 02:18:2077<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>
78</tr>
79
80<tr>
Nico Weber019d40f2014-09-23 20:21:5981<td>Angle Bracket Parsing in Templates</td>
pkasting07c0959a2016-04-14 22:16:4382<td><code>&gt;&gt;</code> for <code>&gt; &gt;</code>, <code>&lt;::</code> for <code>&lt; ::</code></td>
Nico Weber019d40f2014-09-23 20:21:5983<td>More intuitive parsing of template parameters</td>
pkasting7f0693b32016-10-31 20:27:5084<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 Weber019d40f2014-09-23 20:21:5985<td>Recommended to increase readability. Approved without discussion.</td>
86</tr>
87
88<tr>
ericrk491cd202015-12-01 01:09:1689<td>Arrays</td>
90<td><code>std::array</code></td>
91<td>A fixed-size replacement for built-in arrays, with STL support</td>
pkasting07c0959a2016-04-14 22:16:4392<td><a href="http://en.cppreference.com/w/cpp/container/array">std::array</a></td>
pkasting0cb5bd42016-11-02 20:55:5893<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>
ericrk491cd202015-12-01 01:09:1694</tr>
95
96<tr>
Nico Weber3537d872014-09-25 19:10:0497<td>Automatic Types</td>
98<td><code>auto</code></td>
99<td>Automatic type deduction</td>
pkasting07c0959a2016-04-14 22:16:43100<td><a href="http://en.cppreference.com/w/cpp/language/auto">auto specifier</a></td>
vmpstr1ccc7642017-02-14 22:06:00101<td>General guidance in <a href="https://google.github.io/styleguide/cppguide.html#auto">Google Style Guide</a>. Additionally, do not use <code>auto</code> to deduce a raw pointer, use <code>auto*</code> instead. <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 Weber3537d872014-09-25 19:10:04102</tr>
103
104<tr>
pkastingce246fa2016-04-14 17:54:08105<td>Constant Expressions</td>
106<td><code>constexpr</code></td>
107<td>Compile-time constant expressions</td>
108<td><a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr specifier</a></td>
pkasting0cb5bd42016-11-02 20:55:58109<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>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/BE9xLUI-Vww">Discussion thread</a></td>
pkastingce246fa2016-04-14 17:54:08110</tr>
111
112<tr>
thakis12bfc742014-10-28 04:37:49113<td>Declared Type Accessor</td>
114<td><code>decltype(<i>expression</i>)</code></td>
pkasting07c0959a2016-04-14 22:16:43115<td>Provides a means to determine the type of an expression at compile-time, useful most often in templates.</td>
116<td><a href="http://en.cppreference.com/w/cpp/language/decltype">decltype specifier</a></td>
thakis12bfc742014-10-28 04:37:49117<td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread</a></td>
118</tr>
119
120<tr>
mdempsky2319bef2014-11-07 05:25:12121<td>Default Function Creation</td>
122<td><code><i>Function</i>(<i>arguments</i>) = default;</code></td>
pkasting07c0959a2016-04-14 22:16:43123<td>Instructs the compiler to generate a default version of the indicated function</td>
124<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>
125<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/qgU4mh_MpGA">Discussion thread</a></td>
mdempsky2319bef2014-11-07 05:25:12126</tr>
127
128<tr>
vmpstrfcdc338e2015-12-09 19:51:08129<td>Default Function Template Arguments</td>
pkasting07c0959a2016-04-14 22:16:43130<td><code>template &lt;typename T = <i>type</i>&gt;<br />
131<i>type</i> <i>Function</i>(T <i>var</i>) {}</code></td>
vmpstrfcdc338e2015-12-09 19:51:08132<td>Allow function templates, like classes, to have default arguments</td>
pkasting07c0959a2016-04-14 22:16:43133<td><a href="http://stackoverflow.com/questions/2447458/default-template-arguments-for-function-templates">Default Template Arguments for Function Templates</a></td>
vmpstrfcdc338e2015-12-09 19:51:08134<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/9KtaAsome-o">Discussion thread</a></td>
135</tr>
136
137<tr>
andersr127772e2014-11-07 17:02:52138<td>Delegated Constructors</td>
pkasting07c0959a2016-04-14 22:16:43139<td><code>Class() : Class(0) {}<br />
140Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0) {}</code></td>
andersr127772e2014-11-07 17:02:52141<td>Allow overloaded constructors to use common initialization code</td>
pkasting07c0959a2016-04-14 22:16:43142<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>
andersr127772e2014-11-07 17:02:52143<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/0zVA8Ctx3Xo">Discussion thread</a></td>
144</tr>
145
146<tr>
thakisb8fbe312014-10-29 01:30:42147<td>Enumerated Type Classes and Enum Bases</td>
pkasting07c0959a2016-04-14 22:16:43148<td><code>enum class <i>classname</i><br />
149enum class <i>classname</i> : <i>base-type</i><br />
150enum <i>enumname</i> : <i>base-type</i></code></td>
151<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>
pkasting7f0693b32016-10-31 20:27:50152<td><a href="http://en.cppreference.com/w/cpp/language/enum">enumeration declaration</a></td>
pkasting07c0959a2016-04-14 22:16:43153<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>
mdempsky4f2d4102014-10-20 17:31:27154</tr>
155
156<tr>
jbromane18d31482016-04-13 18:06:47157<td>Explicit Conversion Operators</td>
pkasting07c0959a2016-04-14 22:16:43158<td><code>explicit operator <i>type</i>() { ... }</code></td>
jbromane18d31482016-04-13 18:06:47159<td>Allows conversion operators that cannot be implicitly invoked</td>
pkasting07c0959a2016-04-14 22:16:43160<td><a href="http://en.cppreference.com/w/cpp/language/explicit">explicit specifier</a></td>
pkasting0cb5bd42016-11-02 20:55:58161<td>Prefer to the "safe bool" idiom. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zGF1SrQ-1HQ">Discussion thread</a></td>
jbromane18d31482016-04-13 18:06:47162</tr>
163
164<tr>
dcheng5f98d332014-09-24 22:12:10165<td>Final Specifier</td>
166<td><code>final</code></td>
167<td> Indicates that a class or function is final and cannot be overridden</td>
pkasting7f0693b32016-10-31 20:27:50168<td><a href="http://en.cppreference.com/w/cpp/language/final">final specifier</a></td>
pkasting07c0959a2016-04-14 22:16:43169<td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td>
dcheng5f98d332014-09-24 22:12:10170</tr>
171
172<tr>
mdempsky2319bef2014-11-07 05:25:12173<td>Function Suppression</td>
174<td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td>
pkasting07c0959a2016-04-14 22:16:43175<td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td>
pkasting7f0693b32016-10-31 20:27:50176<td><a href="http://en.cppreference.com/w/cpp/language/function#Deleted_functions">Deleted functions</a></td>
mdempsky2319bef2014-11-07 05:25:12177<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/i1o7-RNRnMs">Discussion thread</a></td>
178</tr>
179
180<tr>
pkasting3e35c532016-11-03 22:54:14181<td>Inherited Constructors</td>
182<td><code>class Derived : Base {<br />
183&nbsp;&nbsp;using Base::Base;<br />
184};</code></td>
185<td>Allows derived classes to inherit constructors from base classes</td>
186<td><a href="http://en.cppreference.com/w/cpp/language/using_declaration#Inheriting_constructors">Inheriting constructors</a></td>
187<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/BULzgIKZ-Ao">Discussion thread</a></td>
188</tr>
189
190<tr>
thakisa907c312014-11-04 23:38:06191<td>Lambda Expressions</td>
192<td><code>[<i>captures</i>](<i>params</i>) -&gt; <i>ret</i> { <i>body</i> }</code></td>
193<td>Anonymous functions</td>
194<td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td>
pkasting0cb5bd42016-11-02 20:55:58195<td>Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code>&lt;algorithm&gt;</code>. Be careful with default captures (<code>[=]</code>, <code>[&amp;]</code>), and do not bind 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 prevent 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.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>. <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">Another discussion thread</a> (about captureless lambdas and <code>base::Bind</code>).</td>
thakisa907c312014-11-04 23:38:06196</tr>
197
198<tr>
Nico Weber019d40f2014-09-23 20:21:59199<td>Local Types as Template Arguments</td>
pkasting0fcb7762016-04-29 00:44:37200<td><code>void func() {<br />
201&nbsp;&nbsp;class Pred {<br />
202&nbsp;&nbsp;&nbsp;public:<br />
203&nbsp;&nbsp;&nbsp;&nbsp;bool operator()(const T&) { ... }<br />
204&nbsp;&nbsp;};<br />
205&nbsp;&nbsp;std::remove_if(vec.begin(), vec.end(), Pred());</code></td>
Nico Weber019d40f2014-09-23 20:21:59206<td>Allows local and unnamed types as template arguments</td>
pkasting07c0959a2016-04-14 22:16:43207<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 Weber019d40f2014-09-23 20:21:59208<td>Usage should be rare. Approved without discussion.</td>
209</tr>
210
211<tr>
pkastingc6a6ebf12016-10-31 20:38:40212<td>Noexcept Specifier</td>
213<td><code>void f() noexcept</code></td>
214<td>Specifies that a function will not throw exceptions</td>
215<td><a href="http://en.cppreference.com/w/cpp/language/noexcept_spec">noexcept specifier</a></td>
216<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>
217</tr>
218
219<tr>
hashimoto42a14e862015-01-22 15:21:41220<td>Non-Static Class Member Initializers</td>
pkasting07c0959a2016-04-14 22:16:43221<td><code>class C {<br />
222&nbsp;&nbsp;<i>type</i> <i>var</i> = <i>value</i>;<br />
223&nbsp;&nbsp;C()&nbsp;&nbsp;// copy-initializes <i>var</i></code>
hashimoto42a14e862015-01-22 15:21:41224<td>Allows non-static class members to be initialized at their definitions (outside constructors)</td>
pkasting07c0959a2016-04-14 22:16:43225<td><a href="http://en.cppreference.com/w/cpp/language/data_members">Non-static data members</a></td>
226<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB-DySA4V0">Discussion thread</a></td>
hashimoto42a14e862015-01-22 15:21:41227</tr>
228
229<tr>
danakj8bc9fc12014-09-24 20:45:29230<td>Null Pointer Constant</td>
231<td><code>nullptr</code></td>
232<td>Declares a type-safe null pointer</td>
pkasting7f0693b32016-10-31 20:27:50233<td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr, the pointer literal</a></td>
pkasting0cb5bd42016-11-02 20:55:58234<td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/NULL">Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread</a></td>
danakj8bc9fc12014-09-24 20:45:29235</tr>
236
dcheng5f98d332014-09-24 22:12:10237<tr>
238<td>Override Specifier</td>
239<td><code>override</code></td>
240<td>Indicates that a class or function overrides a base implementation</td>
pkasting7f0693b32016-10-31 20:27:50241<td><a href="http://en.cppreference.com/w/cpp/language/override">override specifier</a></td>
pkasting07c0959a2016-04-14 22:16:43242<td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td>
dcheng5f98d332014-09-24 22:12:10243</tr>
244
245<tr>
Nico Weber3537d872014-09-25 19:10:04246<td>Range-Based For Loops</td>
247<td><code>for (<i>type</i> <i>var</i> : <i>range</i>)</code></td>
pkasting07c0959a2016-04-14 22:16:43248<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>
249<td><a href="http://en.cppreference.com/w/cpp/language/range-for">Range-based for loop</a></td>
Nico Weber3537d872014-09-25 19:10:04250<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>
251</tr>
252
253<tr>
danakj2c5aee92015-12-07 20:40:27254<td>Rvalue References</td>
pkasting07c0959a2016-04-14 22:16:43255<td><code>T(T&amp;&amp; t)</code> and <code>T&amp; operator=(T&amp;&amp; t)<br/><br/>
256template &lt;typename T&gt;<br/>void Function(T&& t) { ... }</code></td>
danakj2c5aee92015-12-07 20:40:27257<td>Reference that only binds to a temporary object</td>
pkasting7f0693b32016-10-31 20:27:50258<td><a href="http://en.cppreference.com/w/cpp/language/reference#Rvalue_references">Rvalue references</a></td>
pkasting0cb5bd42016-11-02 20:55:58259<td>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://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/UnRaORb4TSw">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/Q526tkruXpM">Another discussion thread</a></td>
danakj2c5aee92015-12-07 20:40:27260</tr>
261
262<tr>
dcheng5f98d332014-09-24 22:12:10263<td>Standard Integers</td>
pkasting07c0959a2016-04-14 22:16:43264<td>Typedefs within <code>&lt;stdint.h&gt;</code> and <code>&lt;inttypes&gt;</code></td>
dcheng5f98d332014-09-24 22:12:10265<td>Provides fixed-size integers independent of platforms</td>
pkasting7f0693b32016-10-31 20:27:50266<td><a href="http://en.cppreference.com/w/cpp/header/cstdint">Standard library header &lt;cstdint&gt;</a></td>
pkasting0cb5bd42016-11-02 20:55:58267<td>Approved without discussion. Required by the <a href="http://google.github.io/styleguide/cppguide.html#Integer_Types">Google Style Guide</a>.</td>
dcheng5f98d332014-09-24 22:12:10268</tr>
269
Nico Weber3537d872014-09-25 19:10:04270<tr>
271<td>Static Assertions</td>
272<td><code>static_assert(<i>bool</i>, <i>string</i>)</code></td>
273<td>Tests compile-time conditions</td>
274<td><a href="http://en.cppreference.com/w/cpp/language/static_assert">Static Assertion</a></td>
275<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/POISBQEhGzU">Discussion thread</a></td>
276</tr>
277
278<tr>
mikhail.pozdnyakovbac797052016-05-16 15:48:10279<td>Trailing Return Types</td>
280<td><code>auto <i>function declaration</i> -> <i>return_type</i></code></td>
281<td>Allows trailing function return value syntax</td>
282<td><a href="http://en.cppreference.com/w/cpp/language/function">Declaring functions</a></td>
pkasting0cb5bd42016-11-02 20:55:58283<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>
mikhail.pozdnyakovbac797052016-05-16 15:48:10284</tr>
285
286<tr>
pkasting7f0693b32016-10-31 20:27:50287<td>Type Aliases ("using" instead of "typedef")</td>
288<td><code>using <i>new_alias</i> = <i>typename</i></code></td>
289<td>Allows parameterized typedefs</td>
290<td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias, alias template</a></td>
291<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>
292</tr>
293
294<tr>
pkasting0fcb7762016-04-29 00:44:37295<td>Uniform Initialization Syntax</td>
296<td><code><i>type</i> <i>name</i> {[<i>value</i> ..., <i>value</i>]};</code></td>
297<td>Allows any object of primitive, aggregate or class type to be initialized using brace syntax</td>
298<td><a href="http://www.stroustrup.com/C++11FAQ.html#uniform-init">Uniform initialization syntax and semantics</a></td>
299<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>
300</tr>
301
302<tr>
kwiberg882859a2016-08-16 09:42:21303<td>Union Class Members</td>
304<td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td>
305<td>Allows class type members</td>
pkasting7f0693b32016-10-31 20:27:50306<td><a href="http://en.cppreference.com/w/cpp/language/union">Union declaration</a></td>
pkasting0cb5bd42016-11-02 20:55:58307<td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/3oK78s1ntgU">Discussion thread</a></td>
kwiberg882859a2016-08-16 09:42:21308</tr>
309
310<tr>
Nico Weber3537d872014-09-25 19:10:04311<td>Variadic Macros</td>
312<td><code>#define <i>MACRO</i>(...) <i>Impl</i>(<i>args</i>, __VA_ARGS__)</code></td>
313<td>Allows macros that accept a variable number of arguments</td>
pkasting07c0959a2016-04-14 22:16:43314<td><a href="http://stackoverflow.com/questions/4786649/are-variadic-macros-nonstandard">Are Variadic macros nonstandard?</a></td>
Nico Weber3537d872014-09-25 19:10:04315<td>Usage should be rare. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread</a></td>
316</tr>
317
318<tr>
319<td>Variadic Templates</td>
320<td><code>template &lt;<i>typename</i> ... <i>arg</i>&gt;</code></td>
321<td>Allows templates that accept a variable number of arguments</td>
pkasting07c0959a2016-04-14 22:16:43322<td><a href="http://en.cppreference.com/w/cpp/language/parameter_pack">Parameter pack</a></td>
avi906dbd5c2014-09-26 22:11:42323<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 Weber3537d872014-09-25 19:10:04324</tr>
325
Nico Weber019d40f2014-09-23 20:21:59326</tbody>
327</table>
328
danakj4fd49fe42015-11-18 20:54:16329<h2 id="whitelist"><a name="library-whitelist"></a>C++11 Allowed Library Features</h2>
Nico Weberc8eb8ca2015-11-11 00:23:34330
331<p>The following library features are currently allowed.</p>
332
333<table id="whitelist_lib_list" class="unlined striped">
334<tbody>
335
336<tr>
337<th style='width:240px;'>Feature or Library</th>
338<th style='width:240px;'>Snippet</th>
339<th style='width:240px;'>Description</th>
340<th style='width:240px;'>Documentation Link</th>
pkasting0cb5bd42016-11-02 20:55:58341<th style='width:240px;'>Notes and Discussion Thread</th>
Nico Weberc8eb8ca2015-11-11 00:23:34342</tr>
343
344<tr>
davidben4507eaa2015-11-19 19:07:06345<td>Access to underlying <code>std::vector</code> data</td>
346<td><code>v.data()</code></td>
347<td>Returns a pointer to a <code>std::vector</code>'s underlying data, accounting for empty vectors.</td>
348<td><a href="http://en.cppreference.com/w/cpp/container/vector/data">std::vector::data</a></td>
pkasting2f966af2015-12-06 01:52:18349<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/16V7fmtbzok">Discussion thread</a></td>
davidben4507eaa2015-11-19 19:07:06350</tr>
351
352<tr>
pkasting3adbbcc2016-02-04 01:52:38353<td>Algorithms</td>
354<td>All C++11 features in <code>&lt;algorithm&gt;</code>:<br/>
355<code>all_of</code>, <code>any_of</code>, <code>none_of</code><br/>
356<code>find_if_not</code><br/>
357<code>copy_if</code>, <code>copy_n</code><br/>
358<code>move</code>, <code>move_backward</code> (see note)<br/>
359<code>shuffle</code><br/>
360<code>is_partitioned</code>, <code>partition_copy</code>, <code>partition_point</code><br/>
361<code>is_sorted</code>, <code>is_sorted_until</code><br/>
362<code>is_heap</code>, <code>is_heap_until</code><br/>
363<code>minmax</code>, <code>minmax_element</code><br/>
pkasting07c0959a2016-04-14 22:16:43364<code>is_permutation<br/></td>
pkasting3adbbcc2016-02-04 01:52:38365<td>Safe and performant implementations of common algorithms</td>
pkasting7f0693b32016-10-31 20:27:50366<td><a href="http://en.cppreference.com/w/cpp/header/algorithm">Standard library header &lt;algorithm&gt;</a></td>
pkasting0cb5bd42016-11-02 20:55:58367<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>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/UJQk8S1IuHk">Discussion thread</a>. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZvQ8'>Another discussion thread</a></td>
pkasting3adbbcc2016-02-04 01:52:38368</tr>
369
370<tr>
ruudab425288a2015-11-23 21:46:57371<td>Begin and End Non-Member Functions</td>
pkasting07c0959a2016-04-14 22:16:43372<td><code>std::begin()</code>, <code>std::end()</code></td>
pkastinga234a072016-02-11 01:35:53373<td>Allows use of free functions on any container, including fixed-size arrays</td>
pkasting07c0959a2016-04-14 22:16:43374<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>
pkasting0cb5bd42016-11-02 20:55:58375<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/forum/#!topic/cxx/5iFNE8P5qT4">Discussion thread</a></td>
ruudab425288a2015-11-23 21:46:57376</tr>
377
378<tr>
pkasting2f966af2015-12-06 01:52:18379<td>Conditional Type Selection</td>
pkasting07c0959a2016-04-14 22:16:43380<td><code>std::enable_if</code>, <code>std::conditional</code></td>
pkasting2f966af2015-12-06 01:52:18381<td>Enables compile-time conditional type selection</td>
pkasting07c0959a2016-04-14 22:16:43382<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>
pkasting2f966af2015-12-06 01:52:18383<td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td>
384</tr>
385
386<tr>
pkastinga234a072016-02-11 01:35:53387<td>Constant Iterator Methods on Containers</td>
pkasting07c0959a2016-04-14 22:16:43388<td>E.g. <code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></td>
pkastinga234a072016-02-11 01:35:53389<td>Allows more widespread use of <code>const_iterator</code></td>
pkasting07c0959a2016-04-14 22:16:43390<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>
pkasting0cb5bd42016-11-02 20:55:58391<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. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/cS83F_buqLM">Discussion thread</a></td>
pkasting07c0959a2016-04-14 22:16:43392</tr>
393
394<tr>
395<td>Declared Type As Value</td>
396<td><code>std::declval&lt;<i>class</i>&gt;()</code></td>
397<td>Converts a type to a reference of the type to allow use of members of the type without constructing it in templates.</td>
398<td><a href="http://en.cppreference.com/w/cpp/utility/declval">std::declval</a></td>
399<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 Weberc8eb8ca2015-11-11 00:23:34400</tr>
jsbella882f622015-11-13 02:02:14401
402<tr>
pkasting53121c42016-02-04 22:14:36403<td>Emplacement methods for containers</td>
404<td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</code>, <code>emplace_hint()</code></td>
pkasting07c0959a2016-04-14 22:16:43405<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>
pkasting53121c42016-02-04 22:14:36406<td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back">std::vector::emplace_back</a></td>
pkasting07c0959a2016-04-14 22:16:43407<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>
pkasting53121c42016-02-04 22:14:36408</tr>
409
410<tr>
davidben411d3f72016-01-22 01:41:41411<td>Forwarding references</td>
412<td><code>std::forward()</code></td>
413<td>Perfectly forwards arguments (including rvalues)</td>
pkasting0fcb7762016-04-29 00:44:37414<td><a href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a></td>
pkasting0cb5bd42016-11-02 20:55:58415<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/forum/#!topic/cxx/-O7euklhSxs">Discussion thread</a>
davidben411d3f72016-01-22 01:41:41416</td>
417</tr>
418
419<tr>
pkasting0fcb7762016-04-29 00:44:37420<td>Initializer Lists</td>
421<td><code>std::initializer_list&lt;T&gt;</code></td>
422<td>Allows containers to be initialized with aggregate elements</td>
423<td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list">std::initializer_list</a></td>
pkasting0cb5bd42016-11-02 20:55:58424<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. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/TQQ-L51_naM">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UpiCpuu9UNc">Another discussion thread</a></td>
pkasting0fcb7762016-04-29 00:44:37425</tr>
426
427<tr>
pkasting3adbbcc2016-02-04 01:52:38428<td>Math functions</td>
429<td>All C++11 features in <code>&lt;cmath&gt;</code>, e.g.:<br/>
430<code>INFINITY</code>, <code>NAN</code>, <code>FP_NAN</code><br/>
431<code>float_t</code>, <code>double_t</code><br/>
432<code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/>
433<code>isinf</code>, <code>isnan</code><br/></td>
434<td>Useful for math-related code</td>
pkasting7f0693b32016-10-31 20:27:50435<td><a href="http://en.cppreference.com/w/cpp/header/cmath">Standard library header &lt;cmath&gt;</a></td>
pkasting3adbbcc2016-02-04 01:52:38436<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></td>
437</tr>
438
439<tr>
pkasting2f966af2015-12-06 01:52:18440<td>Move Iterator Adaptor</td>
441<td><code>std::make_move_iterator()</code></td>
442<td>Wraps an iterator so that it moves objects instead of copying them.</td>
443<td><a href="http://en.cppreference.com/w/cpp/iterator/make_move_iterator">std::make_move_iterator</a></td>
pkasting0cb5bd42016-11-02 20:55:58444<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>
vmpstrf484f722015-11-16 23:10:31445</tr>
446
vmpstrc52317f2015-11-18 08:43:26447<tr>
pkasting2f966af2015-12-06 01:52:18448<td>Move Semantics</td>
449<td><code>std::move()</code></td>
450<td>Facilitates efficient move operations</td>
pkasting0fcb7762016-04-29 00:44:37451<td><a href="http://en.cppreference.com/w/cpp/utility/move">std::move</a></td>
danakj2c5aee92015-12-07 20:40:27452<td><a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/x_dWFxJFdbM'>Discussion thread</a></td>
vmpstrc52317f2015-11-18 08:43:26453</tr>
454
455<tr>
pkasting0cb5bd42016-11-02 20:55:58456<td>Null Pointer Type</td>
457<td><code>std::nullptr_t</code></td>
458<td>Allows referencing the type of <code>nullptr</code>, e.g. in templates</td>
459<td><a href="http://en.cppreference.com/w/cpp/types/nullptr_t">std::nullptr_t</a></td>
460<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/UNaXc8R7eJ0">Discussion thread</a></td>
461</tr>
462
463<tr>
pkastingcb5ed942016-11-03 00:59:12464<td>Random Number Generators</td>
465<td><code>&lt;random&gt;</code></td>
466<td>Random number generation algorithms and utilities</td>
467<td><a href="http://en.cppreference.com/w/cpp/numeric/random">Pseudo-random number generation</a></td>
468<td>Because the standard does not define precisely how the <code><i>xxx</i>_distribution</code> objects generate output, the same object may produce different output for the same seed across platforms, or even across different versions of the STL. Do not use these objects in any scenario where behavioral consistency is required. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/MLgK9vCE4BA">Discussion thread</a></td>
469</tr>
470
471<tr>
pkastinga393564842016-11-03 23:55:20472<td>Raw String Literals</td>
473<td><code>string <i>var</i>=R&quot;(<i>raw_string</i>)&quot;;</code></td>
474<td>Allows a string to be encoded without any escape sequences, easing parsing in regex expressions, for example</td>
475<td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string literal</a></td>
476<td>Beware of passing these as macro arguments, which can trigger a <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824">lexer bug</a> on older GCC versions. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/2kWQHbbuMHI">Discussion thread</a></td>
477</tr>
478
479<tr>
pkasting9022cb42016-02-05 00:08:56480<td>String Direct Reference Functions</td>
pkasting07c0959a2016-04-14 22:16:43481<td><code>std::string::front()</code>, <code>std::string::back()</code></td>
pkasting9022cb42016-02-05 00:08:56482<td>Returns a reference to the front or back of a string</td>
pkasting07c0959a2016-04-14 22:16:43483<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>
pkasting9022cb42016-02-05 00:08:56484<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/DRJuROAYCV4">Discussion thread</a></td>
485</tr>
486
487<tr>
vmpstrc52317f2015-11-18 08:43:26488<td>Type Traits</td>
pkasting3adbbcc2016-02-04 01:52:38489<td>All C++11 features in <code>&lt;type_traits&gt;</code> except for aligned storage (see separate item), e.g.:<br/>
490<code>integral_constant</code><br/>
491<code>is_floating_point</code>, <code>is_rvalue_reference</code>, <code>is_scalar</code><br/>
492<code>is_const</code>, <code>is_pod</code>, <code>is_unsigned</code><br/>
493<code>is_default_constructible</code>, <code>is_move_constructible</code>, <code>is_copy_assignable</code><br/>
pkasting07c0959a2016-04-14 22:16:43494<code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></td>
vmpstrc52317f2015-11-18 08:43:26495<td>Allows compile-time inspection of the properties of types</td>
pkasting7f0693b32016-10-31 20:27:50496<td><a href="http://en.cppreference.com/w/cpp/header/type_traits">Standard library header &lt;type_traits&gt;</a></td>
pkasting0cb5bd42016-11-02 20:55:58497<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>
vmpstrc52317f2015-11-18 08:43:26498</tr>
499
ricea5db2dfe2015-12-04 14:26:46500<tr>
dcheng7bebfa462016-04-03 23:15:25501<td>Tuples</td>
pkasting00ebe862016-05-11 01:48:50502<td>All C++11 features in <code>&lt;tuple&gt;</code>, e.g. <code>std::tie</code> and <code>std::tuple</code>.</td>
dcheng7bebfa462016-04-03 23:15:25503<td>A fixed-size ordered collection of values of mixed types</td>
pkasting7f0693b32016-10-31 20:27:50504<td><a href="http://en.cppreference.com/w/cpp/header/tuple">Standard library header &lt;tuple&gt;</a></td>
pkasting0cb5bd42016-11-02 20:55:58505<td>libstdc++ 4.6 has a bug where <code>std::get</code> can return an lvalue-reference 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/#!topic/cxx/0NnCRmMY1xY">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/VA7Ej2IWS2w">Another discussion thread</a></td>
dcheng7bebfa462016-04-03 23:15:25506</tr>
507
508<tr>
davidben411d3f72016-01-22 01:41:41509<td>Unordered Associative Containers</td>
pkasting07c0959a2016-04-14 22:16:43510<td><code>std::unordered_set</code>, <code>std::unordered_map</code>, <code>std::unordered_multiset</code>, <code>std::unordered_multimap</code></td>
davidben411d3f72016-01-22 01:41:41511<td>Allows efficient containers of key/value pairs</td>
pkasting07c0959a2016-04-14 22:16:43512<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>
pkasting0cb5bd42016-11-02 20:55:58513<td>Specify custom hashers instead of specializing <code>std::hash</code> for custom 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>
davidben411d3f72016-01-22 01:41:41514</tr>
515
tzik9ca302192016-02-11 10:24:45516<tr>
dcheng7bebfa462016-04-03 23:15:25517<td>Unique Pointers</td>
518<td><code>std::unique_ptr&lt;<i>type</i>&gt;</code></td>
519<td>A smart pointer with sole ownership of the owned object.</td>
520<td><a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">std::unique_ptr</a></td>
pkasting0cb5bd42016-11-02 20:55:58521<td><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/forum/#!topic/cxx/aT2wsBLKvzI">Discussion thread</a></td>
tzik9ca302192016-02-11 10:24:45522</tr>
523
Nico Weberc8eb8ca2015-11-11 00:23:34524</tbody>
525</table>
526
Nico Weber019d40f2014-09-23 20:21:59527<h2 id="blacklist">C++11 Blacklist (Disallowed and Banned Features)</h2>
528
529<p>This section lists features that are not allowed to be used yet.
530
danakj4fd49fe42015-11-18 20:54:16531<h3 id="blacklist_banned"><a name="core-blacklist"></a>C++11 Banned Features</h3>
Nico Weber019d40f2014-09-23 20:21:59532
mdempsky33bafda2014-10-30 23:14:52533<p>This section lists C++11 features that are not allowed in the Chromium
Nico Webercea20a82014-09-25 17:46:51534codebase.
Nico Weber019d40f2014-09-23 20:21:59535</p>
536
Nico Weber019d40f2014-09-23 20:21:59537<table id="banned_list" class="unlined striped">
538<tbody>
539
540<tr>
541<th style='width:240px;'>Feature or Library</th>
542<th style='width:240px;'>Snippet</th>
543<th style='width:240px;'>Description</th>
544<th style='width:240px;'>Documentation Link</th>
pkasting0cb5bd42016-11-02 20:55:58545<th style='width:240px;'>Notes and Discussion Thread</th>
Nico Webercea20a82014-09-25 17:46:51546</tr>
547
548<tr>
pkastingfb8e7fe2016-10-31 21:34:45549<td>Inline Namespaces</td>
550<td><code>inline namespace foo { ... }</code></td>
551<td>Allows better versioning of namespaces</td>
552<td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces">Inline namespaces</a></td>
553<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>
mdempsky33bafda2014-10-30 23:14:52554</tr>
555
556<tr>
thakis12bfc742014-10-28 04:37:49557<td><code>long long</code> Type</td>
pkasting7f0693b32016-10-31 20:27:50558<td><code>long long <i>var</i> = <i>value</i>;</code></td>
thakis12bfc742014-10-28 04:37:49559<td>An integer of at least 64 bits</td>
pkasting07c0959a2016-04-14 22:16:43560<td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td>
561<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>
thakis12bfc742014-10-28 04:37:49562</tr>
563
564<tr>
jbromand21995c52016-01-07 23:43:54565<td>Ref-qualified Member Functions</td>
pkasting07c0959a2016-04-14 22:16:43566<td><code>class T {<br />
567&nbsp;&nbsp;void f() & {}<br />
568&nbsp;&nbsp;void f() && {}<br />
569};<br />
570t.f();&nbsp;&nbsp;// first<br />
571T().f();&nbsp;&nbsp;// second<br />
572std::move(t).f();&nbsp;&nbsp;// second</code></td>
jbromand21995c52016-01-07 23:43:54573<td>Allows class member functions to only bind to |this| as an rvalue or lvalue.</td>
pkasting7f0693b32016-10-31 20:27:50574<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>
pkasting0cb5bd42016-11-02 20:55:58575<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/forum/#!topic/cxx/gowclr2LPQA">Discussion Thread</a></td>
jbromand21995c52016-01-07 23:43:54576</tr>
577
pkastingfb8e7fe2016-10-31 21:34:45578<tr>
579<td>User-Defined Literals</td>
580<td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td>
581<td>Allows user-defined literal expressions</td>
582<td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-defined literals</a></td>
583<td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">Google Style Guide</a>.</td>
584</tr>
585
Nico Weber019d40f2014-09-23 20:21:59586</tbody>
587</table>
Nico Weber019d40f2014-09-23 20:21:59588
danakj4fd49fe42015-11-18 20:54:16589<h3 id="blacklist_stdlib"><a name="library-blacklist"></a>C++11 Banned Library Features</h3>
Nico Weberc8eb8ca2015-11-11 00:23:34590
591<p>This section lists C++11 library features that are not allowed in the Chromium codebase.</p>
592
593<table id="blacklist_lib_list" class="unlined striped">
594<tbody>
595
596<tr>
597<th style='width:240px;'>Feature</th>
598<th style='width:240px;'>Snippet</th>
599<th style='width:240px;'>Description</th>
600<th style='width:240px;'>Documentation Link</th>
pkasting0cb5bd42016-11-02 20:55:58601<th style='width:240px;'>Notes and Discussion Thread</th>
Nico Weberc8eb8ca2015-11-11 00:23:34602</tr>
603
604<tr>
pkastingfb8e7fe2016-10-31 21:34:45605<td>Atomics</td>
606<td><code>&lt;atomic&gt;</code></td>
607<td>Fine-grained atomic types and operations</td>
608<td><a href="http://en.cppreference.com/w/cpp/atomic">Atomic operations library</a></td>
pkasting0cb5bd42016-11-02 20:55:58609<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/forum/#!topic/cxx/Ej3RAiaI44s">Discussion Thread</a></td>
pkastingfb8e7fe2016-10-31 21:34:45610</tr>
611
612<tr>
pkastingfc30cf42016-11-04 00:49:03613<td>Bind Operations</td>
614<td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td>
615<td>Declares a function object bound to certain arguments</td>
616<td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind</a></td>
617<td>Use <code>base::Bind</code> instead. Compared to <code>std::bind</code>, <code>base::Bind</code> helps prevent lifetime issues by preventing binding of capturing lambdas and by forcing callers to declare raw pointers as <code>Unretained</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td>
618</tr>
619
620<tr>
621<td>C Floating-Point Environment</td>
622<td><code>&lt;cfenv&gt;</code>, <code>&lt;fenv.h&gt;</code></td>
623<td>Provides floating point status flags and control modes for C-compatible code</td>
624<td><a href="http://en.cppreference.com/w/cpp/header/cfenv">Standard library header &lt;cfenv&gt;</a></td>
625<td>Banned by the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a> due to concerns about compiler support.</td>
626</tr>
627
628<tr>
pkasting7f0693b32016-10-31 20:27:50629<td>Date and time utilities</td>
Nico Weberc8eb8ca2015-11-11 00:23:34630<td><code>&lt;chrono&gt;</code></td>
pkasting7f0693b32016-10-31 20:27:50631<td>A standard date and time library</td>
Nico Weberc8eb8ca2015-11-11 00:23:34632<td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a></td>
pkasting7f0693b32016-10-31 20:27:50633<td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the <code>base/</code> classes.</td>
Nico Weberc8eb8ca2015-11-11 00:23:34634</tr>
635
636<tr>
pkastingc6a6ebf12016-10-31 20:38:40637<td>Exceptions</td>
638<td><code>&lt;exception&gt;</code></td>
639<td>Enhancements to exception throwing and handling</td>
640<td><a href="http://en.cppreference.com/w/cpp/header/exception">Standard library header &lt;exception&gt;</a></td>
641<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>
642</tr>
643
644<tr>
pkastingfc30cf42016-11-04 00:49:03645<td>Function Objects</td>
646<td><code>std::function</code></td>
647<td>Wraps a standard polymorphic function</td>
648<td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std::function</a></td>
649<td>Use <code>base::Callback</code> instead. Compared to <code>std::function</code>, <code>base::Callback</code> directly supports Chromium's refcounting classes and weak pointers and deals with additional thread safety concerns. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/SoEj7oIDNuA">Discussion thread</a></td>
650</tr>
651
652<tr>
653<td>Ratio Template Class</td>
654<td><code>std::ratio&lt;<i>numerator</i>, <i>denominator</i>&gt;</code></td>
655<td>Provides compile-time rational numbers</td>
656<td><a href="http://en.cppreference.com/w/cpp/numeric/ratio/ratio">std::ratio</a></td>
657<td>Banned by the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a> due to concerns that this is tied to a more template-heavy interface style.</td>
658</tr>
659
660<tr>
pkasting7f0693b32016-10-31 20:27:50661<td>Regular Expressions</td>
Nico Weberc8eb8ca2015-11-11 00:23:34662<td><code>&lt;regex&gt;</code></td>
pkasting7f0693b32016-10-31 20:27:50663<td>A standard regular expressions library</td>
Nico Weberc8eb8ca2015-11-11 00:23:34664<td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library</a></td>
pkasting7f0693b32016-10-31 20:27:50665<td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td>
Nico Weberc8eb8ca2015-11-11 00:23:34666</tr>
667
668<tr>
pkastingfb8e7fe2016-10-31 21:34:45669<td>Shared Pointers</td>
670<td><code>std::shared_ptr</code></td>
671<td>Allows shared ownership of a pointer through reference counts</td>
672<td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr</a></td>
pkasting0cb5bd42016-11-02 20:55:58673<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/forum/#!topic/cxx/aT2wsBLKvzI">Discussion Thread</a></td>
pkastingfb8e7fe2016-10-31 21:34:45674</tr>
675
676<tr>
Nico Weberc8eb8ca2015-11-11 00:23:34677<td>Thread Library</td>
pkasting7f0693b32016-10-31 20:27:50678<td><code>&lt;thread&gt;</code> and related headers, including<br />
pkasting07c0959a2016-04-14 22:16:43679<code>&lt;future&gt;</code>, <code>&lt;mutex&gt;</code>, <code>&lt;condition_variable&gt;</code></td>
pkasting7f0693b32016-10-31 20:27:50680<td>Provides a standard multithreading library using <code>std::thread</code> and associates</td>
Nico Weberc8eb8ca2015-11-11 00:23:34681<td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a></td>
pkasting7f0693b32016-10-31 20:27:50682<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 Weberc8eb8ca2015-11-11 00:23:34683</tr>
684
685</tbody>
686</table>
687
688
danakj4fd49fe42015-11-18 20:54:16689<h3 id="blacklist_review"><a name="core-review"></a>C++11 Features To Be Discussed</h3>
Nico Weber019d40f2014-09-23 20:21:59690
pkastingfc30cf42016-11-04 00:49:03691<p>The following C++ language 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.</p>
Nico Weber019d40f2014-09-23 20:21:59692
693<table id="blacklist_review_list" class="unlined striped">
694<tbody>
695
696<tr>
697<th style='width:240px;'>Feature</th>
698<th style='width:240px;'>Snippet</th>
699<th style='width:240px;'>Description</th>
700<th style='width:240px;'>Documentation Link</th>
pkasting0cb5bd42016-11-02 20:55:58701<th style='width:240px;'>Notes and Discussion Thread</th>
Nico Weber019d40f2014-09-23 20:21:59702</tr>
703
704<tr>
pkastingfb8e7fe2016-10-31 21:34:45705<td>Alignment Features</td>
706<td><code>alignas</code> specifier, <code>alignof</code> operator</td>
707<td>Object alignment</td>
708<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>
pkasting0cb5bd42016-11-02 20:55:58709<td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/rwXN02jzzq0">Discussion thread</a></td>
pkastingfb8e7fe2016-10-31 21:34:45710</tr>
711
712<tr>
Nico Weber019d40f2014-09-23 20:21:59713<td>Attributes</td>
714<td><code>[[<i>attribute_name</i>]]</code></td>
pkasting07c0959a2016-04-14 22:16:43715<td>Attaches properties to declarations that specific compiler implementations may use.</td>
716<td><a href="http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generalized-attributes/">C++11 generalized attributes</a></td>
Nico Weber019d40f2014-09-23 20:21:59717<td></td>
718</tr>
719
720<tr>
pkastingfb8e7fe2016-10-31 21:34:45721<td>UTF-8, UTF-16, UTF-32 String Literals</td>
722<td><code>u8&quot;<i>string</i>&quot;, u&quot;<i>string</i>&quot;, U&quot;<i>string</i>&quot;</code></td>
723<td>Enforces UTF-8, UTF-16, UTF-32 encoding on all string literals</td>
724<td><a href="http://en.cppreference.com/w/cpp/language/string_literal">string literal</a></td>
725<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>
726</tr>
727
728<tr>
729<td>UTF-16 and UTF-32 Support (16-Bit and 32-Bit Character Types)</td>
730<td><code>char16_t</code> and <code>char32_t</code></td>
731<td>Provides character types for handling 16-bit and 32-bit code units (useful for encoding UTF-16 and UTF-32 string data)</td>
732<td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td>
733<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 Weber019d40f2014-09-23 20:21:59734</tr>
735
Nico Weber019d40f2014-09-23 20:21:59736</tbody>
737</table>
738
danakj4fd49fe42015-11-18 20:54:16739<h3 id="blacklist_stdlib_review"><a name="library-review"></a>C++11 Standard Library Features To Be Discussed</h3>
Nico Weber019d40f2014-09-23 20:21:59740
pkastingfc30cf42016-11-04 00:49:03741<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.</p>
Nico Weber019d40f2014-09-23 20:21:59742
743<table id="banned_stdlib" class="unlined striped">
744
745<tbody>
746<tr>
747<th style='width:240px;'>Feature</th>
748<th style='width:240px;'>Snippet</th>
749<th style='width:240px;'>Description</th>
750<th style='width:240px;'>Documentation Link</th>
pkasting0cb5bd42016-11-02 20:55:58751<th style='width:240px;'>Notes</th>
Nico Weber019d40f2014-09-23 20:21:59752</tr>
753
754<tr>
755<td>Address Retrieval</td>
756<td><code>std::addressof()</code></td>
757<td>Obtains the address of an object even with overloaded <code>operator&amp;</code></td>
758<td><a href="http://en.cppreference.com/w/cpp/memory/addressof">std::addressof</a></td>
pkasting07c0959a2016-04-14 22:16:43759<td>Usage should be rare as <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">operator overloading</a> is rare and <code>&amp;</code> should suffice in most cases. May be preferable over <code>&amp;</code> for performing object identity checks.</td>
Nico Weber019d40f2014-09-23 20:21:59760</tr>
761
762<tr>
763<td>Aligned Storage</td>
pkasting07c0959a2016-04-14 22:16:43764<td><code>std::aligned_storage&lt;Size, Align&gt;::type</code><br />
765<code>std::alignment_of&lt;T&gt;</code>, <code>std::aligned_union&lt;Size, ...Types&gt;</code> <code>std::max_align_t</code></td>
danakj715179fc2015-11-12 05:32:18766<td>Declare uninitialized storage having a specified alignment, or determine alignments.</td>
Nico Weber019d40f2014-09-23 20:21:59767<td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligned_storage</a></td>
pkasting07c0959a2016-04-14 22:16:43768<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 Weber019d40f2014-09-23 20:21:59769</tr>
770
771<tr>
772<td>Allocator Traits</td>
773<td><code>std::allocator_traits</code></td>
774<td>Provides an interface for accessing custom allocators</td>
pkasting07c0959a2016-04-14 22:16:43775<td><a href="http://en.cppreference.com/w/cpp/memory/allocator_traits">std::allocator_traits</a></td>
Nico Weber019d40f2014-09-23 20:21:59776<td>Usage should be rare.</td>
777</tr>
778
779<tr>
Nico Weber019d40f2014-09-23 20:21:59780<td>Complex Inverse Trigonometric and Hyperbolic Functions</td>
781<td>Functions within <code>&lt;complex&gt;</code></td>
pkasting07c0959a2016-04-14 22:16:43782<td>Adds inverse trigonomentric and hyperbolic non-member functions to the <code>&lt;complex&gt;</code> library.</td>
Nico Weber019d40f2014-09-23 20:21:59783<td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a></td>
784<td></td>
785</tr>
786
787<tr>
Nico Weber019d40f2014-09-23 20:21:59788<td>Container Compaction Functions</td>
pkasting07c0959a2016-04-14 22:16:43789<td><code>std::vector::shrink_to_fit()</code>, <code>std::deque::shrink_to_fit()</code>, <code>std::string::shrink_to_fit()</code></td>
790<td>Requests the removal of unused space in the container</td>
791<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 Weber019d40f2014-09-23 20:21:59792<td></td>
793</tr>
794
795<tr>
796<td>Date/Time String Formatting Specifiers</td>
797<td><code>std::strftime()</code></td>
pkasting07c0959a2016-04-14 22:16:43798<td>Converts date and time information into a formatted string using new specifiers</td>
799<td><a href="http://en.cppreference.com/w/cpp/chrono/c/strftime">std::strftime</a></td>
Nico Weber019d40f2014-09-23 20:21:59800<td></td>
801</tr>
802
803<tr>
804<td>Function Return Type Deduction</td>
805<td><code>std::result_of&lt;<i>Functor(ArgTypes...)</i>&gt;</code></td>
pkasting07c0959a2016-04-14 22:16:43806<td>Extracts the return type from the type signature of a function call invocation at compile-time.</td>
807<td><a href="http://en.cppreference.com/w/cpp/types/result_of">std::result_of</a></td>
808<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 Weber019d40f2014-09-23 20:21:59809</tr>
810
811<tr>
Nico Weber019d40f2014-09-23 20:21:59812<td>Forward Lists</td>
813<td><code>std::forward_list</code></td>
814<td>Provides an efficient singly linked list</td>
pkasting07c0959a2016-04-14 22:16:43815<td><a href="http://en.cppreference.com/w/cpp/container/forward_list">std::forward_list</a></td>
Nico Weber019d40f2014-09-23 20:21:59816<td></td>
817</tr>
818
819<tr>
820<td>Gamma Natural Log</td>
821<td><code>std::lgamma()</code></td>
pkasting07c0959a2016-04-14 22:16:43822<td>Computes the natural log of the gamma of a floating point value</td>
823<td><a href="http://en.cppreference.com/w/cpp/numeric/math/lgamma">std::lgamma</a></td>
Nico Weber019d40f2014-09-23 20:21:59824<td></td>
825</tr>
826
827<tr>
828<td>Garbage Collection Features</td>
pkasting07c0959a2016-04-14 22:16:43829<td><code>std::{un}declare_reachable()</code>, <code>std::{un}declare_no_pointers()</code></td>
Nico Weber019d40f2014-09-23 20:21:59830<td>Enables garbage collection implementations</td>
pkasting07c0959a2016-04-14 22:16:43831<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 Weber019d40f2014-09-23 20:21:59832<td></td>
833</tr>
834
835<tr>
Nico Weber019d40f2014-09-23 20:21:59836<td>Iterator Operators</td>
pkasting07c0959a2016-04-14 22:16:43837<td><code>std::next()</code>, <code>std::prev()</code></td>
838<td>Copies an iterator and increments or decrements the copy by some value</td>
839<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 Weber019d40f2014-09-23 20:21:59840<td></td>
841</tr>
842
843<tr>
Nico Weber019d40f2014-09-23 20:21:59844<td>Pointer Traits Class Template</td>
845<td><code>std::pointer_traits</code></td>
pkasting07c0959a2016-04-14 22:16:43846<td>Provides a standard way to access properties of pointers and pointer-like types</td>
847<td><a href="http://en.cppreference.com/w/cpp/memory/pointer_traits">std::pointer_traits</a></td>
848<td>Useful for determining the element type pointed at by a (possibly smart) pointer.</td>
Nico Weber019d40f2014-09-23 20:21:59849</tr>
850
851<tr>
Nico Weber019d40f2014-09-23 20:21:59852<td>Reference Wrapper Classes</td>
pkasting07c0959a2016-04-14 22:16:43853<td><code>std::reference_wrapper</code> and <code>std::ref()</code>, <code>std::cref()</code></td>
854<td>Allows you to wrap a reference within a standard object (and use those within containers)</td>
pkasting7f0693b32016-10-31 20:27:50855<td><a href="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper">std::reference_wrapper</a></td>
Nico Weber019d40f2014-09-23 20:21:59856<td></td>
857</tr>
858
859<tr>
Nico Weber019d40f2014-09-23 20:21:59860<td>Soft Program Exits</td>
pkasting07c0959a2016-04-14 22:16:43861<td><code>std::at_quick_exit()</code>, <code>std::quick_exit()</code></td>
862<td>Allows registration of functions to be called upon exit, allowing cleaner program exit than <code>abort()</code> or <code>exit</code></td>
863<td><a href="http://en.cppreference.com/w/cpp/utility/program/quick_exit">std:quick_exit</a></td>
Nico Weber019d40f2014-09-23 20:21:59864<td></td>
865</tr>
866
867<tr>
dcheng2d4220ae2016-07-26 08:58:46868<td>String-Number Conversion Functions</td>
pkasting07c0959a2016-04-14 22:16:43869<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>
dcheng2d4220ae2016-07-26 08:58:46870<td>Converts strings to/from numbers</td>
871<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>
pkasting0cb5bd42016-11-02 20:55:58872<td>May be useful to <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=593512">replace dmg_fp</a>.</td>
Nico Weber019d40f2014-09-23 20:21:59873</tr>
874
875<tr>
Nico Weber019d40f2014-09-23 20:21:59876<td>System Errors</td>
877<td><code>&lt;system_error&gt;</code></td>
878<td>Provides a standard system error library</td>
pkasting7f0693b32016-10-31 20:27:50879<td><a href="http://en.cppreference.com/w/cpp/header/system_error">Standard library header &lt;system_error&gt;</a></td>
Nico Weber019d40f2014-09-23 20:21:59880<td></td>
881</tr>
882
883<tr>
Nico Weber019d40f2014-09-23 20:21:59884<td>Type-Generic Math Functions</td>
pkasting7f0693b32016-10-31 20:27:50885<td><code>&lt;ctgmath&gt;</code></td>
pkasting07c0959a2016-04-14 22:16:43886<td>Provides a means to call real or complex functions based on the type of arguments</td>
887<td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library header &lt;ctgmath&gt;</a></td>
Nico Weber019d40f2014-09-23 20:21:59888<td></td>
889</tr>
890
891<tr>
892<td>Type Info Enhancements</td>
pkasting07c0959a2016-04-14 22:16:43893<td><code>std::type_index</code>, <code>std::type_info::hash_code()</code></td>
894<td>Allows type information (most often within containers) that can be copied, assigned, or hashed</td>
895<td><a href="http://en.cppreference.com/w/cpp/types/type_index">std::type_index</a>, <a href="http://en.cppreference.com/w/cpp/types/type_info/hash_code">std::type_info::hash_code</a></td>
pkasting0cb5bd42016-11-02 20:55:58896<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 Weber019d40f2014-09-23 20:21:59897</tr>
898
899<tr>
Nico Weber019d40f2014-09-23 20:21:59900<td>Variadic Copy Macro</td>
901<td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td>
902<td>Makes a copy of the variadic function arguments</td>
pkasting7f0693b32016-10-31 20:27:50903<td><a href="http://en.cppreference.com/w/cpp/utility/variadic/va_copy">va_copy</a></td>
Nico Weber019d40f2014-09-23 20:21:59904<td></td>
905</tr>
906
907<tr>
908<td>Weak Pointers</td>
909<td><code>std::weak_ptr</code></td>
910<td>Allows a weak reference to a <code>std::shared_ptr</code></td>
pkasting07c0959a2016-04-14 22:16:43911<td><a href="http://en.cppreference.com/w/cpp/memory/weak_ptr">std::weak_ptr</a></td>
912<td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers">Ownership and Smart Pointers</a></td>
Nico Weber019d40f2014-09-23 20:21:59913</tr>
914
915<tr>
916<td>Wide String Support</td>
pkasting07c0959a2016-04-14 22:16:43917<td><code>std::wstring_convert</code>, <code>std::wbuffer_convert</code><br />
918<code>std::codecvt_utf8</code>, <code>std::codecvt_utf16</code>, <code>std::codecvt_utf8_utf16</code></td>
Nico Weber019d40f2014-09-23 20:21:59919<td>Converts between string encodings</td>
pkasting07c0959a2016-04-14 22:16:43920<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>
921<td>Non-UTF-8 text is banned by the <a href="https://google.github.io/styleguide/cppguide.html#Non-ASCII_Characters">Google Style Guide</a>. However, may be useful for consuming non-ASCII data.</td>
Nico Weber019d40f2014-09-23 20:21:59922</tr>
923
924</tbody>
925</table>
926
Nico Weber019d40f2014-09-23 20:21:59927</div>
928</body>
929</html>