On Wed, 19 Sep 2012 15:45:21 +0200, Namespace <rswhi...@googlemail.com>
wrote:
On Wednesday, 19 September 2012 at 13:32:42 UTC, Namespace wrote:
Is that possible?
I can initialize an object with scope or, in feature, with scoped,
directly on the stack but is it also possible to move an existing
object from the heap to the stack?
I tried this:
http://dpaste.dzfl.pl/2955ff41
But as you can see in line 25/26, after I destroyed the heap object, the
stack object seems to be corrupted.
The problem here is that A.sizeof returns the size of the reference, not
the instance. Instead you should use __traits(classInstanceSize, A).
Also, do have a look at the internals of std.typecons.scoped, it likely
contains some good ideas.
--
Simen