[libcxx-commits] [libcxx] 4265ca3 - [libc++][NFC] Remove `pointer_traits<__wrap_iter>` partial specialization (#178864)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 20 05:50:36 PDT 2026


Author: A. Jiang
Date: 2026-04-20T20:50:31+08:00
New Revision: 4265ca3ecbcbe7e1df6a5bc95787956c92d2cde5

URL: https://github.com/llvm/llvm-project/commit/4265ca3ecbcbe7e1df6a5bc95787956c92d2cde5
DIFF: https://github.com/llvm/llvm-project/commit/4265ca3ecbcbe7e1df6a5bc95787956c92d2cde5.diff

LOG: [libc++][NFC] Remove `pointer_traits<__wrap_iter>` partial specialization (#178864)

Since commit b5270ba20dc3d84df9d880be11d57667f04c6c28, it was decided
that `__wrap_iter` wasn't intended to perform runtime check, so it's
`operator->` won't check whether the iterator is deferenceable. (See
https://llvm.org/PR178521.)

Currently, `pointer_traits<__wrap_iter>` partial specialization is
provided and makes `__to_address`/`to_address` call the member
`to_address` instead of `operator->`. But given these operations are
equivalent and `__wrap_iter::operator->` is improbable to have
behavioral change in the future, perhaps it would be better to remove
the partial specialization.

The changes have no negative impact on compile time, and sometimes have
a negligible positive impact.

Drive-by: Also remove inclusion of `<__memory/addressof.h>` from
`<__iterator/wrap_iter.h>` as we don't need to call `addressof` or its
equivalent internal version.

Added: 
    

Modified: 
    libcxx/include/__iterator/wrap_iter.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index 576adfbce3841..0633794e15080 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -15,7 +15,6 @@
 #include <__config>
 #include <__cstddef/size_t.h>
 #include <__iterator/iterator_traits.h>
-#include <__memory/addressof.h>
 #include <__memory/pointer_traits.h>
 #include <__type_traits/conjunction.h>
 #include <__type_traits/disjunction.h>
@@ -46,8 +45,6 @@ class __wrap_iter {
 private:
   _Iter __i_;
 
-  friend struct pointer_traits<__wrap_iter<_Iter> >;
-
 public:
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {}
   template <class _OtherIter,
@@ -227,17 +224,6 @@ template <class _It>
 struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {};
 #endif
 
-template <class _It>
-struct pointer_traits<__wrap_iter<_It> > {
-  typedef __wrap_iter<_It> pointer;
-  typedef typename pointer_traits<_It>::element_type element_type;
-  typedef typename pointer_traits<_It>::
diff erence_type 
diff erence_type;
-
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __w) _NOEXCEPT {
-    return std::__to_address(__w.__i_);
-  }
-};
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___ITERATOR_WRAP_ITER_H


        


More information about the libcxx-commits mailing list