Skip to content

Commit 73ebcab

Browse files
committed
[libc++][ranges][NFC] Implement the repetitive parts of the remaining range algorithms:
- create the headers (but not include them from `<algorithm>`); - define the niebloid and its member functions with the right signatures (as no-ops); - make sure all the right headers are included that are required by each algorithm's signature; - update `CMakeLists.txt` and the module map; - create the test files with the appropriate synopses. The synopsis in `<algorithm>` is deliberately not updated because that could be taken as a readiness signal. The new headers aren't included from `<algorithm>` for the same reason. Differential Revision: https://reviews.llvm.org/D129549
1 parent 00797b8 commit 73ebcab

Some content is hidden

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

44 files changed

+2606
-2
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ set(files
7979
__algorithm/ranges_count.h
8080
__algorithm/ranges_count_if.h
8181
__algorithm/ranges_equal.h
82+
__algorithm/ranges_equal_range.h
8283
__algorithm/ranges_fill.h
8384
__algorithm/ranges_fill_n.h
8485
__algorithm/ranges_find.h
@@ -87,6 +88,12 @@ set(files
8788
__algorithm/ranges_find_if_not.h
8889
__algorithm/ranges_for_each.h
8990
__algorithm/ranges_for_each_n.h
91+
__algorithm/ranges_generate.h
92+
__algorithm/ranges_generate_n.h
93+
__algorithm/ranges_includes.h
94+
__algorithm/ranges_inplace_merge.h
95+
__algorithm/ranges_is_heap.h
96+
__algorithm/ranges_is_heap_until.h
9097
__algorithm/ranges_is_partitioned.h
9198
__algorithm/ranges_is_sorted.h
9299
__algorithm/ranges_is_sorted_until.h
@@ -105,22 +112,35 @@ set(files
105112
__algorithm/ranges_move_backward.h
106113
__algorithm/ranges_none_of.h
107114
__algorithm/ranges_nth_element.h
115+
__algorithm/ranges_partial_sort_copy.h
116+
__algorithm/ranges_partition.h
117+
__algorithm/ranges_partition_copy.h
118+
__algorithm/ranges_partition_point.h
108119
__algorithm/ranges_pop_heap.h
109120
__algorithm/ranges_push_heap.h
110121
__algorithm/ranges_remove.h
122+
__algorithm/ranges_remove_copy.h
123+
__algorithm/ranges_remove_copy_if.h
111124
__algorithm/ranges_remove_if.h
112125
__algorithm/ranges_replace.h
126+
__algorithm/ranges_replace_copy.h
127+
__algorithm/ranges_replace_copy_if.h
113128
__algorithm/ranges_replace_if.h
114129
__algorithm/ranges_reverse.h
115130
__algorithm/ranges_reverse_copy.h
116131
__algorithm/ranges_rotate_copy.h
117132
__algorithm/ranges_set_difference.h
118133
__algorithm/ranges_set_intersection.h
134+
__algorithm/ranges_set_union.h
135+
__algorithm/ranges_shuffle.h
119136
__algorithm/ranges_sort.h
120137
__algorithm/ranges_sort_heap.h
138+
__algorithm/ranges_stable_partition.h
121139
__algorithm/ranges_stable_sort.h
122140
__algorithm/ranges_swap_ranges.h
123141
__algorithm/ranges_transform.h
142+
__algorithm/ranges_unique.h
143+
__algorithm/ranges_unique_copy.h
124144
__algorithm/ranges_upper_bound.h
125145
__algorithm/remove.h
126146
__algorithm/remove_copy.h
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM __project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
10+
#define _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
11+
12+
#include <__algorithm/equal_range.h>
13+
#include <__algorithm/make_projected.h>
14+
#include <__config>
15+
#include <__functional/identity.h>
16+
#include <__functional/invoke.h>
17+
#include <__functional/ranges_operations.h>
18+
#include <__iterator/concepts.h>
19+
#include <__iterator/iterator_traits.h>
20+
#include <__iterator/projected.h>
21+
#include <__ranges/access.h>
22+
#include <__ranges/concepts.h>
23+
#include <__ranges/dangling.h>
24+
#include <__ranges/subrange.h>
25+
#include <__utility/forward.h>
26+
#include <__utility/move.h>
27+
28+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29+
# pragma GCC system_header
30+
#endif
31+
32+
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33+
34+
_LIBCPP_BEGIN_NAMESPACE_STD
35+
36+
namespace ranges {
37+
namespace __equal_range {
38+
39+
struct __fn {
40+
41+
template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Tp, class _Proj = identity,
42+
indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
43+
_LIBCPP_HIDE_FROM_ABI constexpr
44+
subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {},
45+
_Proj __proj = {}) const {
46+
// TODO: implement
47+
(void)__first; (void)__last; (void)__value; (void)__comp; (void)__proj;
48+
return {};
49+
}
50+
51+
template <forward_range _Range, class _Tp, class _Proj = identity,
52+
indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
53+
_LIBCPP_HIDE_FROM_ABI constexpr
54+
borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {},
55+
_Proj __proj = {}) const {
56+
// TODO: implement
57+
(void)__range; (void)__value; (void)__comp; (void)__proj;
58+
return {};
59+
}
60+
61+
};
62+
63+
} // namespace __equal_range
64+
65+
inline namespace __cpo {
66+
inline constexpr auto equal_range = __equal_range::__fn{};
67+
} // namespace __cpo
68+
} // namespace ranges
69+
70+
_LIBCPP_END_NAMESPACE_STD
71+
72+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73+
74+
#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H
10+
#define _LIBCPP___ALGORITHM_RANGES_GENERATE_H
11+
12+
#include <__algorithm/generate.h>
13+
#include <__algorithm/make_projected.h>
14+
#include <__concepts/constructible.h>
15+
#include <__concepts/invocable.h>
16+
#include <__config>
17+
#include <__functional/identity.h>
18+
#include <__functional/invoke.h>
19+
#include <__functional/ranges_operations.h>
20+
#include <__iterator/concepts.h>
21+
#include <__iterator/iterator_traits.h>
22+
#include <__iterator/projected.h>
23+
#include <__ranges/access.h>
24+
#include <__ranges/concepts.h>
25+
#include <__ranges/dangling.h>
26+
#include <__utility/forward.h>
27+
#include <__utility/move.h>
28+
29+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30+
# pragma GCC system_header
31+
#endif
32+
33+
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34+
35+
_LIBCPP_BEGIN_NAMESPACE_STD
36+
37+
namespace ranges {
38+
namespace __generate {
39+
40+
struct __fn {
41+
42+
template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func>
43+
requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
44+
_LIBCPP_HIDE_FROM_ABI constexpr
45+
_OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const {
46+
// TODO: implement
47+
(void)__first; (void)__last; (void)__gen;
48+
return {};
49+
}
50+
51+
template <class _Range, copy_constructible _Func>
52+
requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>>
53+
_LIBCPP_HIDE_FROM_ABI constexpr
54+
borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const {
55+
// TODO: implement
56+
(void)__range; (void)__gen;
57+
return {};
58+
}
59+
60+
};
61+
62+
} // namespace __generate
63+
64+
inline namespace __cpo {
65+
inline constexpr auto generate = __generate::__fn{};
66+
} // namespace __cpo
67+
} // namespace ranges
68+
69+
_LIBCPP_END_NAMESPACE_STD
70+
71+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72+
73+
#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
10+
#define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
11+
12+
#include <__algorithm/generate_n.h>
13+
#include <__algorithm/make_projected.h>
14+
#include <__concepts/constructible.h>
15+
#include <__concepts/invocable.h>
16+
#include <__config>
17+
#include <__functional/identity.h>
18+
#include <__functional/invoke.h>
19+
#include <__functional/ranges_operations.h>
20+
#include <__iterator/concepts.h>
21+
#include <__iterator/incrementable_traits.h>
22+
#include <__iterator/iterator_traits.h>
23+
#include <__iterator/projected.h>
24+
#include <__ranges/access.h>
25+
#include <__ranges/concepts.h>
26+
#include <__ranges/dangling.h>
27+
#include <__utility/forward.h>
28+
#include <__utility/move.h>
29+
30+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31+
# pragma GCC system_header
32+
#endif
33+
34+
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35+
36+
_LIBCPP_BEGIN_NAMESPACE_STD
37+
38+
namespace ranges {
39+
namespace __generate_n {
40+
41+
struct __fn {
42+
43+
template <input_or_output_iterator _OutIter, copy_constructible _Func>
44+
requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
45+
_LIBCPP_HIDE_FROM_ABI constexpr
46+
_OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const {
47+
// TODO: implement
48+
(void)__first; (void)__n; (void)__gen;
49+
return {};
50+
}
51+
52+
};
53+
54+
} // namespace __generate_n
55+
56+
inline namespace __cpo {
57+
inline constexpr auto generate_n = __generate_n::__fn{};
58+
} // namespace __cpo
59+
} // namespace ranges
60+
61+
_LIBCPP_END_NAMESPACE_STD
62+
63+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
64+
65+
#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
10+
#define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
11+
12+
#include <__algorithm/make_projected.h>
13+
#include <__algorithm/includes.h>
14+
#include <__config>
15+
#include <__functional/identity.h>
16+
#include <__functional/invoke.h>
17+
#include <__functional/ranges_operations.h>
18+
#include <__iterator/concepts.h>
19+
#include <__iterator/iterator_traits.h>
20+
#include <__iterator/projected.h>
21+
#include <__ranges/access.h>
22+
#include <__ranges/concepts.h>
23+
#include <__ranges/dangling.h>
24+
#include <__utility/forward.h>
25+
#include <__utility/move.h>
26+
27+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28+
# pragma GCC system_header
29+
#endif
30+
31+
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32+
33+
_LIBCPP_BEGIN_NAMESPACE_STD
34+
35+
namespace ranges {
36+
namespace __includes {
37+
38+
struct __fn {
39+
40+
template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, input_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
41+
class _Proj1 = identity, class _Proj2 = identity,
42+
indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
43+
_LIBCPP_HIDE_FROM_ABI constexpr
44+
bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp __comp = {},
45+
_Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
46+
// TODO: implement
47+
(void)__first1; (void)__last1; (void)__first2; (void)__last2; (void)__comp; (void)__proj1; (void)__proj2;
48+
return {};
49+
}
50+
51+
template <input_range _Range1, input_range _Range2, class _Proj1 = identity, class _Proj2 = identity,
52+
indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
53+
projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
54+
_LIBCPP_HIDE_FROM_ABI constexpr
55+
bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {},
56+
_Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
57+
// TODO: implement
58+
(void)__range1; (void)__range2; (void)__comp; (void)__proj1; (void)__proj2;
59+
return {};
60+
}
61+
62+
};
63+
64+
} // namespace __includes
65+
66+
inline namespace __cpo {
67+
inline constexpr auto includes = __includes::__fn{};
68+
} // namespace __cpo
69+
} // namespace ranges
70+
71+
_LIBCPP_END_NAMESPACE_STD
72+
73+
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74+
75+
#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H

0 commit comments

Comments
 (0)