I want to store interfaces as untyped void[], then cast them back to the interface at a later time. However, it appears to produce garbage values on get().

Is this even possible, and if so, what is happening here? The alternative would be a struct { CheckedPtr self; api_fns.... }

e.g.

void register(I)(I i) {
  auto mem = new void[](I.sizeof);
  memcpy(mem.ptr, cast(void*) i, I.sizeof);

  // CheckedPtr includes a hash of fullyQualifiedName
  map[i.get_name()] = CheckedPtr!I(mem.ptr);
}

I get(I)() {
  // basically cast(I) p
  return map[I.get_name()].as!I();
}

Reply via email to