On Thursday, 6 February 2014 at 17:54:38 UTC, Andrei Alexandrescu wrote:
Malloced!T and GC!T suggests parameterization by the type of the allocator.

Not necessarily, different allocators with the same free could return the same type. The key point is the knowledge of how to free it is encapsulated there in some way.

RefCounted!T is a whole different thing, because it doesn't encode allocation strategy but instead memory reclamation tactics.

Malloced!T also encodes reclamation tactics: ~this() { free(ptr); }

You could also call it Unique!T(&free): the malloced pointer is unique and must be released with free. That cvers the same ground in more generic way. (Surely refcounted!T needs to know what happens when count==0 too.)

Reply via email to