================
@@ -1881,6 +1881,19 @@ OutputIt move(R &&Range, OutputIt Out) {
return std::move(adl_begin(Range), adl_end(Range), Out);
}
+/// Provide wrappers to std::includes which take ranges instead of having to
+/// pass begin/end explicitly.
+template <typename R1, typename R2> bool includes(R1 &&Range1, R2 &&Range2) {
+ return std::includes(adl_begin(Range1), adl_end(Range1), adl_begin(Range2),
+ adl_end(Range2));
+}
+
+template <typename R1, typename R2, typename Compare>
+bool includes(R1 &&Range1, R2 &&Range2, Compare C) {
+ return std::includes(adl_begin(Range1), adl_end(Range1), adl_begin(Range2),
+ adl_end(Range2), C);
----------------
kuhar wrote:
For `forward` you'd have to pass `C` as `Compare &&` in the function signature.
This way it will be moved if the caller passes an rvalue reference.
> I just have a question that why other places no need to forward C?
Most wrappers assume that predicates/comparators are cheap to copy (e.g.,
function pointer), but if they are not, each additional wrapper adds a layer of
copying.
This suggestion was optional -- I don't think we strictly need it now, but it
doesn't hurt to use `forward` now so that we don't have to update this code in
the future.
https://github.com/llvm/llvm-project/pull/143297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits