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

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

Issue 1675483002: Allow use of container cbegin() and cend() methods, plus sample uses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New sample uses Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2014 The Chromium Authors. All rights reserved. 3 Copyright 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <head> 8 <head>
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <title>C++11 use in Chromium</title> 10 <title>C++11 use in Chromium</title>
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 </td> 350 </td>
351 <td>Safe and performant implementations of common algorithms</td> 351 <td>Safe and performant implementations of common algorithms</td>
352 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code>&lt;algori thm&gt;</code></a></td> 352 <td><a href="http://en.cppreference.com/w/cpp/header/algorithm"><code>&lt;algori thm&gt;</code></a></td>
353 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/> 353 <td><a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/UJQk8S1I uHk">Discussion thread</a><br/>
354 Note that &lt;algorithm&gt; contains a range-based <code>move</code> method. Th is 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/8WzmtYrZv Q8'>Discussion thread</a></td> 354 Note that &lt;algorithm&gt; contains a range-based <code>move</code> method. Th is 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/8WzmtYrZv Q8'>Discussion thread</a></td>
355 </tr> 355 </tr>
356 356
357 <tr> 357 <tr>
358 <td>Begin and End Non-Member Functions</td> 358 <td>Begin and End Non-Member Functions</td>
359 <td><code>std::begin()</code> and <code>std::end()</code></td> 359 <td><code>std::begin()</code> and <code>std::end()</code></td>
360 <td>Allows use of free functions on any container, including 360 <td>Allows use of free functions on any container, including fixed-size arrays</ td>
361 fixed-size arrays</td> 361 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin">std::begin</a> and <a href="http://en.cppreference.com/w/cpp/iterator/end">std::end</a></td>
362 <td><a href="http://en.cppreference.com/w/cpp/iterator/begin">
363 std::begin</a> and
364 <a href="http://en.cppreference.com/w/cpp/iterator/end">
365 std::end</a></td>
366 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td> 362 <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium. org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td>
367 </tr> 363 </tr>
368 364
369 <tr> 365 <tr>
370 <td>Conditional Type Selection</td> 366 <td>Conditional Type Selection</td>
371 <td><code>std::enable_if</code> and <code>std::conditional</code></td> 367 <td><code>std::enable_if</code> and <code>std::conditional</code></td>
372 <td>Enables compile-time conditional type selection</td> 368 <td>Enables compile-time conditional type selection</td>
373 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a > and <a href="http://en.cppreference.com/w/cpp/types/conditional">conditional</ a></td> 369 <td><a href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a > and <a href="http://en.cppreference.com/w/cpp/types/conditional">conditional</ a></td>
374 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td> 370 <td>Usage should be rare. <a href='https://groups.google.com/a/chromium.org/foru m/#!topic/cxx/vCxo4tZNd_M'>Discussion thread</a></td>
375 </tr> 371 </tr>
376 372
377 <tr> 373 <tr>
374 <td>Constant Iterator Methods on Containers</td>
375 <td><code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></td>
376 <td>Allows more widespread use of <code>const_iterator</code></td>
377 <td>E.g. <a href="http://en.cppreference.com/w/cpp/container/vector/begin">std:: vector::cbegin<a> and <a href="http://en.cppreference.com/w/cpp/container/vector /end">std::vector::cend<a></td>
378 <td>Applies to all containers, not just <code>vector</code>. Consider using <co de>const_iterator</code> over <code>iterator</code> where possible for the same reason as using <code>const</code> variables and functions where possible; see E ffective Modern C++ item 13 for motivation. <a href="https://groups.google.com/ a/chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discussion thread</a></td>
Nico 2016/02/10 16:54:56 maybe mention that global std::cbegin()/cend() is
Peter Kasting 2016/02/11 00:44:35 I added a note about this to the item on non-membe
379 </tr>
380
381 <tr>
378 <td>Containers containing movable types</td> 382 <td>Containers containing movable types</td>
379 <td><code>vector&lt;scoped_ptr&gt;</code></td> 383 <td><code>vector&lt;scoped_ptr&gt;</code></td>
380 <td>Enables containers that contain move-only types like <code>scoped_ptr</code> </td> 384 <td>Enables containers that contain move-only types like <code>scoped_ptr</code> </td>
381 <td>TODO</td> 385 <td>TODO</td>
382 <td>Allows getting rid of <a href="http://crbug.com/554289">ScopedVector</a></td > 386 <td>Allows getting rid of <a href="http://crbug.com/554289">ScopedVector</a></td >
383 </tr> 387 </tr>
384 388
385 <tr> 389 <tr>
386 <td>Emplacement methods for containers</td> 390 <td>Emplacement methods for containers</td>
387 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td> 391 <td><code>emplace()</code>, <code>emplace_back()</code>, <code>emplace_front()</ code>, <code>emplace_hint()</code></td>
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 <tr> 843 <tr>
840 <td>Complex Inverse Trigonometric and Hyperbolic Functions</td> 844 <td>Complex Inverse Trigonometric and Hyperbolic Functions</td>
841 <td>Functions within <code>&lt;complex&gt;</code></td> 845 <td>Functions within <code>&lt;complex&gt;</code></td>
842 <td>Adds inverse trigonomentric and hyperbolic non-member functions to 846 <td>Adds inverse trigonomentric and hyperbolic non-member functions to
843 the <code>&lt;complex&gt;</code> library.</td> 847 the <code>&lt;complex&gt;</code> library.</td>
844 <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a>< /td> 848 <td><a href="http://en.cppreference.com/w/cpp/numeric/complex">std::complex</a>< /td>
845 <td></td> 849 <td></td>
846 </tr> 850 </tr>
847 851
848 <tr> 852 <tr>
849 <td>Constant Iterator Methods on Containers</td>
850 <td><code>std::vector::cbegin()</code> and <code>std::vector::cend()</code></td>
851 <td>Enforces iteration methods that don't change container contents</td>
852 <td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vecto r::cbegin<a></td>
853 <td>This applies to all containers, std::vector is just an example. <a href="htt ps://groups.google.com/a/chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discus sion thread</a></td>
854 </tr>
855
856 <tr>
857 <td>Container Compaction Functions</td> 853 <td>Container Compaction Functions</td>
858 <td><code>std::vector::shrink_to_fit()</code>, 854 <td><code>std::vector::shrink_to_fit()</code>,
859 <code>std::deque::shrink_to_fit()</code>, and 855 <code>std::deque::shrink_to_fit()</code>, and
860 <code>std::string::shrink_to_fit()</code></td> 856 <code>std::string::shrink_to_fit()</code></td>
861 <td>Requests the removal of unused space 857 <td>Requests the removal of unused space
862 in the container</td> 858 in the container</td>
863 <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit"> 859 <td><a href="http://en.cppreference.com/w/cpp/container/vector/shrink_to_fit">
864 std::vector::shrink_to_fit</a>, 860 std::vector::shrink_to_fit</a>,
865 <a href="http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit"> 861 <a href="http://en.cppreference.com/w/cpp/container/deque/shrink_to_fit">
866 std::deque::shrink_to_fit</a>, and 862 std::deque::shrink_to_fit</a>, and
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 C++ Style Guide</a>. However, may be useful for 1106 C++ Style Guide</a>. However, may be useful for
1111 consuming non-ASCII data.</td> 1107 consuming non-ASCII data.</td>
1112 </tr> 1108 </tr>
1113 1109
1114 </tbody> 1110 </tbody>
1115 </table> 1111 </table>
1116 1112
1117 </div> 1113 </div>
1118 </body> 1114 </body>
1119 </html> 1115 </html>
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698