C++ Logo

std-proposals

Advanced search

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

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 9 Jun 2021 07:08:36 +0100
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.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2021-06-09 01:08:49