summaryrefslogtreecommitdiffstats
path: root/styleguide
diff options
context:
space:
mode:
authorpkasting <pkasting@chromium.org>2016-02-10 17:35:53 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-11 01:37:04 +0000
commita234a0774c1ae03eadcfba867891df8f822229f6 (patch)
tree4b0b4443c8274231851c8b0310bf4dd9c8f6904e /styleguide
parent0cb852e886746830b48c09b426705b23c6845d4c (diff)
downloadchromium_src-a234a0774c1ae03eadcfba867891df8f822229f6.zip
chromium_src-a234a0774c1ae03eadcfba867891df8f822229f6.tar.gz
chromium_src-a234a0774c1ae03eadcfba867891df8f822229f6.tar.bz2
Allow use of container cbegin() and cend() methods, plus sample uses.
This also fixes a small bug in the histogram recording of TabStripModelStatsRecorder::ActiveTabChanged() I spotted while doing this. BUG=none TEST=none Review URL: https://codereview.chromium.org/1675483002 Cr-Commit-Position: refs/heads/master@{#374827}
Diffstat (limited to 'styleguide')
-rw-r--r--styleguide/c++/c++11.html27
1 files changed, 12 insertions, 15 deletions
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html
index 239a282..27d37b6 100644
--- a/styleguide/c++/c++11.html
+++ b/styleguide/c++/c++11.html
@@ -357,13 +357,10 @@ Note that &lt;algorithm&gt; 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>Useful for fixed-size arrays. <a href="https://groups.google.com/a/chromium.org/d/topic/cxx/5iFNE8P5qT4/discussion">Discussion thread</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><br>
+Note that non-member <code>cbegin()</code> and <code>cend()</code> are not available until C++14.</td>
</tr>
<tr>
@@ -375,6 +372,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>
+</tr>
+
+<tr>
<td>Containers containing movable types</td>
<td><code>vector&lt;scoped_ptr&gt;</code></td>
<td>Enables containers that contain move-only types like <code>scoped_ptr</code></td>
@@ -846,14 +851,6 @@ the <code>&lt;complex&gt;</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