On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler wrote:
T construct(T,A...)(void* buffer, A args)
{
  return (cast(T)buffer).__ctor(args);
}

This is wrong, you need to initialize the memory first to the proper values for the class, gotten via typeid(T).init. std.conv.emplace does this correctly, either use it or look at its source to see how to do it.

ubyte[ __traits(classInstanceSize, Exception)] exceptionBuffer;

When the stack unwinds, this will be invalidated... I don't think stack allocated exceptions are ever a good idea. I don't think malloc exceptions are a good idea either, the catcher would need to know to free it.

You might preallocate a pool of GC'd exceptions though, then throw the next one in the list instead of making a new one each time.

Reply via email to