Index: styleguide/c++/c++11.html |
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html |
index 6f0cfccb220d23ffb4c46b83bf2fbeae02576775..e7fcf10fb40c9e2b6a5d50ba227563f83f3ade72 100644 |
--- a/styleguide/c++/c++11.html |
+++ b/styleguide/c++/c++11.html |
@@ -78,23 +78,15 @@ with the language.</p> |
<td>__func__ Local Variable</td> |
<td><code>__func__</code></td> |
<td>Provides a local variable containing the name of the enclosing function</td> |
-<td><a href="https://msdn.microsoft.com/en-us/library/dn919276.aspx">__func__</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/function#func">__func__</a></td> |
<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> |
</tr> |
<tr> |
-<td>Aliases</td> |
-<td><code>using <i>new_alias</i> = <i>typename</i></code></td> |
-<td>Allow parameterized typedefs</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias (using syntax)</a></td> |
-<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> |
-</tr> |
- |
-<tr> |
<td>Angle Bracket Parsing in Templates</td> |
<td><code>>></code> for <code>> ></code>, <code><::</code> for <code>< ::</code></td> |
<td>More intuitive parsing of template parameters</td> |
-<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> |
+<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> |
<td>Recommended to increase readability. Approved without discussion.</td> |
</tr> |
@@ -162,7 +154,7 @@ Class(<i>type</i> <i>var</i>) : Class(<i>var</i>, 0) {}</code></td> |
enum class <i>classname</i> : <i>base-type</i><br /> |
enum <i>enumname</i> : <i>base-type</i></code></td> |
<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> |
-<td><a href="http://www.stroustrup.com/C++11FAQ.html#enum">enum-class</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/enum">enumeration declaration</a></td> |
<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> |
</tr> |
@@ -178,7 +170,7 @@ enum <i>enumname</i> : <i>base-type</i></code></td> |
<td>Final Specifier</td> |
<td><code>final</code></td> |
<td> Indicates that a class or function is final and cannot be overridden</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/final">final Language Reference</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/final">final specifier</a></td> |
<td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
</tr> |
@@ -186,7 +178,7 @@ enum <i>enumname</i> : <i>base-type</i></code></td> |
<td>Function Suppression</td> |
<td><code><i>Function</i>(<i>arguments</i>) = delete;</code></td> |
<td>Suppresses the implementation of a function, especially a synthetic function such as a copy constructor</td> |
-<td>TODO: documentation link</td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/function#Deleted_functions">Deleted functions</a></td> |
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/i1o7-RNRnMs">Discussion thread</a></td> |
</tr> |
@@ -226,7 +218,7 @@ enum <i>enumname</i> : <i>base-type</i></code></td> |
<td>Null Pointer Constant</td> |
<td><code>nullptr</code></td> |
<td>Declares a type-safe null pointer</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/nullptr">nullptr, the pointer literal</a></td> |
<td>Prefer over <code>NULL</code> or <code>0</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/4mijeJHzxLg">Discussion thread</a>. <a href="https://google.github.io/styleguide/cppguide.html#0_and_nullptr/NULL">Google Style Guide</a>. <code>std::nullptr_t</code> can be used too.</td> |
</tr> |
@@ -234,7 +226,7 @@ enum <i>enumname</i> : <i>base-type</i></code></td> |
<td>Override Specifier</td> |
<td><code>override</code></td> |
<td>Indicates that a class or function overrides a base implementation</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/override">override Language Reference</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/override">override specifier</a></td> |
<td>Recommended for new code. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/VTNZzizN0zo">Discussion thread</a></td> |
</tr> |
@@ -251,7 +243,7 @@ enum <i>enumname</i> : <i>base-type</i></code></td> |
<td><code>T(T&& t)</code> and <code>T& operator=(T&& t)<br/><br/> |
template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<td>Reference that only binds to a temporary object</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/references#Rvalue_references">Rvalue references</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/reference#Rvalue_references">Rvalue references</a></td> |
<td>As per the <a href="https://google.github.io/styleguide/cppguide.html#Rvalue_references">Google Style Guide</a>: Only use these to define move constructors and move assignment operators, and for perfect forwarding. Most classes should not be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN in most cases. <a href="https://groups.google.com/a/chromium.org/d/topic/chromium-dev/UnRaORb4TSw">Discussion thread</a>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/Q526tkruXpM">Another discussion thread</a>.</td> |
</tr> |
@@ -259,7 +251,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<td>Standard Integers</td> |
<td>Typedefs within <code><stdint.h></code> and <code><inttypes></code></td> |
<td>Provides fixed-size integers independent of platforms</td> |
-<td><a href="http://www.cplusplus.com/reference/cstdint/"><stdint.h> (cstdint)</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/cstdint">Standard library header <cstdint></a></td> |
<td>Already in common use in the codebase. Approved without discussion.</td> |
</tr> |
@@ -280,6 +272,14 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
</tr> |
<tr> |
+<td>Type Aliases ("using" instead of "typedef")</td> |
+<td><code>using <i>new_alias</i> = <i>typename</i></code></td> |
+<td>Allows parameterized typedefs</td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/type_alias">Type alias, alias template</a></td> |
+<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> |
+</tr> |
+ |
+<tr> |
<td>Uniform Initialization Syntax</td> |
<td><code><i>type</i> <i>name</i> {[<i>value</i> ..., <i>value</i>]};</code></td> |
<td>Allows any object of primitive, aggregate or class type to be initialized using brace syntax</td> |
@@ -291,7 +291,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<td>Union Class Members</td> |
<td><code>union <i>name</i> {<i>class</i> <i>var</i>}</code></td> |
<td>Allows class type members</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/union">Union declarations</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/union">Union declaration</a></td> |
<td>Usage should be rare.</td> |
</tr> |
@@ -351,7 +351,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<code>minmax</code>, <code>minmax_element</code><br/> |
<code>is_permutation<br/></td> |
<td>Safe and performant implementations of common algorithms</td> |
-<td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><algorithm></a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/algorithm">Standard library header <algorithm></a></td> |
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1IuHk">Discussion thread</a><br/> Note that <algorithm> contains a range-based <code>move</code> method. This is allowed, but because people may confuse it with the single-arg <code>std::move</code>, there is often a way to write code without it that is more readable. <a href='https://groups.google.com/a/chromium.org/forum/#!topic/cxx/8WzmtYrZvQ8'>Discussion thread</a></td> |
</tr> |
@@ -380,7 +380,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
</tr> |
<tr> |
-<td>Containers containing movable types</td> |
+<td>Containers containing move-only types</td> |
<td><code>vector<scoped_ptr></code></td> |
<td>Enables containers that contain move-only types like <code>scoped_ptr</code></td> |
<td>TODO</td> |
@@ -428,7 +428,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<code>fmax</code>, <code>fmin</code>, <code>trunc</code>, <code>round</code><br/> |
<code>isinf</code>, <code>isnan</code><br/></td> |
<td>Useful for math-related code</td> |
-<td><a href="http://en.cppreference.com/w/cpp/header/cmath"><cmath></a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/cmath">Standard library header <cmath></a></td> |
<td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/P-1bFBXMeUk">Discussion thread</a></td> |
</tr> |
@@ -465,7 +465,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<code>is_default_constructible</code>, <code>is_move_constructible</code>, <code>is_copy_assignable</code><br/> |
<code>enable_if</code>, <code>conditional</code>, <code>result_of</code><br/></td> |
<td>Allows compile-time inspection of the properties of types</td> |
-<td><a href="http://en.cppreference.com/w/cpp/header/type_traits"><type_traits></a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/type_traits">Standard library header <type_traits></a></td> |
<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> |
</tr> |
@@ -473,7 +473,7 @@ template <typename T><br/>void Function(T&& t) { ... }</code></td> |
<td>Tuples</td> |
<td>All C++11 features in <code><tuple></code>, e.g. <code>std::tie</code> and <code>std::tuple</code>.</td> |
<td>A fixed-size ordered collection of values of mixed types</td> |
-<td><a href="http://en.cppreference.com/w/cpp/header/tuple"><tuple></a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/tuple">Standard library header <tuple></a></td> |
<td>Use <code>base::get</code> instead of <code>std::get</code> in case the <code>std::tuple</code> may be a rvalue-reference. |
<code>std::get</code> in <=libstdc++-4.6 misses an overload for rvalue-reference of a tuple, and <code>base::get</code> complements it. </td> |
</tr> |
@@ -522,7 +522,7 @@ codebase. |
<td>Alignment Features</td> |
<td><code>alignas</code> specifier, <code>alignof</code> operator</td> |
<td>Object alignment</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/alignas">alignas</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof</a></td> |
+<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> |
<td>Reevaluate now that MSVS2015 is available. <a href="https://groups.google.com/a/chromium.org/d/msg/cxx/rwXN02jzzq0/CpUc1ZzMBQAJ">Discussion thread</a></td> |
</tr> |
@@ -538,7 +538,7 @@ codebase. |
<tr> |
<td><code>long long</code> Type</td> |
-<td><code>long long <i>var</i>= <i>value</i>;</code></td> |
+<td><code>long long <i>var</i> = <i>value</i>;</code></td> |
<td>An integer of at least 64 bits</td> |
<td><a href="http://en.cppreference.com/w/cpp/language/types">Fundamental types</a></td> |
<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> |
@@ -578,8 +578,8 @@ t.f(); // first<br /> |
T().f(); // second<br /> |
std::move(t).f(); // second</code></td> |
<td>Allows class member functions to only bind to |this| as an rvalue or lvalue.</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/member_functions">Member functions</a></td> |
-<td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a>. Banned in Chromium except by explicit approval from <code>styleguide/c++/OWNERS</code>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/gowclr2LPQA/discussion">Discussion Thread</a></td> |
+<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> |
+<td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#C++11">Google Style Guide</a>. May only be used in Chromium with explicit approval from <code>styleguide/c++/OWNERS</code>. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/gowclr2LPQA/discussion">Discussion Thread</a></td> |
</tr> |
</tbody> |
@@ -601,35 +601,35 @@ std::move(t).f(); // second</code></td> |
</tr> |
<tr> |
-<td>Chrono Library</td> |
+<td>Date and time utilities</td> |
<td><code><chrono></code></td> |
-<td>Provides a standard date and time library</td> |
+<td>A standard date and time library</td> |
<td><a href="http://en.cppreference.com/w/cpp/chrono">Date and time utilities</a></td> |
-<td>Duplicated <code>Time</code> APIs in <code>base/</code>. Keep using the <code>base/</code> classes.</td> |
+<td>Overlaps with <code>Time</code> APIs in <code>base/</code>. Keep using the <code>base/</code> classes.</td> |
</tr> |
<tr> |
-<td>Regex Library</td> |
+<td>Regular Expressions</td> |
<td><code><regex></code></td> |
-<td>Provides a standard regular expressions library</td> |
+<td>A standard regular expressions library</td> |
<td><a href="http://en.cppreference.com/w/cpp/regex">Regular expressions library</a></td> |
-<td>We already have too many regular expression libraries in Chromium. Use re2 when in doubt.</td> |
+<td>Overlaps with many regular expression libraries in Chromium. When in doubt, use re2.</td> |
</tr> |
<tr> |
<td>Thread Library</td> |
-<td><code><thread></code> support, including<br /> |
+<td><code><thread></code> and related headers, including<br /> |
<code><future></code>, <code><mutex></code>, <code><condition_variable></code></td> |
-<td>Provides a standard mulitthreading library using <code>std::thread</code> and associates</td> |
+<td>Provides a standard multithreading library using <code>std::thread</code> and associates</td> |
<td><a href="http://en.cppreference.com/w/cpp/thread">Thread support library</a></td> |
-<td>C++11 has all kinds of classes for threads, mutexes, etc. Since we already have good code for this in <code>base/</code>, we should keep using the base classes, at least at first. <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> |
+<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> |
</tr> |
<tr> |
<td>Atomics</td> |
-<td><code>std::atomic</code> and others in <code><atomic></code></td> |
+<td><code><atomic></code></td> |
<td>Fine-grained atomic types and operations</td> |
-<td><a href="http://en.cppreference.com/w/cpp/atomic"><atomic></a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/atomic">Atomic operations library</a></td> |
<td>Use in tcmalloc has caused <a href="http://crbug.com/572525">performance regressions</a>. Banned until we understand this better. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/Ej3RAiaI44s/discussion">Discussion Thread</a></td> |
</tr> |
@@ -672,19 +672,19 @@ work in all our compilers yet.</p> |
</tr> |
<tr> |
-<td>Exception Features</td> |
-<td><code>noexcept</code>, <code>exception_ptr</code>, <code>current_exception()</code>, <code>rethrow_exception</code>, <code>nested_exception</code></td> |
+<td>Exceptions</td> |
+<td><code>noexcept</code> and features in <code><exception></code></td> |
<td>Enhancements to exception throwing and handling</td> |
-<td><a href="http://en.cppreference.com/w/cpp/error/exception">std::exception</a></td> |
-<td>Exceptions are banned by the <a href="https://google.github.io/styleguide/cppguide.html#Exceptions">Google Style Guide</a>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/exception">Standard library header <exception></a></td> |
+<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. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/8i4tMqNpHhg">Discussion thread</a></td> |
</tr> |
<tr> |
<td>Inline Namespaces</td> |
-<td><code>inline</code></td> |
+<td><code>inline namespace foo { ... }</code></td> |
<td>Allows better versioning of namespaces</td> |
-<td><a href="http://en.cppreference.com/w/cpp/language/namespace">Namespaces</a></td> |
-<td>Unclear how it will work with components</td> |
+<td><a href="http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces">Inline namespaces</a></td> |
+<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> |
</tr> |
<tr> |
@@ -692,7 +692,7 @@ work in all our compilers yet.</p> |
<td><code><i>type</i> <i>var</i> = <i>literal_value</i>_<i>type</i></code></td> |
<td>Allows user-defined literal expressions</td> |
<td><a href="http://en.cppreference.com/w/cpp/language/user_literal">User-defined literals</a></td> |
-<td></td> |
+<td>Banned in the <a href="https://google.github.io/styleguide/cppguide.html#Operator_Overloading">Google Style Guide</a>.</td> |
</tr> |
</tbody> |
@@ -742,7 +742,7 @@ work in all our compilers yet.</p> |
<td>Bind Operations</td> |
<td><code>std::bind(<i>function</i>, <i>args</i>, ...)</code></td> |
<td>Declares a function object bound to certain arguments</td> |
-<td>TODO: documentation link</td> |
+<td><a href="http://en.cppreference.com/w/cpp/utility/functional/bind">std::bind</a></td> |
<td></td> |
</tr> |
@@ -790,7 +790,7 @@ work in all our compilers yet.</p> |
<td>Function Objects</td> |
<td><code>std::function</code></td> |
<td>Wraps a standard polymorphic function</td> |
-<td>TODO: documentation link</td> |
+<td><a href="http://en.cppreference.com/w/cpp/utility/functional/function">std::function</a></td> |
<td></td> |
</tr> |
@@ -854,7 +854,7 @@ work in all our compilers yet.</p> |
<td>Reference Wrapper Classes</td> |
<td><code>std::reference_wrapper</code> and <code>std::ref()</code>, <code>std::cref()</code></td> |
<td>Allows you to wrap a reference within a standard object (and use those within containers)</td> |
-<td><a href="http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=217">Reference Wrappers</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper">std::reference_wrapper</a></td> |
<td></td> |
</tr> |
@@ -878,13 +878,13 @@ work in all our compilers yet.</p> |
<td>System Errors</td> |
<td><code><system_error></code></td> |
<td>Provides a standard system error library</td> |
-<td><a href="http://en.cppreference.com/w/cpp/error/system_error">std::system_error</a></td> |
+<td><a href="http://en.cppreference.com/w/cpp/header/system_error">Standard library header <system_error></a></td> |
<td></td> |
</tr> |
<tr> |
<td>Type-Generic Math Functions</td> |
-<td>Functions within <code><ctgmath></code></td> |
+<td><code><ctgmath></code></td> |
<td>Provides a means to call real or complex functions based on the type of arguments</td> |
<td><a href="http://en.cppreference.com/w/cpp/header/ctgmath">Standard library header <ctgmath></a></td> |
<td></td> |
@@ -902,7 +902,7 @@ work in all our compilers yet.</p> |
<td>Variadic Copy Macro</td> |
<td><code>va_copy(va_list <i>dest</i>, va_list <i>src</i>)</code></td> |
<td>Makes a copy of the variadic function arguments</td> |
-<td></td> |
+<td><a href="http://en.cppreference.com/w/cpp/utility/variadic/va_copy">va_copy</a></td> |
<td></td> |
</tr> |