So why doesn't popFront return an element?
Timon Gehr
timon.gehr at gmx.ch
Thu Apr 14 13:36:31 PDT 2011
> Nah, it's simpler than that:
>
> assert(is(typeof(b) == int[]));
>
> which is done by retro (it detects if you're retro-ing a retro range, and
> just returns the original).
>
> -Steve
Makes sense. But still, I think inlining is responsible for the following code
generating identical machine code:
import std.range;
import std.stdio;
import std.algorithm;
int id(int a){return a;}
void main(){
int[] a=new int[1000];
auto b=retro(map!id(map!id(retro(a))));
writeln(b.front);
}
Correct me if I'm wrong, but I think phobos does only handle the special case
retro(retro(x)) explicitly.
-Timon
More information about the Digitalmars-d-learn
mailing list