this(this) must be cheap and O(1)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Sep 24 11:07:00 PDT 2011


On 9/24/11 10:14 AM, Trass3r wrote:
>>> Isn't an expensive-to-copy type supposed to be a class anyway?
>>
>> Well not always - see BigInt.
>
> True.
>
>> A nothrow function may allocate memory, but allocating inside this(this)
>> would be a faux pas.
>
> So I can't .dup inside this(this)?

You can't.

> Even the example in the docs does so:
> http://www.d-programming-language.org/struct.html#StructPostblit

That needs changing.


Andrei


More information about the Digitalmars-d mailing list