[Issue 22272] New: [std.range.retro] should behave the same as foreach_reverse
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 3 19:48:47 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22272
Issue ID: 22272
Summary: [std.range.retro] should behave the same as
foreach_reverse
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: jlourenco5691 at gmail.com
The Range retro follows the current Range hierarchy. This brings friction when
working with this range because it forces the user to implement a 'save'
method. Iterating a retro range should be the same as iterating with a
foreach_reverse. The foreach_reverse allows iterating ranges without the 'save'
method implementation. I would even argue that 'popFront' and 'front' shouldn't
be required because once again foreach_reverse allows that.
---
struct Foo
{
void popBack() { i--; }
bool empty() { return !i; }
auto back() { return i; }
int i = 1;
}
void main()
{
foreach_reverse(_; Foo.init) {}
}
---
--
More information about the Digitalmars-d-bugs
mailing list