On Wednesday, 19 September 2012 at 17:08:28 UTC, monarch_dodra
wrote:
On Wednesday, 19 September 2012 at 14:16:31 UTC, Namespace
wrote:
Thanks, I will use __traits(classInstanceSize, A);
But it does not work either.
This is because classes are already pointers. when you write
"&a", you are getting the address of pointer itself. So when
you memcopy, don't use "&a", but use "cast(void*)a".
What you were currently doing was memcopying the "pointer to a"
into your chunk. From there, since you were casting to A*,
everything worked and was legal, but you still only had 1 class
intance. Your destroying that instance made your ap crash.
this works:
http://dpaste.dzfl.pl/8ba1f457
I forget this. Thank you!
IMO something like this should exist in phobos. A more flexible
version of scoped also.