Implement LWG 2360: 'reverse_iterator::operator*() is unimplementable'. Note that this is a (small) behavior change in the library. Reverse iterators whose base iterators' operator* return references to 'within themselves' have been sacrificed to the greater goal of avoiding data races.
llvm-svn: 203587
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: ef3d68009382d2888a397632aaa24c6c0a975525
diff --git a/include/iterator b/include/iterator
index 5aa784f..4c6b0a6 100644
--- a/include/iterator
+++ b/include/iterator
@@ -536,8 +536,6 @@
typename iterator_traits<_Iter>::pointer,
typename iterator_traits<_Iter>::reference>
{
-private:
- mutable _Iter __t;
protected:
_Iter current;
public:
@@ -547,11 +545,11 @@
typedef typename iterator_traits<_Iter>::pointer pointer;
_LIBCPP_INLINE_VISIBILITY reverse_iterator() : current() {}
- _LIBCPP_INLINE_VISIBILITY explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
+ _LIBCPP_INLINE_VISIBILITY explicit reverse_iterator(_Iter __x) : current(__x) {}
template <class _Up> _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u)
- : __t(__u.base()), current(__u.base()) {}
+ : current(__u.base()) {}
_LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;}
- _LIBCPP_INLINE_VISIBILITY reference operator*() const {__t = current; return *--__t;}
+ _LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;}
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return _VSTD::addressof(operator*());}
_LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;}
_LIBCPP_INLINE_VISIBILITY reverse_iterator operator++(int)