[libcxx-commits] [libcxx] Users/23silicon/libcxx 186801 remove wrap iter iterator type (PR #186871)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 16 12:52:17 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Nikhil Kotikalapudi (23silicon)

<details>
<summary>Changes</summary>

Resolves #<!-- -->186801 
Removed the non-standard member type ``iterator_type`` from ``__wrap_iter``.
This member exposed the underlying iterator type, and its removal prevents users from relying on the implementation detail.

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


3 Files Affected:

- (modified) libcxx/docs/ReleaseNotes/23.rst (+4) 
- (modified) libcxx/include/__cxx03/__iterator/wrap_iter.h (+9-10) 
- (modified) libcxx/include/__iterator/wrap_iter.h (+7-8) 


``````````diff
diff --git a/libcxx/docs/ReleaseNotes/23.rst b/libcxx/docs/ReleaseNotes/23.rst
index 4441a8aed198c..a12d2742b8f9f 100644
--- a/libcxx/docs/ReleaseNotes/23.rst
+++ b/libcxx/docs/ReleaseNotes/23.rst
@@ -58,6 +58,10 @@ Deprecations and Removals
 - ``__wrap_iter``'s (iterator type for ``array``, ``span``, ``string``, ``string_view`` and ``vector``) ``base()``
   method has been removed as it was non-standard.
 
+- Removed the non-standard member type ``iterator_type`` from ``__wrap_iter``.
+  This member exposed the underlying iterator type and its removal prevents
+  users from relying on the implementation detail.
+
 Potentially breaking changes
 ----------------------------
 
diff --git a/libcxx/include/__cxx03/__iterator/wrap_iter.h b/libcxx/include/__cxx03/__iterator/wrap_iter.h
index 22c9e2dfb5f5a..1e250b24c72c0 100644
--- a/libcxx/include/__cxx03/__iterator/wrap_iter.h
+++ b/libcxx/include/__cxx03/__iterator/wrap_iter.h
@@ -27,19 +27,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Iter>
 class __wrap_iter {
 public:
-  typedef _Iter iterator_type;
-  typedef typename iterator_traits<iterator_type>::value_type value_type;
-  typedef typename iterator_traits<iterator_type>::difference_type difference_type;
-  typedef typename iterator_traits<iterator_type>::pointer pointer;
-  typedef typename iterator_traits<iterator_type>::reference reference;
-  typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
+  typedef typename iterator_traits<_Iter>::value_type value_type;
+  typedef typename iterator_traits<_Iter>::difference_type difference_type;
+  typedef typename iterator_traits<_Iter>::pointer pointer;
+  typedef typename iterator_traits<_Iter>::reference reference;
+  typedef typename iterator_traits<_Iter>::iterator_category iterator_category;
 
 private:
-  iterator_type __i_;
+  _Iter __i_;
 
 public:
   _LIBCPP_HIDE_FROM_ABI __wrap_iter() _NOEXCEPT : __i_() {}
-  template <class _Up, __enable_if_t<is_convertible<_Up, iterator_type>::value, int> = 0>
+  template <class _Up, __enable_if_t<is_convertible<_Up, _Iter>::value, int> = 0>
   _LIBCPP_HIDE_FROM_ABI __wrap_iter(const __wrap_iter<_Up>& __u) _NOEXCEPT : __i_(__u.base()) {}
   _LIBCPP_HIDE_FROM_ABI reference operator*() const _NOEXCEPT { return *__i_; }
   _LIBCPP_HIDE_FROM_ABI pointer operator->() const _NOEXCEPT { return std::__to_address(__i_); }
@@ -78,10 +77,10 @@ class __wrap_iter {
   }
   _LIBCPP_HIDE_FROM_ABI reference operator[](difference_type __n) const _NOEXCEPT { return __i_[__n]; }
 
-  _LIBCPP_HIDE_FROM_ABI iterator_type base() const _NOEXCEPT { return __i_; }
+  _LIBCPP_HIDE_FROM_ABI _Iter base() const _NOEXCEPT { return __i_; }
 
 private:
-  _LIBCPP_HIDE_FROM_ABI explicit __wrap_iter(iterator_type __x) _NOEXCEPT : __i_(__x) {}
+  _LIBCPP_HIDE_FROM_ABI explicit __wrap_iter(_Iter __x) _NOEXCEPT : __i_(__x) {}
 
   template <class _Up>
   friend class __wrap_iter;
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index c1b27b8242cd9..576adfbce3841 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -34,18 +34,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Iter>
 class __wrap_iter {
 public:
-  typedef _Iter iterator_type;
-  typedef typename iterator_traits<iterator_type>::value_type value_type;
-  typedef typename iterator_traits<iterator_type>::difference_type difference_type;
-  typedef typename iterator_traits<iterator_type>::pointer pointer;
-  typedef typename iterator_traits<iterator_type>::reference reference;
-  typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
+  typedef typename iterator_traits<_Iter>::value_type value_type;
+  typedef typename iterator_traits<_Iter>::difference_type difference_type;
+  typedef typename iterator_traits<_Iter>::pointer pointer;
+  typedef typename iterator_traits<_Iter>::reference reference;
+  typedef typename iterator_traits<_Iter>::iterator_category iterator_category;
 #if _LIBCPP_STD_VER >= 20
   typedef contiguous_iterator_tag iterator_concept;
 #endif
 
 private:
-  iterator_type __i_;
+  _Iter __i_;
 
   friend struct pointer_traits<__wrap_iter<_Iter> >;
 
@@ -103,7 +102,7 @@ class __wrap_iter {
   }
 
 private:
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __wrap_iter(iterator_type __x) _NOEXCEPT : __i_(__x) {}
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __wrap_iter(_Iter __x) _NOEXCEPT : __i_(__x) {}
 
   template <class _Up>
   friend class __wrap_iter;

``````````

</details>


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


More information about the libcxx-commits mailing list