On 2/6/14, 11:14 AM, Adam D. Ruppe wrote:
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); }

So if T is int[] and you have taken a slice into it...?

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.)

I'm not sure I understand what you are talking about.


Andrei

Reply via email to