[libcxx-commits] [libcxx] [libc++][NFC] Remove `pointer_traits<__wrap_iter>` partial specialization (PR #178864)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 30 02:55:47 PST 2026
https://github.com/frederick-vs-ja created https://github.com/llvm/llvm-project/pull/178864
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.
>From 724c878bf7c0b92e55686272e3ef2e8ddc8b9ba0 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Fri, 30 Jan 2026 18:51:32 +0800
Subject: [PATCH] [libc++][NFC] Remove `pointer_traits<__wrap_iter>` partial
specialization
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.
---
libcxx/include/__iterator/wrap_iter.h | 12 ------------
1 file changed, 12 deletions(-)
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
More information about the libcxx-commits
mailing list