C++ Logo

std-proposals

Advanced search

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

From: Walt Karas <wkaras_at_[hidden]>
Date: Wed, 9 Jun 2021 01:06:31 +0000 (UTC)
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-08 20:06:36