On May 20, 2011, at 8:43 AM, so wrote:
> On Fri, 20 May 2011 17:30:33 +0300, Sean Kelly <[email protected]> wrote:
>
>> In main above you're declaring a new struct variable t which is
>> default-constructed, then a temporary is created and initialized to 5, and
>> then the temporary is copied onto t. It does seem like a postblit should
>> probably occur in this scenario though.
>
> I am confused.
> There shouldn't be any copying, it is construction.
If you do the following:
MyStruct s;
A new instance of MyStruct is be created and default-initialized. Changing
this to:
MyStruct s = MyStruct(5);
Is really just shorthand for:
MyStruct s;
s = MyStruct(5);
The compiler can translate this into a single construction (it does in C++),
but I don't know that it's required to.