3 Copyright 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
10 <title>C++
11 use in Chromium
</title>
11 <link rel=
"stylesheet" href=
"c++11.css">
13 table tbody tr td:first-child {
21 <h1>C++
11 use in Chromium
</h1>
23 <p><i>This document lives at src/styleguide/c++/c++
11.html in a Chromium
26 <p>This document summarizes the features of C++
11 (both in the language itself
27 and in enhancements to the Standard Library) and describes which features are
28 allowed in Chromium and contains pointers to more detailed information. The
29 Guide applies to Chromium and its subprojects. Subprojects can choose to be
30 more restrictive if they need to compile on more toolchains than Chromium.
</p>
32 <p>You can propose to make a feature available or to ban a
33 feature by sending an email to chromium-dev. Ideally include a short blurb
34 on what the feature is, and why you think it should or should not be allowed.
35 Ideally, the list will arrive at some consensus and the wiki page will be
36 updated to mention that consensus. If there's no consensus,
37 <code>src/styleguide/C++/OWNERS
</code> get to decide -- for divisive features, we expect
38 the decision to be to not use the feature yet and possibly discuss it again a
39 few months later, when we have more experience with the language.
</p>
41 <p class=
"warning">Unless otherwise noted,
<strong>no
</strong> C++
11
42 <strong>library
</strong> features are allowed.
</p>
44 <h2 id=
"whitelist">C++
11 Allowed Features
</h2>
46 <p>The following features are currently allowed.
</p>
48 <table id=
"whitelist_lang_list" class=
"unlined striped">
52 <th style='width:
220px;'
>Feature
</th>
53 <th style='width:
260px;'
>Snippet
</th>
54 <th style='width:
240px;'
>Description
</th>
55 <th style='width:
240px;'
>Documentation Link
</th>
56 <th style='width:
240px;'
>Notes and Discussion Thread
</th>
61 <td><code>using
<i>new_alias
</i> =
<i>typename
</i></code></td>
62 <td>Allow parameterized typedefs
</td>
63 <td><a href=
"http://en.cppreference.com/w/cpp/language/type_alias">Type alias (using syntax)
</a></td>
64 <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>
68 <td>Angle Bracket Parsing in Templates
</td>
69 <td><code>>></code> for
<code>> ></code> and
<br />
70 <code><::
</code> for
<code>< ::
</code></td>
71 <td>More intuitive parsing of template parameters
</td>
72 <td><a href=
"http://stackoverflow.com/questions/15785496/c-templates-angle-brackets-pitfall-what-is-the-c11-fix">
73 C++ Templates Angle Brackets Pitfall
</a></td>
74 <td>Recommended to increase readability. Approved without discussion.
</td>
78 <td>Automatic Types
</td>
79 <td><code>auto
</code></td>
80 <td>Automatic type deduction
</td>
81 <td>TODO: documentation link
</td>
82 <td>Use according to the
<a
83 href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto">Google
84 Style Guide on
<code>auto
</code></a>.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/OQyYSfH9m2M">Discussion thread
</a>.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/5-Bt3BJzAo0">Another discussion thread
</a>.
</td>
88 <td>Declared Type Accessor
</td>
89 <td><code>decltype(
<i>expression
</i>)
</code></td>
90 <td>Provides a means to determine the type of an expression at compile-time,
91 useful most often in templates.
</td>
92 <td><a href=
"http://en.cppreference.com/w/cpp/language/decltype">
93 decltype specifier
</a></td>
94 <td>Usage should be rare.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/_zoNvZd_dSo">Discussion thread
</a></td>
98 <td>Default Function Creation
</td>
99 <td><code><i>Function
</i>(
<i>arguments
</i>) = default;
</code></td>
100 <td>Instructs the compiler to generate a default version
101 of the indicated function
</td>
102 <td><a href=
"http://stackoverflow.com/questions/823935/whats-the-point-in-defaulting-functions-in-c11">
103 What's the point in defaulting functions in C++
11?
</a></td>
104 <td>Doesn't work for move constructors and move assignment operators in MSVC2013.
105 <a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/qgU4mh_MpGA">Discussion thread
</a></td>
109 <td>Delegated Constructors
</td>
110 <td><code>Class() : Class(
0) {}
</code><br />
111 <code>Class(
<i>type
</i> <i>var
</i>) : Class(
<i>var
</i>,
0)
</code></td>
112 <td>Allow overloaded constructors to use common initialization code
</td>
113 <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">
114 Introduction to the C++
11 feature: delegating constructors
</a></td>
115 <td><a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/0zVA8Ctx3Xo">Discussion thread
</a></td>
119 <td>Enumerated Type Classes and Enum Bases
</td>
120 <td><code>enum class
<i>classname
</i></code><br>
121 <code>enum class
<i>classname
</i> :
<i>base-type
</i></code><br>
122 <code>enum
<i>enumname
</i> :
<i>base-type
</i></code></td>
123 <td>Provide enums as full classes, with no implicit
124 conversion to booleans or integers. Provide an explicit underlying type for
125 enum classes and regular enums.
</td>
126 <td><a href=
"http://www.stroustrup.com/C++11FAQ.html#enum">enum-class
</a></td>
127 <td>Enum classes are still enums and follow enum naming rules
128 (which means SHOUTY_CASE in the
<a href=
"http://www.chromium.org/developers/coding-style#Naming">current style guide
</a>).
129 <a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/Q5WmkAImanc">Discussion thread
</a></td>
133 <td>Final Specifier
</td>
134 <td><code>final
</code></td>
135 <td> Indicates that a class or function is final and cannot be overridden
</td>
136 <td><a href=
"http://en.cppreference.com/w/cpp/language/final">final Language Reference
</a></td>
137 <td>Recommended for new code. Existing uses of the
<code>FINAL
</code> macro will be
<a href=
"https://crbug.com/417463">replaced throughout the codebase
</a>.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread
</a></td>
141 <td>Function Suppression
</td>
142 <td><code><i>Function
</i>(
<i>arguments
</i>) = delete;
</code></td>
143 <td>Suppresses the implementation of a function, especially a
144 synthetic function such as a copy constructor
</td>
145 <td>TODO: documentation link
</td>
146 <td><a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/i1o7-RNRnMs">Discussion thread
</a></td>
150 <td>Lambda Expressions
</td>
151 <td><code>[
<i>captures
</i>](
<i>params
</i>) -
> <i>ret
</i> {
<i>body
</i> }
</code></td>
152 <td>Anonymous functions
</td>
153 <td><a href=
"http://en.cppreference.com/w/cpp/language/lambda">Lambda functions
</a></td>
154 <td>Do not bind or store lambdas; use
<code>base::Bind
</code> and
155 <code>base::Callback
</code> instead, because they offer protection against a
156 large class of object lifetime mistakes. Don't use default captures
157 (
<code>[=]
</code>,
<code>[
&]
</code> – <a
158 href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions">Google Style Guide
</a>).
159 Lambdas are typically useful as a parameter to methods or
160 functions that will use them immediately, such as those in
161 <code><algorithm
></code>.
<a
162 href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion
167 <td>Local Types as Template Arguments
</td>
169 <td>Allows local and unnamed types as template arguments
</td>
170 <td><a href=
"http://stackoverflow.com/questions/742607/using-local-classes-with-stl-algorithms">
171 Local types, types without linkage and unnamed types as template arguments
</a></td>
172 <td>Usage should be rare. Approved without discussion.
</td>
176 <td>Non-Static Class Member Initializers
</td>
180 <i>type
</i> <i>var
</i> =
<i>value
</i>;
<br/>
181 C() // copy-initializes
<i>var
</i><br/>
183 <td>Allows non-static class members to be initialized at their definitions (outside constructors)
</td>
184 <td><a href=
"http://en.cppreference.com/w/cpp/language/data_members">
185 Non-static data members
</a></td>
186 <td><a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Initialization">Google
188 <a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/zqB-DySA4V0">Discussion thread
</a>
193 <td>Null Pointer Constant
</td>
194 <td><code>nullptr
</code></td>
195 <td>Declares a type-safe null pointer
</td>
196 <td>TODO: documentation link
</td>
197 <td>Recommended for new code.
198 <a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread
</a>.
199 <a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#0_and_nullptr/NULL">Google Style Guide
</a>.
200 Note:
<code>std::nullptr_t
</code> is a library feature and not available.
205 <td>Override Specifier
</td>
206 <td><code>override
</code></td>
207 <td>Indicates that a class or function overrides a base implementation
</td>
208 <td><a href=
"http://en.cppreference.com/w/cpp/language/override">override Language Reference
</a></td>
209 <td>Recommended for new code. Existing uses of the
<code>OVERRIDE
</code> macro will be
<a href=
"https://crbug.com/417463">replaced throughout the codebase
</a>.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion
</a></td>
213 <td>Range-Based For Loops
</td>
214 <td><code>for (
<i>type
</i> <i>var
</i> :
<i>range
</i>)
</code></td>
215 <td>Facilitates a more concise syntax for iterating over the elements
216 of a container (or a range of iterators) in a
<code>for
</code> loop
</td>
217 <td>TODO: documentation link
</td>
218 <td>As a rule of thumb, use
<code>for (const auto& ...)
</code>,
<code>for (auto& ...)
</code>, or
<code>for (
<i>concrete type
</i> ...)
</code>. For pointers, use
<code>for (auto* ...)
</code> to make clear that the copy of the loop variable is intended, and only a pointer is copied.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/hpzz4EqbVmc">Discussion thread
</a></td>
222 <td>Standard Integers
</td>
223 <td>Typedefs within
<code><stdint.h
></code>
224 and
<code><inttypes
></code></td>
225 <td>Provides fixed-size integers independent of platforms
</td>
226 <td><a href=
"http://www.cplusplus.com/reference/cstdint/">
227 <stdint.h
> (cstdint)
</a></td>
228 <td>Already in common use in the codebase. Approved without discussion.
</td>
232 <td>Static Assertions
</td>
233 <td><code>static_assert(
<i>bool
</i>,
<i>string
</i>)
</code></td>
234 <td>Tests compile-time conditions
</td>
235 <td><a href=
"http://en.cppreference.com/w/cpp/language/static_assert">Static Assertion
</a></td>
236 <td><a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/POISBQEhGzU">Discussion thread
</a></td>
240 <td>Variadic Macros
</td>
241 <td><code>#define
<i>MACRO
</i>(...)
<i>Impl
</i>(
<i>args
</i>, __VA_ARGS__)
</code></td>
242 <td>Allows macros that accept a variable number of arguments
</td>
243 <td><a href=
"http://stackoverflow.com/questions/4786649/are-variadic-macros-nonstandard">
244 Are Variadic macros nonstandard?
</a></td>
245 <td>Usage should be rare.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/sRx9j3CQqyA">Discussion thread
</a></td>
249 <td>Variadic Templates
</td>
250 <td><code>template
<<i>typename
</i> ...
<i>arg
</i>></code></td>
251 <td>Allows templates that accept a variable number of arguments
</td>
252 <td>TODO: documentation link
</td>
253 <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>
259 <h2 id=
"blacklist">C++
11 Blacklist (Disallowed and Banned Features)
</h2>
261 <p>This section lists features that are not allowed to be used yet.
263 <h3 id=
"blacklist_banned">C++
11 Banned Features
</h3>
265 <p>This section lists C++
11 features that are not allowed in the Chromium
269 <table id=
"banned_list" class=
"unlined striped">
273 <th style='width:
240px;'
>Feature or Library
</th>
274 <th style='width:
240px;'
>Snippet
</th>
275 <th style='width:
240px;'
>Description
</th>
276 <th style='width:
240px;'
>Documentation Link
</th>
277 <th style='width:
240px;'
>Notes
</th>
281 <td>Constant Expressions
</td>
282 <td><code>constexpr
</code></td>
283 <td>Compile-time constant expressions
</td>
284 <td>TODO: documentation link
</td>
285 <td>Doesn't work in MSVS2013. Reevalute once it does.
<a
286 href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Use_of_constexpr">Google
287 Style Guide on
<code>constexpr
</code></a></td>
291 <td>Explicit Conversion Operators
</td>
292 <td><code>explicit operator
<i>type
</i>() {
293 <br /> // code
<br /> }
</code></td>
294 <td>Allows conversion operators that cannot be implicitly invoked
</td>
295 <td><a href=
"http://en.cppreference.com/w/cpp/language/explicit">
296 explicit specifier
</a></td>
297 <td><a href=
"https://connect.microsoft.com/VisualStudio/feedback/details/811334/bug-in-vs-2013-support-for-explicit-conversion-operators">Doesn't work in MSVS2013
</a>. Reevaluate once it does.
<a href=
"https://groups.google.com/a/chromium.org/d/msg/chromium-dev/zGF1SrQ-1HQ/BAiC12vwPeEJ">Discussion thread
</a></td>
301 <td>Function Local Variable
</td>
302 <td><code>__func__
</code></td>
303 <td>Provides a local variable of the name of the enclosing
304 function for logging purposes
</td>
305 <td><a href=
"http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=338">
306 The __func__ Predeclared Identifier is Coming to C++
</a></td>
307 <td>Doesn't work in MSVS2013. Reevaluate once it does.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ojGfcgSDzHM">Discussion thread
</a></td>
311 <td>Inherited Constructors
</td>
312 <td><code>class Derived : Base {
313 <br /> using Base::Base;
315 <td>Allow derived classes to inherit constructors from base classes
</td>
316 <td><a href=
"http://en.cppreference.com/w/cpp/language/using_declaration">Using-declaration
</a></td>
317 <td>Doesn't work in MSVS2013. Reevaluate once it does.
<a
318 href=
"https://groups.google.com/a/chromium.org/d/msg/chromium-dev/BULzgIKZ-Ao/PLO7_GoVNvYJ">Discussion thread
</a></td>
322 <td><code>long long
</code> Type
</td>
323 <td><code>long long
<i>var
</i>=
<i>value
</i>;
</code></td>
324 <td>An integer of at least
64 bits
</td>
325 <td><a href=
"http://en.cppreference.com/w/cpp/language/types">
326 Fundamental types
</a></td>
327 <td>Use an 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>
331 <td>Raw String Literals
</td>
332 <td><code>string
<i>var
</i>=R
"(
<i>raw_string
</i>)
";
</code></td>
333 <td>Allows a string to be encoded without any escape
334 sequences, easing parsing in regex expressions, for example
</td>
335 <td>TODO: documentation link
</td>
336 <td>Causes incorrect line numbers in MSVS2014 and gcc. Reevaluate once that works.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/2kWQHbbuMHI">Discussion thread
</a></td>
340 <td>Rvalue References (and Move Semantics)
</td>
341 <td><code>T(T
&& t)
</code> and
<code>T
& operator=(T
&& t)
</code></td>
342 <td>Reference that only binds to a temporary object
</td>
343 <td>TODO: documentation link
</td>
344 <td>To be revisited in the future. Allowed in exceptional cases where approved by the OWNERS of src/styleguide/c++/.
</td>
348 <td>(Uniform) Initialization Syntax
</td>
349 <td><code><i>type
</i> <i>name
</i> { [
<i>value
</i> ...,
<i>value
</i>]};
</code></td>
350 <td>Allows any object of primitive, aggregate or class
351 type to be initialized using brace syntax
</td>
352 <td>TODO: documentation link
</td>
353 <td>Dangerous without library support, see thread. Reevaulate once we have C++
11 library support.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/GF96FshwHLw">Discussion thread
</a></td>
357 <td>UTF-
16 and UTF-
32 Support (
16-Bit and
32-Bit Character Types)
</td>
358 <td><code>char16_t
</code> and
<code>char32_t
</code></td>
359 <td>Provides character types for handling
16-bit
360 and
32-bit code units (useful for encoding
361 UTF-
16 and UTF-
32 string data)
</td>
362 <td><a href=
"http://en.cppreference.com/w/cpp/language/types">
363 Fundamental types
</a></td>
364 <td>Doesn't work in MSVS2013. Reevaluate once it does. Non-UTF-
8 text is
366 <a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Non-ASCII_Characters">
367 C++ Style Guide
</a>. However, may be useful for
368 consuming non-ASCII data.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/ME2kL7_Kvyk">Discussion thread
</a></td>
372 <td>UTF-
8, UTF-
16, UTF-
32 String Literals
</td>
373 <td><code>u8
"<i>string
</i>", u
"<i>string
</i>", U
"<i>string
</i>"</code></td>
374 <td>Enforces UTF-
8, UTF-
16, UTF-
32 encoding on all string literals
</td>
375 <td><a href=
"http://en.cppreference.com/w/cpp/language/string_literal">
376 string literal
</a></td>
377 <td>Does not yet work in MSVS2013. Reevaluate once it does.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/gcoUbcjfsII">Discussion thread
</a></td>
383 <h3 id=
"blacklist_review">C++
11 Features To Be Discussed
</h3>
385 <p>The following C++ language features are currently disallowed.
386 See the top of this page on how to propose moving a feature from this list
387 into the allowed or banned sections. Note that not all of these features
388 work in all our compilers yet.
</p>
390 <table id=
"blacklist_review_list" class=
"unlined striped">
394 <th style='width:
240px;'
>Feature
</th>
395 <th style='width:
240px;'
>Snippet
</th>
396 <th style='width:
240px;'
>Description
</th>
397 <th style='width:
240px;'
>Documentation Link
</th>
398 <th style='width:
240px;'
>Notes
</th>
402 <td>Alignment Features
</td>
404 <code>alignas
</code> specifier,
405 <code>std::alignment_of
<T
></code>,
406 <code>std::aligned_union
<Size, ...Types
></code> and
407 <code>std::max_align_t
</code></td>
408 <td>Object alignment
</td>
409 <td><a href=
"http://en.cppreference.com/w/cpp/types/alignment_of">std::alignment_of
</a></td>
415 <td><code>[[
<i>attribute_name
</i>]]
</code></td>
416 <td>Attaches properties to declarations that
417 specific compiler implementations may use.
</td>
418 <td><a href=
"http://www.codesynthesis.com/~boris/blog/2012/04/18/cxx11-generalized-attributes/">
419 C++
11 generalized attributes
</a></td>
424 <td>Default Function Template Arguments
</td>
425 <td><code>template
<typename T =
<i>type
</i>> <br />
426 <i>type
</i> <i>Function
</i>(T
<i>var
</i>) {}
</code></td>
427 <td>Allow function templates, like classes, to have default arguments
</td>
428 <td><a href=
"http://stackoverflow.com/questions/2447458/default-template-arguments-for-function-templates">
429 Default Template Arguments for Function Templates
</a></td>
434 <td>Exception Features
</td>
435 <td><code>noexcept
</code>,
<code>exception_ptr
</code>,
436 <code>current_exception()
</code>,
<code>rethrow_exception
</code>,
437 and
<code>nested_exception
</code></td>
438 <td>Enhancements to exception throwing and handling
</td>
439 <td><a href=
"http://en.cppreference.com/w/cpp/error/exception">
440 std::exception
</a></td>
441 <td>Exceptions are banned by the
442 <a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Exceptions"> C++ Style Guide
</a>.
<a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread
</a></td>
446 <td>Inline Namespaces
</td>
447 <td><code>inline
</code></td>
448 <td>Allows better versioning of namespaces
</td>
449 <td><a href=
"http://en.cppreference.com/w/cpp/language/namespace">Namespaces
</a></td>
450 <td>Unclear how it will work with components
</td>
454 <td>Union Class Members
</td>
455 <td><code>union
<i>name
</i> {
<i>class
</i> <i>var
</i>}
</code></td>
456 <td>Allows class type members
</td>
457 <td><a href=
"http://en.cppreference.com/w/cpp/language/union">
458 Union declarations
</a></td>
463 <td>User-Defined Literals
</td>
464 <td><code><i>type
</i> <i>var
</i> =
<i>literal_value
</i>_
<i>type
</i></code></td>
465 <td>Allows user-defined literal expressions
</td>
466 <td>TODO: documentation link
</td>
473 <h3 id=
"blacklist_stdlib">C++
11 Standard Library features
</h3>
477 <p><summary class=
"note">All C++
11 <strong>Standard Library features are currently
478 banned
</strong>, because they are not supported on all of our toolchains yet.
479 In particular, chromium/android is currently using STLport, and chromium/mac is
480 currently using libstdc++
4.2, which predate C++
11.
483 <table id=
"banned_stdlib" class=
"unlined striped">
487 <th style='width:
240px;'
>Feature
</th>
488 <th style='width:
240px;'
>Snippet
</th>
489 <th style='width:
240px;'
>Description
</th>
490 <th style='width:
240px;'
>Documentation Link
</th>
491 <th style='width:
240px;'
>Style Guide Usage
</th>
495 <td>Address Retrieval
</td>
496 <td><code>std::addressof()
</code></td>
497 <td>Obtains the address of an object even with overloaded
<code>operator
&</code></td>
498 <td><a href=
"http://en.cppreference.com/w/cpp/memory/addressof">std::addressof
</a></td>
499 <td>Usage should be rare as
500 <a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Operator_Overloading">
501 Operator Overloading
</a> is rare and
<code>&s;</code>
502 should suffice in most cases. May be preferable
503 over
<code>&s;</code> for performing object
504 identity checks.
</td>
508 <td>Aligned Storage
</td>
509 <td><code>std::aligned_storage
<Size, Align
>::type
</code></td>
510 <td>Declare uninitialized storage having a specified alignment.
</td>
511 <td><a href=
"http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligned_storage
</a></td>
512 <td>Note:
<code>std::aligned_storage
</code> is allowed, but some other C++
11
513 alignment features are still disallowed.
</td>
517 <td>Allocator Traits
</td>
518 <td><code>std::allocator_traits
</code></td>
519 <td>Provides an interface for accessing custom allocators
</td>
520 <td><a href=
"http://en.cppreference.com/w/cpp/memory/allocator_traits">
521 std::allocator_traits
</a></td>
522 <td>Usage should be rare.
</td>
527 <td><code>std::atomic
</code> and others in
<code><atomic
></code></td>
528 <td>Fine-grained atomic types and operations
</td>
529 <td><a href=
"http://en.cppreference.com/w/cpp/atomic"><atomic
></a></td>
535 <td><code>std::array
</code></td>
536 <td>A fixed-size replacement for built-in arrays, with STL support
</td>
537 <td><a href=
"http://en.cppreference.com/w/cpp/container/array">
543 <td>Begin and End Non-Member Functions
</td>
544 <td><code>std::begin()
</code> and
<code>std::end()
</code></td>
545 <td>Allows use of free functions on any container, including
547 <td><a href=
"http://en.cppreference.com/w/cpp/iterator/begin">
549 <a href=
"http://en.cppreference.com/w/cpp/iterator/end">
551 <td>Useful for built-in arrays.
</td>
555 <td>Bind Operations
</td>
556 <td><code>std::bind(
<i>function
</i>,
<i>args
</i>, ...)
</code></td>
557 <td>Declares a function object bound to certain arguments
</td>
558 <td>TODO: documentation link
</td>
563 <td>C Floating-Point Environment
</td>
564 <td><code><cfenv
></code></td>
565 <td>Provides floating point status flags and control modes for C-compatible code
</td>
566 <td><a href=
"http://en.cppreference.com/w/cpp/header/cfenv">Standard library header
<cfenv
></a></td>
567 <td>Compilers do not support use
</td>
571 <td>Chrono Library
</td>
572 <td><code><chrono
></code></td>
573 <td>Provides a standard date and time library
</td>
574 <td><a href=
"http://en.cppreference.com/w/cpp/chrono">Date and time utilities
</a></td>
579 <td>Complex Inverse Trigonometric and Hyperbolic Functions
</td>
580 <td>Functions within
<code><complex
></code></td>
581 <td>Adds inverse trigonomentric and hyperbolic non-member functions to
582 the
<code><complex
></code> library.
</td>
583 <td><a href=
"http://en.cppreference.com/w/cpp/numeric/complex">std::complex
</a></td>
588 <td>Conditional Type Selection
</td>
589 <td><code>std::enable_if
</code> and
<code>std::conditional
</code></td>
590 <td>Enables compile-time conditional type selection
</td>
591 <td><a href=
"http://en.cppreference.com/w/cpp/types/enable_if">
592 std::enable_if
</a> and
593 <a href=
"http://en.cppreference.com/w/cpp/types/conditional">
599 <td>Constant Iterator Methods on Containers
</td>
600 <td><code>std::cbegin()
</code> and
<code>std::cend()
</code></td>
601 <td>Enforces iteration methods that don't change container contents
</td>
602 <td>TODO: documentation link
</td>
607 <td>Construct Elements in Containers
</td>
608 <td><code>emplace()
</code>,
<code>emplace_back()
</code>,
609 <code>emplace_front()
</code>,
<code>emplace_hint()
</code></td>
610 <td>Constructs elements directly within a container without a copy
612 <td>TODO: documentation link
</td>
613 <td>Use where element construction within a container
618 <td>Container Compaction Functions
</td>
619 <td><code>std::vector::shrink_to_fit()
</code>,
620 <code>std::deque::shrink_to_fit()
</code>, and
621 <code>std::string::shrink_to_fit()
</code></td>
622 <td>Requests the removal of unused space
623 in the container
</td>
624 <td><a href=
"http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit">
625 std::vector::shrink_to_fit
</a>,
626 <a href=
"http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit">
627 std::deque::shrink_to_fit
</a>, and
628 <a href=
"http://en.cppreference.com/w/cpp/string/basic_string/shrink_to_fit">
629 std::basic_string::shrink_to_fit
</a></td>
634 <td>Date/Time String Formatting Specifiers
</td>
635 <td><code>std::strftime()
</code></td>
636 <td>Converts date and time information into a
637 formatted string using new specifiers
</td>
638 <td><a href=
"http://en.cppreference.com/w/cpp/chrono/c/strftime">
639 std::strftime
</a></td>
644 <td>Function Return Type Deduction
</td>
645 <td><code>std::result_of
<<i>Functor(ArgTypes...)
</i>></code></td>
646 <td>Extracts the return type from the type signature of
647 a function call invocation at compile-time.
</td>
648 <td><a href=
"http://en.cppreference.com/w/cpp/types/result_of">
649 std::result_of
</a></td>
651 <a href=
"http://stackoverflow.com/questions/15486951/why-does-stdresult-of-take-an-unrelated-function-type-as-a-type-argument">
652 Why does std::result_of take an (unrelated) function type as a type argument?
657 <td>Function Objects
</td>
658 <td><code>std::function
</code></td>
659 <td>Wraps a standard polymorphic function
</td>
660 <td>TODO: documentation link
</td>
665 <td>Forward Lists
</td>
666 <td><code>std::forward_list
</code></td>
667 <td>Provides an efficient singly linked list
</td>
668 <td><a href=
"http://en.cppreference.com/w/cpp/container/forward_list">
669 std::forward_list
</a></td>
674 <td>Gamma Natural Log
</td>
675 <td><code>std::lgamma()
</code></td>
676 <td>Computes the natural log of the gamma of a
677 floating point value
</td>
678 <td><a href=
"http://en.cppreference.com/w/cpp/numeric/math/lgamma">
684 <td>Garbage Collection Features
</td>
685 <td><code>std::{un}declare_reachable()
</code> and
686 <code>std::{un}declare_no_pointers()
</code></td>
687 <td>Enables garbage collection implementations
</td>
688 <td><a href=
"http://en.cppreference.com/w/cpp/memory/gc/declare_reachable">
689 std::declare_reachable
</a>
690 and
<a href=
"http://en.cppreference.com/w/cpp/memory/gc/declare_no_pointers">
691 std::declare_no_pointers
</a></td>
696 <td>Heap Validation
</td>
697 <td><code>std::is_heap()
</code></td>
698 <td>Checks whether an iterator range is in fact a heap
</td>
699 <td>TODO: documentation link
</td>
705 <td><code>std::isnan()
</code></td>
706 <td>Determines if a floating point value is not-a-number
</td>
707 <td><a href=
"http://en.cppreference.com/w/cpp/numeric/math/isnan">std::isnan
</a></td>
712 <td>Iterator Operators
</td>
713 <td><code>std::next()
</code> and
<code>std::prev()
</code></td>
714 <td>Copies an iterator and increments or decrements the copy by
716 <td><a href=
"http://en.cppreference.com/w/cpp/iterator/next">std::next
</a>
717 and
<a href=
"http://en.cppreference.com/w/cpp/iterator/prev">std::prev
</a>
723 <td>Initializer Lists
</td>
724 <td><code>std::initializer_list
<T
></code></td>
725 <td>Allows containers to be initialized with aggregate elements
</td>
726 <td>TODO: documentation link
</td>
731 <td>Move Semantics
</td>
732 <td><code>std::move()
</code></td>
733 <td>Facilitates efficient move operations
</td>
734 <td><a href=
"http://en.cppreference.com/w/cpp/utility/move">
735 <code>std::move
</code> reference
</a></td>
740 <td>Pointer Traits Class Template
</td>
741 <td><code>std::pointer_traits
</code></td>
742 <td>Provides a standard way to access properties
743 of pointers and pointer-like types
</td>
744 <td><a href=
"http://en.cppreference.com/w/cpp/memory/pointer_traits">
745 std::pointer_traits
</a></td>
746 <td>Useful for determining the element type
747 pointed at by a (possibly smart) pointer.
</td>
751 <td>Random Number Generators
</td>
752 <td>Functions within
<code><random
></code></td>
753 <td>Random number generation algorithms and utilities
</td>
754 <td><a href=
"http://en.cppreference.com/w/cpp/numeric/random">
755 Pseudo-random number generation
</a></td>
760 <td>Ratio Template Class
</td>
761 <td><code>std::ratio
<<i>numerator
</i>,
<i>denominator
</i>></code></td>
762 <td>Provides compile-time rational numbers
</td>
763 <td>TODO: documentation link
</td>
768 <td>Reference Wrapper Classes
</td>
769 <td><code>std::reference_wrapper
</code> and
770 <code>std::ref()
</code>,
<code>std::cref()
</code></td>
771 <td>Allows you to wrap a reference within a standard
772 object (and use those within containers)
</td>
773 <td><a href=
"http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=217">
774 Reference Wrappers
</a></td>
779 <td>Regex Library
</td>
780 <td><code><regex
></code></td>
781 <td>Provides a standard regular expressions library
</td>
782 <td><a href=
"http://en.cppreference.com/w/cpp/regex">Regular expressions library
</a></td>
787 <td>Shared Pointers
</td>
788 <td><code>std::shared_ptr
</code></td>
789 <td>Allows shared ownership of a pointer through reference counts
</td>
790 <td><a href=
"http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr
</a></td>
791 <td><a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ownership_and_Smart_Pointers">
792 Ownership and Smart Pointers
</a></td>
796 <td>Soft Program Exits
</td>
797 <td><code>std::at_quick_exit()
</code>
798 and
<code>std::quick_exit()
</code></td>
799 <td>Allows registration of functions to be called upon exit,
800 allowing cleaner program exit than
<code>abort()
</code> or
801 <code>exit
</code></td>
802 <td><a href=
"http://en.cppreference.com/w/cpp/utility/program/quick_exit">
803 std:quick_exit
</a></td>
808 <td>String Direct Reference Functions
</td>
809 <td><code>std::string::front()
</code> and
<code>std::string::back()
</code></td>
810 <td>Returns a reference to the front or back of a string
</td>
811 <td><a href=
"http://en.cppreference.com/w/cpp/string/basic_string/front">
812 std::basic_string::front
</a> and
813 <a href=
"http://en.cppreference.com/w/cpp/string/basic_string/back">
814 std::basic_string::back
</a></td>
819 <td>String to Number Functions
</td>
820 <td><code>std::stoi()
</code>,
<code>std::stol()
</code>,
821 <code>std::stoul()
</code>,
<code>std::stoll
</code>,
<code>std::stoull()
</code>,
822 <code>std::stof()
</code>,
<code>std::stod()
</code>,
<code>std::stold()
</code>,
823 and
<code>std::to_string()
</code></td>
824 <td>Converts strings to numbers
</td>
825 <td><a href=
"http://en.cppreference.com/w/cpp/string/basic_string/stol">
826 std::stoi, std::stol, std::stoll
</a>,
827 <a href=
"http://en.cppreference.com/w/cpp/string/basic_string/stoul">
828 std::stoul, std::stoull
</a>, and
829 <a href=
"http://en.cppreference.com/w/cpp/string/basic_string/stof">
830 std::stof, std::stod, std::stold
</a> </td>
835 <td>STL Algorithms
</td>
836 <td>Functions within
<code><algorithm
></code>.
</td>
837 <td>Enhancements to the set of STL algorithms
</td>
838 <td>See the
<a href=
"http://en.cppreference.com/w/cpp/algorithm">
839 Algorithms library
</a> for a complete list.
</td>
844 <td>System Errors
</td>
845 <td><code><system_error
></code></td>
846 <td>Provides a standard system error library
</td>
847 <td><a href=
"http://en.cppreference.com/w/cpp/error/system_error">std::system_error
</a></td>
852 <td>Trailing Return Types
</td>
853 <td><code>auto
<i>function declaration
</i> -
> <i>return_type
</i></code></td>
854 <td>Allows trailing function return value syntax
</td>
855 <td><a href=
"http://en.cppreference.com/w/cpp/language/function">
856 Declaring functions
</a></td>
857 <td><a href=
"https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/OQyYSfH9m2M">Discussion thread
</a></td>
861 <td>Thread Library
</td>
862 <td><code><thread
> support, including
<future
>,
863 <mutex
>,
<condition_variable
></code></td>
864 <td>Provides a standard mulitthreading library using
<code>std::thread
</code> and associates
</td>
865 <td><a href=
"http://en.cppreference.com/w/cpp/thread">Thread support library
</a></td>
871 <td><code>std::tuple
</code></td>
872 <td>A fixed-size ordered collection of values of mixed types
</td>
873 <td>TODO: documentation link
</td>
878 <td>Type-Generic Math Functions
</td>
879 <td>Functions within
<code><ctgmath
></code></td>
880 <td>Provides a means to call real or complex functions
881 based on the type of arguments
</td>
882 <td><a href=
"http://en.cppreference.com/w/cpp/header/ctgmath">
883 Standard library header
<ctgmath
></a></td>
888 <td>Type Info Enhancements
</td>
889 <td><code>std::type_index
</code> and
<code>std::type_info::hash_code()
</code></td>
890 <td>Allows type information (most often within containers)
891 that can be copied, assigned, or hashed
</td>
892 <td><a href=
"http://en.cppreference.com/w/cpp/types/type_index">
893 std::type_index
</a> and
894 <a href=
"http://en.cppreference.com/w/cpp/types/type_info/hash_code">
895 std::type_info::hash_code
</a></td>
896 <td><code>std::type_index
</code> is a thin wrapper for
897 <code>std::type_info
</code>, allowing you to use it directly
898 within both associative and unordered containers
</td>
903 <td>Class templates within
<code><type_traits
></code></td>
904 <td>Allows compile-time inspection of the properties of types
</td>
905 <td><a href=
"http://en.cppreference.com/w/cpp/header/type_traits">
906 Standard library header
<type_traits
></a></td>
911 <td>Unique Pointers
</td>
912 <td><code>std::unique_ptr
<<i>type
</i>></code></td>
913 <td>Defines a pointer with clear and unambiguous ownership
</td>
914 <td>TODO: documentation link
</td>
915 <td><a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ownership_and_Smart_Pointers">
916 Ownership and Smart Pointers
</a></td>
920 <td>Unordered Associative Containers
</td>
921 <td><code>std::unordered_set
</code>,
<code>std::unordered_map
</code>,
922 <code>std::unordered_multiset
</code>, and
<code>std::unordered_multimap
</code></td>
923 <td>Allows efficient containers of key/value pairs
</td>
924 <td><a href=
"http://en.cppreference.com/w/cpp/container/unordered_map">std::unordered_map
</a>
925 and
<a href=
"http://en.cppreference.com/w/cpp/container/unordered_set">std::unordered_set
</a>
931 <td>Variadic Copy Macro
</td>
932 <td><code>va_copy(va_list
<i>dest
</i>, va_list
<i>src
</i>)
</code></td>
933 <td>Makes a copy of the variadic function arguments
</td>
939 <td>Weak Pointers
</td>
940 <td><code>std::weak_ptr
</code></td>
941 <td>Allows a weak reference to a
<code>std::shared_ptr
</code></td>
942 <td><a href=
"http://en.cppreference.com/w/cpp/memory/weak_ptr">
943 std::weak_ptr
</a></td>
944 <td><a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Ownership_and_Smart_Pointers">
945 Ownership and Smart Pointers
</a></td>
949 <td>Wide String Support
</td>
950 <td><code>std::wstring_convert
</code>,
951 <code>std::wbuffer_convert
</code>.
952 <code>std::codecvt_utf8
</code>,
<code>std::codecvt_utf16
</code>,
953 and
<code>std::codecvt_utf8_utf16
</code></td>
954 <td>Converts between string encodings
</td>
955 <td><a href=
"http://en.cppreference.com/w/cpp/locale/wstring_convert">
956 std::wstring_convert
</a>,
957 <a href=
"http://en.cppreference.com/w/cpp/locale/wbuffer_convert">
958 std::wbuffer_convert
</a>,
959 <a href=
"http://en.cppreference.com/w/cpp/locale/codecvt_utf8">
960 std::codecvt_utf8
</a>,
961 <a href=
"http://en.cppreference.com/w/cpp/locale/codecvt_utf16">
962 std::codecvt_utf16
</a>, and
963 <a href=
"http://en.cppreference.com/w/cpp/locale/codecvt_utf8_utf16">
964 std::codecvt_utf8_utf16
</a>
966 <td>Non-UTF-
8 text is banned by the
967 <a href=
"https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Non-ASCII_Characters">
968 C++ Style Guide
</a>. However, may be useful for
969 consuming non-ASCII data.
</td>