diff options
author | jbroman <jbroman@chromium.org> | 2016-01-07 15:43:54 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-07 23:45:02 +0000 |
commit | d21995c5b183ae0dbc3f46f9ab959986b877efd8 (patch) | |
tree | 3e65803a6fa6d337c781c402c1df7a8c3be0ff8f /styleguide | |
parent | d107d5224f806eb9fc32daa23fd5fdf950310013 (diff) | |
download | chromium_src-d21995c5b183ae0dbc3f46f9ab959986b877efd8.zip chromium_src-d21995c5b183ae0dbc3f46f9ab959986b877efd8.tar.gz chromium_src-d21995c5b183ae0dbc3f46f9ab959986b877efd8.tar.bz2 |
styleguide: Ban ref-qualified member functions, <atomic>, std::shared_ptr and std::initializer_list.
NOTRY=true
Review URL: https://codereview.chromium.org/1570443005
Cr-Commit-Position: refs/heads/master@{#368198}
Diffstat (limited to 'styleguide')
-rw-r--r-- | styleguide/c++/c++11.html | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html index 3f014b1..2776be9 100644 --- a/styleguide/c++/c++11.html +++ b/styleguide/c++/c++11.html @@ -559,6 +559,18 @@ string literal</a></td> <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> </tr> +<tr> +<td>Ref-qualified Member Functions</td> +<td><code>class T {<br/> void f() & {}<br/> void f() && {}<br/>};<br/>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 google3 C++11 library style guide. 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> +</tr> + </tbody> </table> @@ -602,6 +614,37 @@ string literal</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> </tr> +<tr> +<td>Atomics</td> +<td><code>std::atomic</code> and others in <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>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> + +<tr> +<td>Shared Pointers</td> +<td><code>std::shared_ptr</code></td> +<td>Allows shared ownership of a pointer through reference counts</td> +<td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr</a></td> +<td> + Needs a lot more evaluation for Chromium, and there isn't enough of a push for this feature. + <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/aT2wsBLKvzI/discussion">Discussion Thread</a>, + <a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers">Google Style Guide</a> +</td> +</tr> + +<tr> +<td>Initializer Lists</td> +<td><code>std::initializer_list<T></code></td> +<td>Allows containers to be initialized with aggregate elements</td> +<td><a href="http://en.cppreference.com/w/cpp/utility/initializer_list"><code>std::initializer_list</code></a></td> +<td> + Banned for now; will be re-evaluated once we switch to MSVC 2015. + <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/TQQ-L51_naM/discussion">Discussion Thread</a> +</td> +</tr> + </tbody> </table> @@ -655,15 +698,6 @@ std::exception</a></td> </tr> <tr> -<td>Ref-qualified Member Functions</td> -<td><code>class T {<br/> void f() & {}<br/> void f() && {}<br/>};<br/>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 google3 C++11 library style guide, but being considered for use in bind/callback in google3 and the standard library.</td> -</tr> - -<tr> <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> @@ -735,14 +769,6 @@ std::allocator_traits</a></td> </tr> <tr> -<td>Atomics</td> -<td><code>std::atomic</code> and others in <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></td> -</tr> - -<tr> <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> @@ -885,14 +911,6 @@ and <a href="http://en.cppreference.com/w/cpp/iterator/prev">std::prev</a> </tr> <tr> -<td>Initializer Lists</td> -<td><code>std::initializer_list<T></code></td> -<td>Allows containers to be initialized with aggregate elements</td> -<td>TODO: documentation link</td> -<td></td> -</tr> - -<tr> <td>Pointer Traits Class Template</td> <td><code>std::pointer_traits</code></td> <td>Provides a standard way to access properties @@ -934,15 +952,6 @@ Reference Wrappers</a></td> </tr> <tr> -<td>Shared Pointers</td> -<td><code>std::shared_ptr</code></td> -<td>Allows shared ownership of a pointer through reference counts</td> -<td><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">std::shared_ptr</a></td> -<td><a href="https://google.github.io/styleguide/cppguide.html#Ownership_and_Smart_Pointers"> -Ownership and Smart Pointers</a></td> -</tr> - -<tr> <td>Soft Program Exits</td> <td><code>std::at_quick_exit()</code> and <code>std::quick_exit()</code></td> |