Copy instead of reference?

Artur Skawina art.08.09 at gmail.com
Thu May 23 06:21:16 PDT 2013


On 05/23/13 14:30, Namespace wrote:
> On Thursday, 23 May 2013 at 12:29:04 UTC, Artur Skawina wrote:
>> On 05/23/13 13:57, Namespace wrote:
>>> I know that D has (sadly) no C++ references, but I still think that
>>>
>>> A a = some_existing_A;
>>>
>>> should call opAssign.
>>
>> Not opAssign, but user-defined copy-constructor. But D does not have
>> them either...
> 
> That would be a solution.

They are required anyway, for several reasons.

Right now, you /can/ do:

   A a = A(some_existing_A);

but, because 'A a = some_existing_A' will bypass your cpctor and
call the postblit, it's too dangerous. Unless you mark the latter
as @disabled, which of course causes other problems.

artur


More information about the Digitalmars-d-learn mailing list