opAssign(int) necessitates this(this) for automatic opAssign to work
Simen kjaeraas
simen.kjaras at gmail.com
Sat Dec 26 17:08:01 PST 2009
On Sun, 27 Dec 2009 01:42:07 +0100, Ali Çehreli <acehreli at yahoo.com> wrote:
> I've tested the following with dmd 2.037.
>
> The compiler generated opAssign is disabled by the definition of
> opAssign(int). The compiler rejects the following assignment operation.
> (The error message is in the comment below.)
>
> Is this by design?
>
> When I also define post-blit, the compiler generated opAssign is
> available again and seems to work correctly. (My struct doesn't have any
> members for brevity.)
>
> The program below compiles when this(this) is provided.
>
> void main()
> {
> S s0;
> s0 = s0; // ERROR
> }
This piece of code does post-blit, not opAssign(int).
Try defining opAssign(S). That should work here.
The problem is, opAssign(int) takes a right-hand parameter of type int,
whereas s0 = s0; has a rhs of type S.
--
Simen
More information about the Digitalmars-d
mailing list