Ranges

%u wfunction at hotmail.com
Mon Feb 7 21:03:34 PST 2011


I've learned that an InputRange needs three methods to enumerate a collection:

  void popFront()
  @property T front()
  @property bool empty()

but is that really necessary? Why not just have:

  bool next(out T value);

?
Wouldn't this be much cleaner? Even the .NET implementation of IEnumerator
only has two methods used for enumeration (MoveNext() and Current), instead of
three.


More information about the Digitalmars-d-learn mailing list