This is an automated email from the git hooks/post-receive script.
sparks pushed a commit to branch master
in repository defensive-coding-guide.
commit 7db67ea9b35a0cb04a0b68048802950775558579
Author: Florian Weimer <fweimer(a)redhat.com>
Date: Thu Sep 19 15:15:28 2013 +0200
C++: Mention front(), back() and data() member functions of vectors
---
defensive-coding/en-US/CXX-Std.xml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/defensive-coding/en-US/CXX-Std.xml b/defensive-coding/en-US/CXX-Std.xml
index 56e1ad0..155f70c 100644
--- a/defensive-coding/en-US/CXX-Std.xml
+++ b/defensive-coding/en-US/CXX-Std.xml
@@ -163,6 +163,15 @@
<literal>operator[](size_type)</literal>, even though it is
slightly more verbose.
</para>
+ <para>
+ The <literal>front()</literal> and
<literal>back()</literal>
+ member functions are undefined if a vector object is empty. You
+ can use <literal>vec.at(0)</literal> and
+ <literal>vec.at(vec.size() - 1)</literal> as checked
+ replacements. For an empty vector, <literal>data()</literal> is
+ defined; it returns an arbitrary pointer, but not necessarily
+ the NULL pointer.
+ </para>
</section>
<section id="sect-Defensive_Coding-CXX-Std-Iterators">
<title>Iterators</title>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by thread