diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -13,7 +13,7 @@ #include <__config> #include <__debug> #include <__iterator/iterator_traits.h> -#include <__memory/pointer_traits.h> // __to_address +#include <__memory/pointer_traits.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -283,12 +283,33 @@ struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; #endif -template -_LIBCPP_CONSTEXPR -decltype(_VSTD::__to_address(declval<_Iter>())) -__to_address(__wrap_iter<_Iter> __w) _NOEXCEPT { - return _VSTD::__to_address(__w.base()); -} +template +struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > +{ + typedef __wrap_iter<_It> pointer; + typedef typename pointer_traits<_It>::element_type element_type; + typedef typename pointer_traits<_It>::difference_type difference_type; + +#ifndef _LIBCPP_CXX03_LANG + template using rebind = _Up*; +#else + template struct rebind {typedef _Up* other;}; +#endif + +private: + struct __nat {}; +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + static element_type *to_address(pointer __w) _NOEXCEPT { + return _VSTD::__to_address(__w.base()); + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + static pointer pointer_to(typename conditional::value, + __nat, element_type>::type& __r) _NOEXCEPT { + return pointer_traits<_It>::pointer_to(__r); + } +}; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/test/std/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp b/libcxx/test/std/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp --- a/libcxx/test/std/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp +++ b/libcxx/test/std/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp @@ -10,10 +10,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 -// TODO: We should enable this test in Debug mode once we fix __wrap_iter -// to be a proper contiguous_iterator. -// UNSUPPORTED: LIBCXX-DEBUG-FIXME - // template constexpr T* to_address(T* p) noexcept; // template constexpr auto to_address(const Ptr& p) noexcept;