Copy instead of reference?
Namespace
rswhite4 at googlemail.com
Thu May 23 05:17:52 PDT 2013
On Thursday, 23 May 2013 at 12:07:40 UTC, Maxim Fomin wrote:
> On Thursday, 23 May 2013 at 11:57:04 UTC, Namespace wrote:
>> I know that D has (sadly) no C++ references, but I still think
>> that
>>
>> A a = some_existing_A;
>>
>> should call opAssign.
>
> Now I see what has you confused. Whether postblit or opAssign
> is called, depend on left, not right side of assignment. Object
> 'a' didn't exists prior, so postblit is called, and copy ctor
> is called with respect of 'a' as 'this' argument.
What had confused me, was the point, that it doesn't matter if
you return by value or by ref, you get the same output for this
specific case.
That did not feel right.
But thanks to you.
More information about the Digitalmars-d-learn
mailing list