Skip to content

Commit 3dc1f75

Browse files
authored
[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

libcxx/include/__cxx03/__algorithm/is_permutation.h

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3333
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class = void>
3434
struct _ConstTimeDistance : false_type {};
3535

36-
#if _LIBCPP_STD_VER >= 20
37-
38-
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2>
39-
struct _ConstTimeDistance<_Iter1,
40-
_Sent1,
41-
_Iter2,
42-
_Sent2,
43-
__enable_if_t< sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2> >>
44-
: true_type {};
45-
46-
#else
47-
4836
template <class _Iter1, class _Iter2>
4937
struct _ConstTimeDistance<
5038
_Iter1,
@@ -55,8 +43,6 @@ struct _ConstTimeDistance<
5543
is_same<typename iterator_traits<_Iter2>::iterator_category, random_access_iterator_tag>::value > >
5644
: true_type {};
5745

58-
#endif // _LIBCPP_STD_VER >= 20
59-
6046
// Internal functions
6147

6248
// For each element in [f1, l1) see if there are the same number of equal elements in [f2, l2)
@@ -261,45 +247,6 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
261247
return std::is_permutation(__first1, __last1, __first2, __equal_to());
262248
}
263249

264-
#if _LIBCPP_STD_VER >= 14
265-
266-
// 2+2 iterators
267-
template <class _ForwardIterator1, class _ForwardIterator2>
268-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
269-
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
270-
return std::__is_permutation<_ClassicAlgPolicy>(
271-
std::move(__first1),
272-
std::move(__last1),
273-
std::move(__first2),
274-
std::move(__last2),
275-
__equal_to(),
276-
__identity(),
277-
__identity());
278-
}
279-
280-
// 2+2 iterators, predicate
281-
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
282-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
283-
_ForwardIterator1 __first1,
284-
_ForwardIterator1 __last1,
285-
_ForwardIterator2 __first2,
286-
_ForwardIterator2 __last2,
287-
_BinaryPredicate __pred) {
288-
static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
289-
"The predicate has to be callable");
290-
291-
return std::__is_permutation<_ClassicAlgPolicy>(
292-
std::move(__first1),
293-
std::move(__last1),
294-
std::move(__first2),
295-
std::move(__last2),
296-
__pred,
297-
__identity(),
298-
__identity());
299-
}
300-
301-
#endif // _LIBCPP_STD_VER >= 14
302-
303250
_LIBCPP_END_NAMESPACE_STD
304251

305252
_LIBCPP_POP_MACROS

libcxx/include/__cxx03/__algorithm/iterator_operations.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3737
template <class _AlgPolicy>
3838
struct _IterOps;
3939

40-
#if _LIBCPP_STD_VER >= 20
41-
struct _RangeAlgPolicy {};
42-
43-
template <>
44-
struct _IterOps<_RangeAlgPolicy> {
45-
template <class _Iter>
46-
using __value_type = iter_value_t<_Iter>;
47-
48-
template <class _Iter>
49-
using __iterator_category = ranges::__iterator_concept<_Iter>;
50-
51-
template <class _Iter>
52-
using __difference_type = iter_difference_t<_Iter>;
53-
54-
static constexpr auto advance = ranges::advance;
55-
static constexpr auto distance = ranges::distance;
56-
static constexpr auto __iter_move = ranges::iter_move;
57-
static constexpr auto iter_swap = ranges::iter_swap;
58-
static constexpr auto next = ranges::next;
59-
static constexpr auto prev = ranges::prev;
60-
static constexpr auto __advance_to = ranges::advance;
61-
};
62-
63-
#endif
64-
6540
struct _ClassicAlgPolicy {};
6641

6742
template <>

libcxx/include/__cxx03/__algorithm/make_projected.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,4 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Pred& __make_projected(_Pred& __pred, _
7373

7474
_LIBCPP_END_NAMESPACE_STD
7575

76-
#if _LIBCPP_STD_VER >= 20
77-
78-
_LIBCPP_BEGIN_NAMESPACE_STD
79-
80-
namespace ranges {
81-
82-
template <class _Comp, class _Proj1, class _Proj2>
83-
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
84-
if constexpr (__is_identity<decay_t<_Proj1>>::value && __is_identity<decay_t<_Proj2>>::value &&
85-
!is_member_pointer_v<decay_t<_Comp>>) {
86-
// Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
87-
// optimizations that rely on the type of the comparator.
88-
return __comp;
89-
90-
} else {
91-
return [&](auto&& __lhs, auto&& __rhs) -> bool {
92-
return std::invoke(__comp,
93-
std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)),
94-
std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs)));
95-
};
96-
}
97-
}
98-
99-
} // namespace ranges
100-
101-
_LIBCPP_END_NAMESPACE_STD
102-
103-
#endif // _LIBCPP_STD_VER >= 20
104-
10576
#endif // _LIBCPP___CXX03___ALGORITHM_MAKE_PROJECTED_H

libcxx/include/__cxx03/__algorithm/max.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
3535
return std::max(__a, __b, __less<>());
3636
}
3737

