On Thursday, 12 August 2021 at 15:50:05 UTC, Tejas wrote:
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote:
On Thursday, 12 August 2021 at 14:57:16 UTC, Steven
Schveighoffer wrote:
[...]
It is not clear to me why the inout generated copy constructor
of the B structure is not able to copy the A structure.
[...]
Why will copy constructor of ```struct B``` accept argument of
type ```A```?
You are right, I forgot the A member, now it is clear:
struct A
{
int[] data;
this(ref return scope A rhs) {}
this(ref return scope const A rhs) const {}
this(ref return scope immutable A rhs) immutable {}
}
struct B
{
// default generated copy constructor, by section
14.15.6.2
this(ref return scope inout(B) src) inout
{
foreach (i, ref inout field; src.tupleof)
this.tupleof[i] = field;
}
A a;
}
Error: none of the overloads of `__ctor` are callable using a
`inout` object, candidates are:
`A.this(return ref scope A rhs)`
`A.this(return ref scope const(A) rhs)`
`A.this(return ref scope immutable(A) rhs)`
Thank you everybody.