This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Small list fix


Sorry if I misunderstood, but in a previous submission I was told not to write "--end()". However I wondered across a couple of occurances of this very thing in stl_list.h!

A very simple patch, bootstrapped and tests, and produces identical output on -O2 to the old version.

Sorry if I misunderstood the exact cases in which doing --end() is and is not allowed...

Chris
2004-11-18  Chris Jefferson  <chris@bubblescope.net>

	* include/bits/stl_list.h (list::back): Don't decrement 
	temporary.
	(list::back const): Likewise.
Index: gcc/libstdc++-v3/include/bits/stl_list.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/include/bits/stl_list.h,v
retrieving revision 1.44
diff -p -c -3 -r1.44 stl_list.h
*** gcc/libstdc++-v3/include/bits/stl_list.h	3 Oct 2004 15:50:32 -0000	1.44
--- gcc/libstdc++-v3/include/bits/stl_list.h	18 Nov 2004 01:35:59 -0000
*************** namespace _GLIBCXX_STD
*** 707,713 ****
         */
        reference
        back()
!       { return *(--end()); }
  
        /**
         *  Returns a read-only (constant) reference to the data at the last
--- 707,716 ----
         */
        reference
        back()
!       {
!         iterator __it = end();
!         return *(--__it);
!       }
  
        /**
         *  Returns a read-only (constant) reference to the data at the last
*************** namespace _GLIBCXX_STD
*** 715,721 ****
         */
        const_reference
        back() const
!       { return *(--end()); }
  
        // [23.2.2.3] modifiers
        /**
--- 718,727 ----
         */
        const_reference
        back() const
!       {
!         const_iterator __it = end();
!         return *(--__it);
!       }
  
        // [23.2.2.3] modifiers
        /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]