DIP77 - Fix unsafe RC pass by 'ref'

matovitch via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 12 01:28:57 PDT 2015


On Sunday, 12 April 2015 at 04:18:54 UTC, Andrei Alexandrescu 
wrote:
> On 4/11/15 5:35 AM, matovitch wrote:
>> I am not convinced by the dip77, what about raii managed 
>> classes with
>> costly opAssign operator (like in w0rn example) ? The goal of 
>> passing an
>> object by reference is to avoid the copy and here you guess the
>> parameter is ref-counted and made a (pseudo-)copy ? Then any 
>> allocating
>> opAssign should be marked @system ?
>
> Expensive opAssign or expensive postblit? -- Andrei

Well both in the example given by w0rp. I guess D as no "rule of 
five" but still a "rule of three" (which is in fact rule of four 
with the copy-and-swap idiom) about coding posblit, opAssign and 
destructor together ?


More information about the Digitalmars-d mailing list