How to do foreach'able template Array?

unknown sphinski at netscape.net
Fri Sep 1 00:21:57 PDT 2006


How to implement foreachable template Array class:

class Array(T)
{
   T[] arr;

   public this() {}
   public int count() { return arr.length; }
   public void add(T t) { arr.length = arr.length+1; arr[length-1] = t; }

   opApply() {
     ???
   }
}

I could not find out how to write correct operator opApply.



More information about the Digitalmars-d-learn mailing list