foreach over pointer to range

Artur Skawina art.08.09 at gmail.com
Tue Jun 5 11:42:04 PDT 2012


"foreach (e; pointer_to_range)" currently fails with:

   Error: foreach: Range* is not an aggregate type

It can be worked around with 

   struct RangePtr(R) {
      R* ptr;
      alias ptr this;
      @property front()() { return ptr.front; }
   }

but this adds unnecessary overhead (unfortunately such struct is not
always treated the same as a real pointer, eg when passing it around).

Is there some reason that makes the is-aggregate check necessary, or could
it be dropped?


Thanks,

artur


More information about the Digitalmars-d mailing list