On Monday, 13 January 2014 at 22:48:37 UTC, evansl wrote:
On 01/11/14 03:30, Rainer Schuetze wrote:
On 10.01.2014 22:42, Andrei Alexandrescu wrote:
[snip]
std.emplace will continue to work as a way to build an object
at a
specified address. I suspect that allocating and manipulating
objects on
the GC heap in particular may have certain restrictions. One
possibility
to avoid such restrictions is to have a function
typify(T)(void* p)
which ascribes type T to heap location p.
That sounds similar to my gc_emplace function. The problematic
part is
how to save that information in the GC.
[snip]
Couldn't you store a pointer to the typeinfo within the
allocated memory? IOW, the first part of the allocated memory
would be the typeinfo* followed by the actual memory used to
store the
value of the allocated T object.
-regards,
Larry
std.emplace can be used on a partial memory block (e.g. as part
of a struct), so you will have to add the emplaced type info in
addition to the outer struct's type info. There can be multiple
areas with emplaced dta within the same memory allocation, too.
So you'll need to store a list of type infos paired with the
offsets within the meory block. How do you do this efficiently
without extra cost for the usual scanning?