[libc++][ranges] implement `std::ranges::set_union`
[libc++][ranges] implement `std::ranges::set_union`
Differential Revision: https://reviews.llvm.org/D129657
NOKEYCHECK=True
GitOrigin-RevId: 3151b95dad408351e368baf31125985b6de4e5db
diff --git a/include/algorithm b/include/algorithm
index f616a03..ff700cf 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -712,6 +712,23 @@
set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+ template<class I1, class I2, class O>
+ using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
+
+ template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
+ weakly_incrementable O, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
+ constexpr set_union_result<I1, I2, O>
+ set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+
+ template<input_range R1, input_range R2, weakly_incrementable O,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
+ constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
+ set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
}
constexpr bool // constexpr in C++20
@@ -1493,6 +1510,7 @@
#include <__algorithm/ranges_set_difference.h>
#include <__algorithm/ranges_set_intersection.h>
#include <__algorithm/ranges_set_symmetric_difference.h>
+#include <__algorithm/ranges_set_union.h>
#include <__algorithm/ranges_sort.h>
#include <__algorithm/ranges_sort_heap.h>
#include <__algorithm/ranges_stable_sort.h>