Support detecting begin()/end() methods for range-for loops (#7185)

This commit adds support for range-based for loops using C++ types. It's
currently limited to detecting that `r.begin()` and `r.end()` are
available. We should be able to add full support for methods after #7181
is merged.

Support for ADL is still a work-in-progress, and will be added at a
later time.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Christopher Di Bella
2026-05-12 19:03:55 +00:00
committed by GitHub
co-authored by Richard Smith
parent dd7cfdb149
commit 2aaa061688
6 changed files with 487 additions and 0 deletions
+7
View File
@@ -30,3 +30,10 @@ impl forall [T:! Copy & Destroy, N:! IntLiteral()]
}
}
}
interface CppRangeForIterate {
let Iterator:! type;
let Sentinel:! type;
fn Begin[ref self: Self]() -> Iterator;
fn End[ref self: Self]() -> Sentinel;
}