[libcxx] r231375 - Rework reverse_iterator::operator[] so as not to use the base iterators operator [], which can cause constness problems. Fixes PR17883

Marshall Clow mclow.lists at gmail.com
Thu Mar 5 08:07:37 PST 2015


Author: marshall
Date: Thu Mar  5 10:07:37 2015
New Revision: 231375

URL: http://llvm.org/viewvc/llvm-project?rev=231375&view=rev
Log:
Rework reverse_iterator::operator[] so as not to use the base iterators operator [], which can cause constness problems. Fixes PR17883

Modified:
    libcxx/trunk/include/iterator

Modified: libcxx/trunk/include/iterator
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=231375&r1=231374&r2=231375&view=diff
==============================================================================
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Thu Mar  5 10:07:37 2015
@@ -575,7 +575,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator-=(difference_type __n)
         {current += __n; return *this;}
     _LIBCPP_INLINE_VISIBILITY reference         operator[](difference_type __n) const
-        {return current[-__n-1];}
+        {return *(*this + __n);}
 };
 
 template <class _Iter1, class _Iter2>





More information about the cfe-commits mailing list