C++ Logo


Advanced search

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

From: Walt Karas <wkaras_at_[hidden]>
Date: Wed, 9 Jun 2021 14:14:25 +0000 (UTC)
Thanks, I wasn't aware that had been added. A bit verbose, but oh well.

What's wrong with explicit(false)?

struct A { explicit(false) A(int); };

On Wed, 9 Jun 2021, 02:06 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.

Received on 2021-06-09 09:14:32