Strange copying of a constant array of structures

Vindex tech.vindex at gmail.com
Fri Jun 14 13:52:14 UTC 2024


>> And why is the copy constructor only called once in the last 
>> example? Optimization?
>
> Yes kind of optim. The compiler is allowed to use 
> "move-semantics". Looks like it's what happens here (at first 
> glance).

I'm guessing it's the implicit `opAssign` method after all. The 
objects in the copy have already been created and initialized as 
T.init, so the copy constructor will not be called in any way.


More information about the Digitalmars-d mailing list