From 05333fc8af4347cb2d4d2e7a8266ff534e589a32 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 11 Apr 2016 03:54:53 +0000 Subject: [PATCH] Implement LWG#680, which was missed lo these many moons ago, and was reported as bug #27259. As a drive-by fix, replace the hand-rolled equivalent to addressof in __wrap_iter with the real thing. llvm-svn: 265914 --- libcxx/include/iterator | 9 +++------ .../predef.iterators/move.iterators/move.iterator/types.pass.cpp | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libcxx/include/iterator b/libcxx/include/iterator index e5bb493..e6f4723 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -949,7 +949,7 @@ public: typedef typename iterator_traits::iterator_category iterator_category; typedef typename iterator_traits::value_type value_type; typedef typename iterator_traits::difference_type difference_type; - typedef typename iterator_traits::pointer pointer; + typedef iterator_type pointer; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typedef value_type&& reference; #else @@ -964,10 +964,7 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { return static_cast(*__i); } - _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - typename iterator_traits::reference __ref = *__i; - return &__ref; - } + _LIBCPP_INLINE_VISIBILITY pointer operator->() const { return __i;} _LIBCPP_INLINE_VISIBILITY move_iterator& operator++() {++__i; return *this;} _LIBCPP_INLINE_VISIBILITY move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} @@ -1185,7 +1182,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable iterator"); #endif - return (pointer)&reinterpret_cast(*__i); + return (pointer)_VSTD::addressof(*__i); } _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT { diff --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp index 9bdf721..1a3081f 100644 --- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp @@ -18,7 +18,7 @@ // public: // typedef Iter iterator_type; // typedef Iter::difference_type difference_type; -// typedef Iterator pointer; +// typedef Iter pointer; // typedef Iter::value_type value_type; // typedef value_type&& reference; // }; @@ -36,7 +36,7 @@ test() typedef std::iterator_traits T; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES static_assert((std::is_same::value), ""); -- 2.7.4