Understanding opAssign and 'alias this'
Maxim Fomin
maxim at maxim-fomin.ru
Mon Oct 14 02:32:14 PDT 2013
On Monday, 14 October 2013 at 09:17:12 UTC, John Colvin wrote:
> Everything is working fine except for the error on [2] when xxx
> == true, which I think is a bug.
>
> minimised test:
>
> struct A
> {
> void opAssign(A a) {}
> }
>
> struct B {
> A a;
> alias a this;
> }
>
> void main() {
> A a;
> B b;
> b = a;
> }
>
> Error: function assign.B.opAssign (B p) is not callable using
> argument types (A)
This does not work (and need not) because compiler generates
default function B.opAssign(B) which is really not callable using
argument types (A).
More information about the Digitalmars-d-learn
mailing list