[libcxx-commits] [PATCH] D101404: [libc++] Comment preconditions for __wrap_iter; make it work with C++20 to_address

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 29 14:54:10 PDT 2021


Quuxplusone planned changes to this revision.
Quuxplusone added inline comments.


================
Comment at: libcxx/include/iterator:1350-1357
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer  operator->() const _NOEXCEPT
     {
 #if _LIBCPP_DEBUG_LEVEL == 2
         _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
                        "Attempted to dereference a non-dereferenceable iterator");
 #endif
         return (pointer)_VSTD::addressof(*__i);
----------------
https://reviews.llvm.org/harbormaster/unit/view/565840/
It turns out that `__wrap_iter::operator->()` assert-fails in situations where we need `std::to_address` //not// to assert-fail. So, since I want `to_address` to work — and since we can't implement `to_address` in terms of `operator->` — the only remaining possibility is to implement `to_address` in terms of a manually specialized `pointer_traits<__wrap_iter>::to_address`.

(The specification of `to_address` should have done it as an ordinary ADL customization point, but they messed that up royally and now it's too late to fix it.)

So, since we have to specialize `pointer_traits<__wrap_iter>` anyway, we probably don't need any of the `element_type` stuff anymore. I'll look into this again soonish.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101404/new/

https://reviews.llvm.org/D101404



More information about the libcxx-commits mailing list