On Tuesday, 14 December 2021 at 13:02:16 UTC, Tejas wrote:
On Tuesday, 14 December 2021 at 12:04:36 UTC, RazvanN wrote:
[...]

Then why did my modification work?

```d
struct Foo(T){
    this(Rhs, this This)(scope Rhs rhs){
    }

this(scope Foo!(T)* rhs){ //replaced typeof(this) with Foo!T and ref with pointer. Code still works if I retain typeof(this)
    }
}


struct Bar{
        Foo!int foo;
}

void main(){
        import std.stdio:writeln;
        
        Bar bar = Bar();
        auto BAR = new Bar();
        writeln(bar, "\t", BAR, "\t", *BAR);
}
```

Did my modifications ensure that this is not treated as a copy constructor?

Yes, the copy constructor needs to be explicitly defined by passing a ref parameter. Since you are expecting an explicit pointer, the compiler does not see it as a copy constructor and therefore does not try to generate one for Bar.

Reply via email to