pure and custom new / delete

Benjamin Thaut code at benjamin-thaut.de
Tue Jun 26 09:05:55 PDT 2012


Am 26.06.2012 18:02, schrieb Timon Gehr:
> On 06/26/2012 05:59 PM, Benjamin Thaut wrote:
>> As delete and new / delete overloading is deprecated and it was
>> recommeneded to write tempaltes to repalce these expressions I did so.
>>
>> But now as everything starts to work out pretty nice I've walked into
>> the 'purity' issue. Pure functions are only allowed to call other pure
>> functions and as far as I know there is no way to make functions
>> "trusted pure". But I would need to make certain functions "trused
>> pure", espeically my new and delete replacements. Any suggestions how to
>> do this?
>>
>> Kind Regards
>> Benjamin Thaut
>
> You can cast function pointers to pure, or mark extern(C) memory
> allocation functions as pure.

extern(c) is not an options as there is a structure of various different 
allocators that implement a common interface which all is written in D.

Is the compiler smart enough to optimize away a function pointer I 
created localy just so I can cast it?

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list