std.typecons scoped question
Martin
martinbbjerregaard at gmail.com
Sat Sep 7 02:23:07 PDT 2013
What is the reason behind the wasted memory when using the scoped
template from std.typecons? For example
class A { }
class B
{
typeof(scoped!A()) a;
this()
{
a = scoped!A();
}
}
void main(string[] args)
{
writeln("Size of class A: ", __traits(classInstanceSize, A));
writeln("Size of class B: ", __traits(classInstanceSize, B));
}
Prints the following:
"Size of class A: 8"
"Size of class B: 24"
An extra 16 bytes for alignment? Is there no options like
align(1) to pack the memory of the class A instance inside class
B?
More information about the Digitalmars-d
mailing list