[Issue 3872] std.algorithm.filter could become bidirectional if its input range is bidir
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 9 07:48:29 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=3872
FeepingCreature <default_357-line at yahoo.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |default_357-line at yahoo.de
Resolution|FIXED |---
--- Comment #2 from FeepingCreature <default_357-line at yahoo.de> ---
Got unfixed at some point:
```
import std.algorithm : filter;
import std.range : only;
void main()
{
int[] a = [2, 3];
assert(only(2, 3).back == 3);
assert(a.filter!"a == 2".back == 2);
}
```
=>
onlineapp.d(7): Error: no property `back` for `filter(a)` of type
`std.algorithm.iteration.FilterResult!(unaryFun, int[])`
Apparently there's `filterBidirectional`. I am violently opposed to that
function and all it represents. `filter` should support bidirectional iteration
by default, with maybe `filterUnidirectional` or `forceForwardRange` if you
want to *disable* it. Since when do we sacrifice functionality for speed by
default?
--
More information about the Digitalmars-d-bugs
mailing list