This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Minor tweak to list::back
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 19 Nov 2004 13:47:28 +0100
- Subject: [v3] Minor tweak to list::back
Hi,
tested x86-linux, committed to mainline.
Paolo.
///////////////
2004-11-19 Chris Jefferson <chris@bubblescope.net>
* include/bits/stl_list.h (list::back, list::back const):
Don't decrement temporary.
2004-11-19 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_deque.h (deque::front, deque::front const,
deque::back, deque::back const): Slightly tweak for stylistic
consistency.
diff -urN libstdc++-v3-orig/include/bits/stl_deque.h libstdc++-v3/include/bits/stl_deque.h
--- libstdc++-v3-orig/include/bits/stl_deque.h 2004-10-12 03:10:38.000000000 +0200
+++ libstdc++-v3/include/bits/stl_deque.h 2004-11-19 13:06:01.000000000 +0100
@@ -970,7 +970,7 @@
*/
reference
front()
- { return *this->_M_impl._M_start; }
+ { return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
@@ -978,7 +978,7 @@
*/
const_reference
front() const
- { return *this->_M_impl._M_start; }
+ { return *begin(); }
/**
* Returns a read/write reference to the data at the last element of the
@@ -987,7 +987,7 @@
reference
back()
{
- iterator __tmp = this->_M_impl._M_finish;
+ iterator __tmp = end();
--__tmp;
return *__tmp;
}
@@ -999,7 +999,7 @@
const_reference
back() const
{
- const_iterator __tmp = this->_M_impl._M_finish;
+ const_iterator __tmp = end();
--__tmp;
return *__tmp;
}
diff -urN libstdc++-v3-orig/include/bits/stl_list.h libstdc++-v3/include/bits/stl_list.h
--- libstdc++-v3-orig/include/bits/stl_list.h 2004-10-03 17:50:32.000000000 +0200
+++ libstdc++-v3/include/bits/stl_list.h 2004-11-19 12:44:00.000000000 +0100
@@ -707,7 +707,11 @@
*/
reference
back()
- { return *(--end()); }
+ {
+ iterator __tmp = end();
+ --__tmp;
+ return *__tmp;
+ }
/**
* Returns a read-only (constant) reference to the data at the last
@@ -715,7 +719,11 @@
*/
const_reference
back() const
- { return *(--end()); }
+ {
+ const_iterator __tmp = end();
+ --__tmp;
+ return *__tmp;
+ }
// [23.2.2.3] modifiers
/**