Struct constructors
Sean Eskapp
eatingstaples at gmail.com
Thu Jan 20 10:42:35 PST 2011
In code like this:
import std.stdio;
struct foo
{
int val;
static immutable bar = foo(1);
this(int val)
{
this.val = 50;
}
}
void main()
{
writeln(foo.bar.val);
}
The user-defined struct constructor is not called, because it's overridden by
a built-in constructor which treats it like an initializer list. Shouldn't
constructors in structs either generate errors/warnings, or work as they would
appear to?
More information about the Digitalmars-d
mailing list