Thread overview
How do you overload new and delete for a class?
Jan 09, 2012
Adrian Mercieca
Jan 10, 2012
Adrian Mercieca
January 09, 2012
Hi,

Can someone please provide an example regarding overloading new and delete for a class?

Thanks a lot.
January 09, 2012
On 09-01-2012 20:41, Adrian Mercieca wrote:
> Hi,
>
> Can someone please provide an example regarding overloading new and delete
> for a class?
>
> Thanks a lot.

This is deprecated.

What you should be doing is using std.conv.emplace() with whatever allocator (say, malloc()) you wish to use.

- Alex
January 10, 2012
Hi Alex,

Thanks for the answer.

As for the allocation, you mention malloc: is that malloc from the C runtime library? You also imply alternatives to this allocator; what would these be?

As for deletion, does on then invoke delete on the malloc'ed data pointer?

Pointing me to some example would be greatly appreciated.

Thanks.
- Adrian.