Manual memory management in D2

Petr janda.petr at gmail.com
Tue Jul 13 15:51:54 PDT 2010


> T* malloc(T, A...)(A args) if (!is(T == class) && !isDynamicArray!T);
> T malloc(T, A...)(A args) if (is(T == class) || isDynamicArray!T);
> free(T)(ref T obj);

> The first two call C's malloc, constructor (if any), and returns the
> allocated object. The last calls the destructor (if any) and then free().

> worksforyou?

Then again, why not just port C++ std::memory interface to make C++ programmers feel right at home? :)

Thanks,
Petr


More information about the Digitalmars-d mailing list