foreach, an analogy

Karen Lanrap karen at digitaldaemon.com
Fri Oct 20 13:21:29 PDT 2006


Walter Bright wrote:

> How do you make for work with the following data structure:
> 
>      struct Tree
>      {     Tree* left;
>           Tree* right;
>           int data;
>      }
> ?

How do you make an iterator for foreach, if you do not own this (or 
any other) struct or class (because it comes from a library)?

What is the general pattern that has to be implemented into every 
struct or class to allow every user of that struct or class to 
provide an efficient enumeration for her/his purposes, which are 
unknown at present?

---und how does the compiler support this?



More information about the Digitalmars-d-announce mailing list