3 ms·
> If you don't override it, it will copy everything properly. Sure, so does memcpy or bare struct assignment in C. The problem is that trivial copy constructo
by bonzini 9y ago
> If you don't override it, it will copy everything properly.
Sure, so does memcpy or bare struct assignment in C. The problem is that trivial copy constructors are relatively rare.
> Here even if you could not just have derived Clone (struct bio looks non-trivial) your hand-rolled implementation would have complained that you had not properly initialised the member.
Right, but this is more similar to an assignment operator. DerefMut in Rust I think wouldn't have caught the bug.
- masklinn 9y ago> Right, but this is more similar to an assignment operator. Only if you don't zoom out. If you do, this is alloc/init/fill which in C++ or Rust would use a regular copy and RVO.