foreach for ranges?

Ali Çehreli acehreli at yahoo.com
Tue Jul 17 12:17:46 PDT 2012


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

-- 
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html


More information about the Digitalmars-d-learn mailing list