diff options
author | Hui Xie <hui.xie1990@gmail.com> | 2022-07-08 15:21:40 +0100 |
---|---|---|
committer | Hui Xie <hui.xie1990@gmail.com> | 2022-07-11 06:55:09 +0100 |
commit | 96b674f23cd66e8fee9efde6003dc2032acf58b6 (patch) | |
tree | 3ef06403f3f42382905804a522b321f4a424c2f5 /libcxx/include/algorithm | |
parent | c13d04e599dd593c53e8f856bb7b71ab914e5934 (diff) | |
download | llvm-96b674f23cd66e8fee9efde6003dc2032acf58b6.zip llvm-96b674f23cd66e8fee9efde6003dc2032acf58b6.tar.gz llvm-96b674f23cd66e8fee9efde6003dc2032acf58b6.tar.bz2 |
[libc++][ranges] implement `std::ranges::set_intersection`
implement `std::ranges::set_intersection` by reusing the classic `std::set_intersenction`
added unit tests
Differential Revision: https://reviews.llvm.org/D129233
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r-- | libcxx/include/algorithm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 785c3ef..0cc4195 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -604,6 +604,25 @@ namespace ranges { set_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_intersection_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_intersection_result<I1, I2, O> + set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // 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_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> + set_intersection(R1&& r1, R2&& r2, O result, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + } constexpr bool // constexpr in C++20 @@ -1378,6 +1397,7 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/ranges_replace_if.h> #include <__algorithm/ranges_reverse.h> #include <__algorithm/ranges_set_difference.h> +#include <__algorithm/ranges_set_intersection.h> #include <__algorithm/ranges_sort.h> #include <__algorithm/ranges_sort_heap.h> #include <__algorithm/ranges_stable_sort.h> |