On Thursday, 22 December 2011 at 06:43:33 UTC, Froglegs wrote:
T emplace(T, Args...)(void[] chunk, Args args) if (is(T ==
class))
{
enforce(chunk.length >= __traits(classInstanceSize, T),
new ConvException("emplace: chunk size too small"));
...
This fails whenever the size is greater or equal to the amount
of memory required :(
Hum nevermind that, got confused by the IDE behavior. Anway
this emplace function crashes when I call it with a very
meaningless callstack.
This works for me:
import std.conv;
class C {
int i;
this() { i = 42; }
}
unittest {
void[__traits(classInstanceSize, C)] data = void;
auto c = emplace!C(data[]);
assert(c.i == 42);
}