diff --git a/libcxx/docs/ReleaseNotes/23.rst b/libcxx/docs/ReleaseNotes/23.rst index 9519f5b6c293..7563ca60e75a 100644 --- a/libcxx/docs/ReleaseNotes/23.rst +++ b/libcxx/docs/ReleaseNotes/23.rst @@ -55,6 +55,9 @@ Deprecations and Removals - The ``std::launch::any`` enumerator that was accidentally provided as an extension is now deprecated. It will be removed in LLVM 25. +- ``__wrap_iter``'s (iterator type for ``array``, ``span``, ``string``, ``string_view`` and ``vector``) ``base()`` + method has been removed as it was non-standard. + Potentially breaking changes ---------------------------- diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h index 234c9a4f8c70..d20d7f3fc4c4 100644 --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -47,6 +47,8 @@ public: private: iterator_type __i_; + friend struct pointer_traits<__wrap_iter<_Iter> >; + public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {} template _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool operator==(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { - return __x.base() == __y.base(); + return __x.__i_ == __y.__i_; } _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator<(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT { - return __x.base() < __y.base(); + return __x.__i_ < __y.__i_; } template _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator<(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { - return __x.base() < __y.base(); + return __x.__i_ < __y.__i_; } #if _LIBCPP_STD_VER <= 17 @@ -192,12 +192,12 @@ private: _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) noexcept { if constexpr (three_way_comparable_with<_Iter, _Iter2, strong_ordering>) { - return __x.base() <=> __y.base(); + return __x.__i_ <=> __y.__i_; } else { - if (__x.base() < __y.base()) + if (__x.__i_ < __y.__i_) return strong_ordering::less; - if (__x.base() == __y.base()) + if (__x.__i_ == __y.__i_) return strong_ordering::equal; return strong_ordering::greater; @@ -208,14 +208,14 @@ private: #ifndef _LIBCPP_CXX03_LANG template _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 auto - operator-(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base()) + operator-(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.__i_ - __y.__i_) #else template _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __wrap_iter::difference_type operator-(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT #endif // C++03 { - return __x.base() - __y.base(); + return __x.__i_ - __y.__i_; } _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter @@ -237,7 +237,7 @@ struct pointer_traits<__wrap_iter<_It> > { 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()); + return std::__to_address(__w.__i_); } }; diff --git a/libcxx/include/regex b/libcxx/include/regex index 620a75f35d10..ae6ffcbb5548 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -817,6 +817,7 @@ typedef regex_token_iterator wsregex_token_iterator; # include <__iterator/wrap_iter.h> # include <__locale> # include <__memory/addressof.h> +# include <__memory/pointer_traits.h> # include <__memory/shared_ptr.h> # include <__memory_resource/polymorphic_allocator.h> # include <__type_traits/is_swappable.h> @@ -5167,7 +5168,7 @@ regex_search(__wrap_iter<_Iter> __first, const basic_regex<_CharT, _Traits>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) { match_results __mc; - bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags); + bool __r = __e.__search(std::__to_address(__first), std::__to_address(__last), __mc, __flags); __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); return __r; }