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

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


https://github.com/23silicon created https://github.com/llvm/llvm-project/pull/186871

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.

>From ded4155f0854c5d725d4bb8a51fef8ea9ca6f2c4 Mon Sep 17 00:00:00 2001
From: 23silicon <nak00001 at outlook.com>
Date: Mon, 16 Mar 2026 15:21:22 -0400
Subject: [PATCH 1/2] removed iterator_type member type from __wrap_iter in
 libcxx

---
 libcxx/docs/ReleaseNotes/23.rst               |  2 ++
 libcxx/include/__cxx03/__iterator/wrap_iter.h | 19 +++++++++----------
 libcxx/include/__iterator/wrap_iter.h         | 15 +++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/libcxx/docs/ReleaseNotes/23.rst b/libcxx/docs/ReleaseNotes/23.rst
index 4441a8aed198c..f0ab848a315fe 100644
--- a/libcxx/docs/ReleaseNotes/23.rst
+++ b/libcxx/docs/ReleaseNotes/23.rst
@@ -58,6 +58,8 @@ 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.
 
+- ``__wrap_iter`` no longer exposes the non-standard ``iterator_type`` member type.
+
 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;

>From 8d1228363c5aa64c331c61049ff4a305366aa72b Mon Sep 17 00:00:00 2001
From: 23silicon <nak00001 at outlook.com>
Date: Mon, 16 Mar 2026 15:48:07 -0400
Subject: [PATCH 2/2] removed iterator_type member type from __wrap_iter in
 libcxx, 23.rst update

---
 libcxx/docs/ReleaseNotes/23.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/docs/ReleaseNotes/23.rst b/libcxx/docs/ReleaseNotes/23.rst
index f0ab848a315fe..a12d2742b8f9f 100644
--- a/libcxx/docs/ReleaseNotes/23.rst
+++ b/libcxx/docs/ReleaseNotes/23.rst
@@ -58,7 +58,9 @@ 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.
 
-- ``__wrap_iter`` no longer exposes the non-standard ``iterator_type`` member type.
+- 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
 ----------------------------



More information about the libcxx-commits mailing list