On Tuesday, 9 October 2012 at 17:32:35 UTC, Zhenya wrote:
On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote:
Hi!
I'm sorry,maybe this topic already was discussed,but could anybody explain me
why default constructor was disallowed in structs?

And if I have to do some initialization of data members,what is the way to do it?

TDPL, the book by Andrei Alexandrescu, says that it was done for having compile time known default value for structure types which is T.init in general. For classes T.init is null so there is no problem. Assumption here is that statically known T.init and default constructor cannot coexist, however there are discussion in this forum that this issue may be reconsidered.

Absence of default structure constructors is a piece of the puzzle which is creation of D structures and consists of structure constructors, static/object opCall methods, struct literals together with static initialization. You may use any of this method for initialization, the problem is IMHO in their contradiction and priority.

Reply via email to