[libcxx-commits] [libcxx] [libc++] Remove `wrap_iter::base()` (PR #179389)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 3 00:43:18 PST 2026


================
@@ -100,9 +102,39 @@ class __wrap_iter {
     return __i_[__n];
   }
 
-  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator_type base() const _NOEXCEPT { return __i_; }
-
 private:
+  template <class _Iter1>
+  _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
+  operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT;
+
+  template <class _Iter1, class _Iter2>
+  _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
+  operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT;
+
+  template <class _Iter1>
+  _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+  operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT;
+
+  template <class _Iter1, class _Iter2>
+  _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+  operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT;
+
+#if _LIBCPP_STD_VER >= 20
+  template <class _Iter1, class _Iter2>
+  _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering
+  operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept;
+#endif
+
+  template <class _Iter1, class _Iter2>
+  _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14
+#ifndef _LIBCPP_CXX03_LANG
+  auto
+  operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.__i_ - __y.__i_);
+#else
+  typename __wrap_iter<_Iter1>::difference_type
+  operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT;
+#endif // C++03
----------------
H-G-Hristov wrote:

IMO such splitting of declaration is crap. Just copy the "prefix" twice inside the `#ifdef`. 

BTW. I have a patch implementing `[[nodiscard]]` for these operators: https://github.com/llvm/llvm-project/pull/172200
Maybe it makes sense to add `[[nodiscard]]` here so we don't forget it later?

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


More information about the libcxx-commits mailing list