color lib
    Nicholas Wilson via Digitalmars-d 
    digitalmars-d at puremagic.com
       
    Mon Oct 10 19:36:50 PDT 2016
    
    
  
On Tuesday, 11 October 2016 at 00:10:04 UTC, Nicholas Wilson 
wrote:
> What about forwarding the array ops to a foreach of the static 
> array?
> Like as above but instead of:
>
> ElementType!(R)[N] batch;
>
> have:
>
> static struct Batch
> {
>     ElementType!(R)[N] elements;
>     auto get() { return elements[];}
>
>     Batch opBinary(string op)(Batch rhs) 
> if(hasOperator!(ElementType!(R),op))
>     {
>         Batch b;
>         foreach(i; iota(N)) mixin("b.elements[i] = elememts[i]" 
> ~op~"rhs.elements[i]");
>         return b;
>     }
>     //repeat for opUnary,opOpAssign...
> }
> Batch batch;
>
> I'll make another forum thread for this.
whoops missed an
alias get this;
    
    
More information about the Digitalmars-d
mailing list