https://issues.dlang.org/show_bug.cgi?id=21904
Issue ID: 21904
Summary: static range primitives should be usable directly
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
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();
}
--