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

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 30 02:56:20 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

<details>
<summary>Changes</summary>



It was said 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.

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/178864.diff


1 Files Affected:

- (modified) libcxx/include/__iterator/wrap_iter.h (-12) 


``````````diff
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index 128aeab3ac7cd..1c58d33f5746e 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>
@@ -236,17 +235,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>::difference_type difference_type;
-
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __w) _NOEXCEPT {
-    return std::__to_address(__w.base());
-  }
-};
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___ITERATOR_WRAP_ITER_H

``````````

</details>


https://github.com/llvm/llvm-project/pull/178864


More information about the libcxx-commits mailing list