I do not understand copy constructors
Paul Backus
snarwin at gmail.com
Fri Aug 13 20:58:30 UTC 2021
On Friday, 13 August 2021 at 15:26:15 UTC, Steven Schveighoffer
wrote:
> The issue is that you can't convert const (or immutable or
> mutable) to inout implicitly, and the member variable is inout
> inside an inout constructor. Therefore, there's no viable copy
> constructor to call for the member, and the outer copy
> constructor cannot be generated.
I'm not quite sure I follow this. Are you saying that the
constructor call is typechecked as if it were written like this:
```d
this.field = this.field.__ctor(rhs.field);
```
...and not like this?
```d
this.field.__ctor(rhs.field);
```
Because I can see how the first version would involve an
const-to-inout conversion, but the second version looks like it
ought to work.
More information about the Digitalmars-d-learn
mailing list