Bug 21904 – static range primitives should be usable directly

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-05-07T17:23:44Z
Last change time
2024-12-13T19:16:17Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#19924 →

Comments

Comment #0 by b2.temp — 2021-05-07T17:23:44Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19924 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB