foreach for ranges?

Eyyub eyyub.pangearaion at gmail.com
Tue Jul 17 12:38:51 PDT 2012


On Tuesday, 17 July 2012 at 19:27:54 UTC, Jonathan M Davis wrote:
>
> It translates
>
> foreach(e; range)
> {}
>
> into something like
>
> foreach(auto __range = range; !__range.empty; 
> __range.popFront())
> {
>     auto e = __range.front;
> }
>
> The compiler knows just enough about ranges to enable foreach, 
> but beyond
> that, ranges are entirely a library construct.

The spec' says "If the foreach range properties do not exist, the 
opApply method will be used instead.", does this mean that range 
properties take precedence over opApply ?



More information about the Digitalmars-d-learn mailing list