To iterate over a type that define the input range primitive, we must define
an alias this:
---
struct Conv
{
static StaticIterable b;
alias b this;
}
struct StaticIterable
{
static Conv b; alias b this; // required
// enhancement: could work without ?
static void popFront() { }
static bool empty() { return true; }
static int front() { return 0; }
}
void main()
{
foreach (int i; StaticIterable){}
//for (; !StaticIterable.empty(); StaticIterable.popFront())
// int i = StaticIterable.front();
}
Comment #1 by robert.schadek — 2024-12-13T19:16:17Z