foreach for ranges?
Mike L.
mike.linford.reg at gmail.com
Tue Jul 17 21:27:28 PDT 2012
Thanks for the reply. Not sure how I missed it there. Interesting
that the compiler has to be made aware of a concept that I had
thought was only supposed to be part of phobos. Would it be
possible to implement it in std.range using the new UFCs?
On Tuesday, 17 July 2012 at 19:17:47 UTC, Ali Çehreli wrote:
> On 07/17/2012 11:59 AM, Mike L. wrote:
>> How exactly does the compiler know how to do foreach on ranges
>> (for
>> example, ones returned by std.algorithm.map ?) I've looked
>> around in
>> std.algorithm and std.range, but can't seem to figure it out.
>
> The spec mentions it under 'Foreach over Structs and Classes
> with Ranges':
>
> http://dlang.org/statement.html#ForeachStatement
>
> There are two methods:
>
> a) opApply() member functions (and opApplyReverse(), which is
> rumored to be deprecated in the future)
>
> b) empty, front, and popFront() member functions
>
> Ali
More information about the Digitalmars-d-learn
mailing list