foreach and filter
Timon Gehr
timon.gehr at gmx.ch
Thu Apr 12 10:44:36 PDT 2012
On 04/11/2012 06:08 PM, Russel Winder wrote:
> Doing something along the lines of:
>
> const a = array ( filter! ... ) ;
> foreach ( i ; a ) { ... }
>
> works fine. Question 1 though is why I can't use immutable here, why I
> have to use const.
'array' is not pure for some reason. This should be fixed.
> Question 2 is why I can't do:
>
> const a = filter! ... ;
> foreach ( i ; a ) { ... }
>
popFront cannot be const. (And Phobos is not very const correct
anyways). You can try
auto a = filter!foo(cast(const)data);
foreach( i ; a ) { ... }
(Assuming data is a built-in array slice)
More information about the Digitalmars-d
mailing list