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

Reply via email to