38-
#ifndef _LIBCPP_CXX03_LANG
39-
40-
template <class _Tp, class _Compare>
41-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
42-
max(initializer_list<_Tp> __t, _Compare __comp) {
43-
return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
44-
}
45-
46-
template <class _Tp>
47-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
48-
return *std::max_element(__t.begin(), __t.end(), __less<>());
49-
}
50-
51-
#endif // _LIBCPP_CXX03_LANG
52-
5338
_LIBCPP_END_NAMESPACE_STD
5439

5540
_LIBCPP_POP_MACROS

libcxx/include/__cxx03/__algorithm/min.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
3535
return std::min(__a, __b, __less<>());
3636
}
3737

38-
#ifndef _LIBCPP_CXX03_LANG
39-
40-
template <class _Tp, class _Compare>
41-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
42-
min(initializer_list<_Tp> __t, _Compare __comp) {
43-
return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
44-
}
45-
46-
template <class _Tp>
47-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {
48-
return *std::min_element(__t.begin(), __t.end(), __less<>());
49-
}
50-
51-
#endif // _LIBCPP_CXX03_LANG
52-
5338
_LIBCPP_END_NAMESPACE_STD
5439

5540
_LIBCPP_POP_MACROS

libcxx/include/__cxx03/__algorithm/minmax.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,6 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
3434
return std::minmax(__a, __b, __less<>());
3535
}
3636

37-
#ifndef _LIBCPP_CXX03_LANG
38-
39-
template <class _Tp, class _Compare>
40-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
41-
minmax(initializer_list<_Tp> __t, _Compare __comp) {
42-
static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
43-
__identity __proj;
44-
auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
45-
return pair<_Tp, _Tp>(*__ret.first, *__ret.second);
46-
}
47-
48-
template <class _Tp>
49-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
50-
minmax(initializer_list<_Tp> __t) {
51-
return std::minmax(__t, __less<>());
52-
}
53-
54-
#endif // _LIBCPP_CXX03_LANG
55-
5637
_LIBCPP_END_NAMESPACE_STD
5738

5839
#endif // _LIBCPP___CXX03___ALGORITHM_MINMAX_H

libcxx/include/__cxx03/__algorithm/mismatch.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -164,52 +164,6 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
164164
return std::mismatch(__first1, __last1, __first2, __equal_to());
165165
}
166166

167-
#if _LIBCPP_STD_VER >= 14
168-
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
169-
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(
170-
_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
171-
while (__first1 != __last1 && __first2 != __last2) {
172-
if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
173-
break;
174-
++__first1;
175-
++__first2;
176-
}
177-
return {std::move(__first1), std::move(__first2)};
178-
}
179-
180-
template <class _Tp, class _Pred, class _Proj1, class _Proj2>
181-
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
182-
__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
183-
auto __len = std::min(__last1 - __first1, __last2 - __first2);
184-
return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2);
185-
}
186-
187-
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
188-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
189-
mismatch(_InputIterator1 __first1,
190-
_InputIterator1 __last1,
191-
_InputIterator2 __first2,
192-
_InputIterator2 __last2,
193-
_BinaryPredicate __pred) {
194-
__identity __proj;
195-
auto __res = std::__mismatch(
196-
std::__unwrap_iter(__first1),
197-
std::__unwrap_iter(__last1),
198-
std::__unwrap_iter(__first2),
199-
std::__unwrap_iter(__last2),
200-
__pred,
201-
__proj,
202-
__proj);
203-
return {std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second)};
204-
}
205-
206-
template <class _InputIterator1, class _InputIterator2>
207-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
208-
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
209-
return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
210-
}
211-
#endif
212-
213167
_LIBCPP_END_NAMESPACE_STD
214168

215169
_LIBCPP_POP_MACROS

libcxx/include/__cxx03/__algorithm/search.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2
177177
return std::search(__first1, __last1, __first2, __last2, __equal_to());
178178
}
179179

180-
#if _LIBCPP_STD_VER >= 17
181-
template <class _ForwardIterator, class _Searcher>
182-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
183-
search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
184-
return __s(__f, __l).first;
185-
}
186-
187-
#endif
188-
189180
_LIBCPP_END_NAMESPACE_STD
190181

191182
#endif // _LIBCPP___CXX03___ALGORITHM_SEARCH_H

libcxx/include/__cxx03/__algorithm/shuffle.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_randomizer {
6262
}
6363
};
6464

65-
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) || defined(_LIBCPP_BUILDING_LIBRARY)
6665
class _LIBCPP_EXPORTED_FROM_ABI __rs_default;
6766

6867
_LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
@@ -111,14 +110,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) {
111110

112111
template <class _RandomAccessIterator, class _RandomNumberGenerator>
113112
_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
114-
random_shuffle(_RandomAccessIterator __first,
115-
_RandomAccessIterator __last,
116-
# ifndef _LIBCPP_CXX03_LANG
117-
_RandomNumberGenerator&& __rand)
118-
# else
119-
_RandomNumberGenerator& __rand)
120-
# endif
121-
{
113+
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _RandomNumberGenerator&& __rand) {
122114
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
123115
difference_type __d = __last - __first;
124116
if (__d > 1) {
@@ -129,7 +121,6 @@ random_shuffle(_RandomAccessIterator __first,
129121
}
130122
}
131123
}
132-
#endif
133124

134125
template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
135126
_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator

0 commit comments

Comments
 (0)