A few bugs connected to structs

Timon Gehr timon.gehr at gmx.ch
Wed Jan 11 11:05:08 PST 2012


On 01/11/2012 05:58 PM, Benjamin Thaut wrote:
> 1. It's currently not possible to overload opAssign for structs with a
> template because opAssign(T)(T rh) if(is(T == typeof(this)))
>
> is not allowed (stated in the documentation). And templates can not
> overload non template functions (already a known bug).
>
> 2. It's not possible to use auto ref with opAssign because
> opAssign(T)(auto ref T rh) if(is(T == typeof(this))) is not allowed
> (partly the same issue as 1).
>
> Why is this not allowed? (The documentation does not state any reason)

There is no reason, and DMD accepts it. Maybe file a bug against the 
documentation?

struct S{
     auto opAssign(T)(auto ref T rhs) if(is(T==typeof(this))){return rhs;}
}

void main(){
     S a, b;
     a=b;
}

>
> 3. Calling a method that is overloaded with shared / const / immutable
> from within a function has to be done with this.method()
> otherwise the compiler complains about ambugiosity. Is method() not the
> same as this.method() ??
>

Yes it is. Has this been filed already?


More information about the Digitalmars-d mailing list