foreach over pointer to range
    Timon Gehr 
    timon.gehr at gmx.ch
       
    Tue Jun  5 11:46:51 PDT 2012
    
    
  
On 06/05/2012 08:42 PM, Artur Skawina wrote:
> "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
It should be dropped. A pointer to range is a perfectly fine range.
    
    
More information about the Digitalmars-d
mailing list