Thanks everyone for the replies! I just thought it was weird that implicit construction is seemingly supported when directly initialising a struct but not in any other case. I guess it's because it's clearly less ambiguous.

On Thursday, 1 August 2024 at 13:07:09 UTC, Lance Bachmeier wrote:

For the program you've written, I'm happy it doesn't compile, because a lot of the time the compiler would be making buggy code compile - though I would love to have a way to do it explicitly. In this case you can change your definition of None to use alias this and it will compile:

The alias this doesn't work generically, though. Either way I agree that implicit construction, if it was present in D, should not be the default, instead being opt-in like say through an `implicit this(...)` or whatever instead of C++'s horrendous implicit by default behaviour.

Reply via email to