Using opOpAssign, cannot assign sequence

Paul Backus snarwin at gmail.com
Fri Apr 5 20:07:53 UTC 2019


On Friday, 5 April 2019 at 13:59:27 UTC, Alex wrote:
> class X(T)
> 	void opOpAssign(string op)(T d)
>
> If T has more than length of one then
>
> x += ????
>
> We can work around this but it seems to me that we should be 
> able to get it to work in some way
>
> x += Alias!(a,b,c)
>
> fails to package it up as do all other things I have tried.

Works for me if you make opOpAssign a variadic template:

     void opOpAssign(string op, Args...)(Args args)

Full example: https://run.dlang.io/is/dPk3BN


More information about the Digitalmars-d-learn mailing list