diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-01-26 00:12:48 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-01-26 00:12:48 +0000 |
| commit | d18302f1bb4d54a3266e21ffe20be133f69e3f7c (patch) | |
| tree | 6ce51e975fe30c8a695f4f52d1c4ae361e4990d3 | |
| parent | 3fde51b8201d563b69d99efc0a5da12c658b3d5a (diff) | |
| download | bcm5719-llvm-d18302f1bb4d54a3266e21ffe20be133f69e3f7c.tar.gz bcm5719-llvm-d18302f1bb4d54a3266e21ffe20be133f69e3f7c.zip | |
Teach move_iterator that rvalue references cannot bind to non-function
lvalues, nor can one take the address of an xvalue, by adding
appropriate static_cast's (in the first case) and a temporary (in the
second case).
llvm-svn: 124255
| -rw-r--r-- | libcxx/include/iterator | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 6fcb259f9a2..8bb811fe65f 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -902,8 +902,13 @@ public: template <class _Up> _LIBCPP_INLINE_VISIBILITY move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} _LIBCPP_INLINE_VISIBILITY _Iter base() const {return __i;} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} + _LIBCPP_INLINE_VISIBILITY reference operator*() const { + return static_cast<reference>(*__i); + } + _LIBCPP_INLINE_VISIBILITY pointer operator->() const { + typename iterator_traits<iterator_type>::reference __ref = *__i; + return &__ref; + } _LIBCPP_INLINE_VISIBILITY move_iterator& operator++() {++__i; return *this;} _LIBCPP_INLINE_VISIBILITY move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} @@ -919,7 +924,9 @@ public: _LIBCPP_INLINE_VISIBILITY move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return __i[__n];} + { + return static_cast<reference>(__i[__n]); + } }; template <class _Iter1, class _Iter2> |

