_indexed_ iteration using opApply or range -- PS
Simen kjaeraas
simen.kjaras at gmail.com
Sun Dec 12 12:06:16 PST 2010
spir <denis.spir at gmail.com> wrote:
> PS: Also tried to make iteration work by defining slice "with no
> argument" (coll[]) only, like indicated in TDPL p.381. But could not
> manage to do it.
The point of coll[] is that a collection may not want to define the
range primitives itself, but rather expose a special range struct for
that purpose:
class Collection {
auto opSlice( ) {
struct range {
// front, popFront, empty, whosYourDaddy
}
return range( this );
}
}
--
Simen
More information about the Digitalmars-d-learn
mailing list