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
This commit is contained in:
Marshall Clow 2016-04-11 03:54:53 +00:00
parent a07ad647ee
commit 05333fc8af
2 changed files with 5 additions and 8 deletions

View File

@ -949,7 +949,7 @@ public:
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef typename iterator_traits<iterator_type>::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<reference>(*__i);
}
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {
typename iterator_traits<iterator_type>::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<const volatile char&>(*__i);
return (pointer)_VSTD::addressof(*__i);
}
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
{

View File

@ -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<It> T;
static_assert((std::is_same<typename R::iterator_type, It>::value), "");
static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
static_assert((std::is_same<typename R::pointer, It>::value), "");
static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");