On 11/02/2015 11:59 PM, Alex wrote:

> "Programming in D" book (the revision of 2015-10-24)

Oooh! That smells very fresh. :)

> In my case, the container class can't become empty. Even if it contains
> one single element, in this case the example should return true for
> begin == end, it is not empty.

That problem is solved by the convention that 'end' is one beyond the last valid element. So, when there is only the element 42, then begin==42 and end==43. Only when the last element (42 in this case) is consumed, begin==end.

> A further problem/wish is: I don't want to store my elements explicitly
> as members. So taking the simplest example on page 486 has a further
> meaning for me: It does not contain an array as member and it is not
> meant to.

Such ranges are called generators. As long as .front returns the current element, and popFront() advances to the next one, you don't need to store any array. (You seem to say the same thing, so I don't understand the question.)

Ali

Reply via email to