Disallowing S() when struct S has a constructor
Paul Backus
snarwin at gmail.com
Fri Sep 6 16:23:45 UTC 2024
On Friday, 6 September 2024 at 09:45:39 UTC, Quirin Schroll wrote:
> On Thursday, 5 September 2024 at 18:17:33 UTC, Paul Backus
> wrote:
>> We already have compiler-generated default implementations for
>> copy constructors and `opAssign`, and neither of them support
>> this kind of explicit declaration. Why is it necessary to have
>> this for default constructors, if it wasn't necessary for copy
>> constructors and `opAssign`?
>
> Because defining any constructor makes the compiler not
> generate a default constructor. It’s a way to say: Give me the
> default constructor without spelling it out.
My point is: so far, we have been fine with requiring the
programmer to spell it out in other cases. Why is that
unacceptable in this case specifically?
Maybe the answer is, "it's not just a problem in this case, the
programmer shouldn't have to spell it out in any of those other
cases either." If so, then this should be a more general language
feature, with its own DIP separate from any default-constructor
proposal.
More information about the Digitalmars-d
mailing list