C++ Logo

std-proposals

Advanced search

Re: Proposal: overload 'auto' keyword to mean implicit for constructors

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 9 Jun 2021 02:13:12 -0400
On Tue, Jun 8, 2021 at 9:06 PM Walt Karas via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> For constructors that can be called with a single argument, and can be called implicitly. For example:
>
> struct A { auto A(int); };
>
> would be equivalent to simply:
>
> struct A { A(int); };
>
> This would allows compilers to support an option to require that constructors callable with one argument (other that copy/move constructors) be preceded by either "explicit" or "auto", otherwise a diagnostic is output. This would be helpful to me and presumably others, who on occasion forget to make a conversion constructor explicit when it should be.

It would make far more sense to just use an attribute for that. That's
the kind of thing attributes are for, after all. Sticking `auto` makes
absolutely no sense, as it doesn't deduce anything at all.

Received on 2021-06-09 01:13:26