Re: Initialization of structure field w/o default ctor

2015-01-22 Thread Kenji Hara via Digitalmars-d-learn
On Thursday, 22 January 2015 at 12:45:53 UTC, drug wrote: On 22.01.2015 15:30, bearophile wrote: drug: Also can I avoid "dummy" non-default ctor for Bar? One solution: struct Foo { int foo; @disable this(); this(int foo_) pure nothrow @safe @nogc { this.foo = foo_;

Re: Initialization of structure field w/o default ctor

2015-01-22 Thread drug via Digitalmars-d-learn
On 22.01.2015 15:30, bearophile wrote: drug: Also can I avoid "dummy" non-default ctor for Bar? One solution: struct Foo { int foo; @disable this(); this(int foo_) pure nothrow @safe @nogc { this.foo = foo_; } } struct Bar { enum arraySize = 3; Foo

Re: Initialization of structure field w/o default ctor

2015-01-22 Thread bearophile via Digitalmars-d-learn
drug: Also can I avoid "dummy" non-default ctor for Bar? One solution: struct Foo { int foo; @disable this(); this(int foo_) pure nothrow @safe @nogc { this.foo = foo_; } } struct Bar { enum arraySize = 3; Foo[arraySize] foo = Foo(1); } void main() @safe

Initialization of structure field w/o default ctor

2015-01-22 Thread drug via Digitalmars-d-learn
What's the best way to initialize structure field that has no default ctor? http://dpaste.dzfl.pl/64cd0a3879fa Also can I avoid "dummy" non-default ctor for Bar?