Warnings/What should I know?

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 18 00:19:30 PDT 2013


On Friday, October 18, 2013 09:02:49 simendsjo wrote:
> On Friday, 18 October 2013 at 06:56:49 UTC, monarch_dodra wrote:
> (...)
> 
> > struct S
> > {
> > 
> >     this(int i = 5)
> >     {}
> > 
> > }
> > S s = S(); //Does *not* call the constructor with the value 5.
> 
> I didn't know that. In that case, I think struct ctors with only
> optional parameters should be illegal - how is it possible to
> call it?
> Struct ctors without parameters is already illegal due to .init.

I think that there's a bug report on that somewhere, but I'd have to go 
digging for it.

The only way that S() is anything other than S.init is if you overloaded 
opCall and made it static, in which case, S() becomes a call to that.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list