Chromium Code Reviews| Index: styleguide/c++/c++11.html |
| diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html |
| index 239a282a13626484e39051dbe752e4fd6c3fd2e0..16bb260a8deb88d7758c828cae48ed5a4d11cd7f 100644 |
| --- a/styleguide/c++/c++11.html |
| +++ b/styleguide/c++/c++11.html |
| @@ -357,12 +357,8 @@ Note that <algorithm> contains a range-based <code>move</code> method. Th |
| <tr> |
| <td>Begin and End Non-Member Functions</td> |
| <td><code>std::begin()</code> and <code>std::end()</code></td> |
| -<td>Allows use of free functions on any container, including |
| -fixed-size arrays</td> |
| -<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> |
| +<td>Allows use of free functions on any container, including fixed-size arrays</td> |
| +<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> |
| <td>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</a></td> |
| </tr> |
| @@ -375,6 +371,14 @@ std::end</a></td> |
| </tr> |
| <tr> |
| +<td>Constant Iterator Methods on Containers</td> |
| +<td><code>std::vector::cbegin()</code>, <code>std::vector::cend()</code></td> |
| +<td>Allows more widespread use of <code>const_iterator</code></td> |
| +<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> |
| +<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 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
|
| +</tr> |
| + |
| +<tr> |
| <td>Containers containing movable types</td> |
| <td><code>vector<scoped_ptr></code></td> |
| <td>Enables containers that contain move-only types like <code>scoped_ptr</code></td> |
| @@ -846,14 +850,6 @@ the <code><complex></code> library.</td> |
| </tr> |
| <tr> |
| -<td>Constant Iterator Methods on Containers</td> |
| -<td><code>std::vector::cbegin()</code> and <code>std::vector::cend()</code></td> |
| -<td>Enforces iteration methods that don't change container contents</td> |
| -<td><a href="http://en.cppreference.com/w/cpp/container/vector/begin">std::vector::cbegin<a></td> |
| -<td>This applies to all containers, std::vector is just an example. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/cS83F_buqLM/discussion">Discussion thread</a></td> |
| -</tr> |
| - |
| -<tr> |
| <td>Container Compaction Functions</td> |
| <td><code>std::vector::shrink_to_fit()</code>, |
| <code>std::deque::shrink_to_fit()</code>, and |