[libc++] Rewrite std::to_address to avoid relying on element_type
This is a rough reapplication of the change that fixed std::to_address
to avoid relying on element_type (da456167). It is somewhat different
because the fix to avoid breaking Clang (which caused it to be reverted
in 347f69c55) was a bit more involved.
Differential Revision: https://reviews.llvm.org/D101638
NOKEYCHECK=True
GitOrigin-RevId: fe0e86e6026f79e0b18f877196fbddd1d9e140d8
diff --git a/include/iterator b/include/iterator
index 1d308a2..687c641 100644
--- a/include/iterator
+++ b/include/iterator
@@ -1356,7 +1356,7 @@
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
"Attempted to dereference a non-dereferenceable iterator");
#endif
- return (pointer)_VSTD::addressof(*__i);
+ return _VSTD::__to_address(__i);
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
{