Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3dc1f75

Browse files
authoredMay 6, 2025
[libc++][C++03] Remove code that is not used in C++03 (#134045)
This patch removes code which is guarded by `_LIBCPP_STD_VER` and `_LIBCPP_CXX03_LANG`. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
1 parent fe1d115 commit 3dc1f75

File tree

308 files changed

+165
-15503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+165
-15503
lines changed
 

‎libcxx/include/__cxx03/__algorithm/equal.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -66,65 +66,6 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
6666
return std::equal(__first1, __last1, __first2, __equal_to());
6767
}
6868

69-
#if _LIBCPP_STD_VER >= 14
70-
71-
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
72-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
73-
_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) {
74-
while (__first1 != __last1 && __first2 != __last2) {
75-
if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
76-
return false;
77-
++__first1;
78-
++__first2;
79-
}
80-
return __first1 == __last1 && __first2 == __last2;
81-
}
82-
83-
template <class _Tp,
84-
class _Up,
85-
class _Pred,
86-
class _Proj1,
87-
class _Proj2,
88-
__enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value &&
89-
__is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
90-
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
91-
int> = 0>
92-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
93-
__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
94-
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
95-
}
96-
97-
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
98-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
99-
equal(_InputIterator1 __first1,
100-
_InputIterator1 __last1,
101-
_InputIterator2 __first2,
102-
_InputIterator2 __last2,
103-
_BinaryPredicate __pred) {
104-
if constexpr (__has_random_access_iterator_category<_InputIterator1>::value &&
105-
__has_random_access_iterator_category<_InputIterator2>::value) {
106-
if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
107-
return false;
108-
}
109-
__identity __proj;
110-
return std::__equal_impl(
111-
std::__unwrap_iter(__first1),
112-
std::__unwrap_iter(__last1),
113-
std::__unwrap_iter(__first2),
114-
std::__unwrap_iter(__last2),
115-
__pred,
116-
__proj,
117-
__proj);
118-
}
119-
120-
template <class _InputIterator1, class _InputIterator2>
121-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
122-
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
123-
return std::equal(__first1, __last1, __first2, __last2, __equal_to());
124-
}
125-
126-
#endif // _LIBCPP_STD_VER >= 14
127-
12869
_LIBCPP_END_NAMESPACE_STD
12970

13071
_LIBCPP_POP_MACROS

‎libcxx/include/__cxx03/__algorithm/for_each.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) {
3333
return __f;
3434
}
3535

36-
// __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++23
37-
#if _LIBCPP_STD_VER >= 23
38-
template <class _SegmentedIterator, class _Function>
39-
requires __is_segmented_iterator<_SegmentedIterator>::value
40-
_LIBCPP_HIDE_FROM_ABI constexpr _Function
41-
for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
42-
ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));
43-
std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
44-
__wrapped_func =
45-
ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));
46-
});
47-
return std::move(*__wrapped_func);
48-
}
49-
#endif // _LIBCPP_STD_VER >= 23
50-
5136
_LIBCPP_END_NAMESPACE_STD
5237

5338
_LIBCPP_POP_MACROS

0 commit comments

Comments
 (0)
Please sign in to comment.