[PATCH] Remove 'explicit' keyword from constructors with multiple (non-default) arguments.
Matt Beaumont-Gay
matthewbg at google.com
Mon Jun 23 11:00:20 PDT 2014
On Mon, Jun 23, 2014 at 4:47 AM, Alexander Kornienko <alexfh at google.com> wrote:
> +Matt, who requested this feature.
>
> On Sun, Jun 22, 2014 at 9:13 AM, James Dennett <jdennett at googlers.com>
> wrote:
>>
>> On Sun, Jun 22, 2014 at 3:00 AM, David Blaikie <dblaikie at gmail.com> wrote:
>>>
>>> Fwiw, if I'm not mistaken, explicit on more - than - one - arg actors
>>> does
>>> have some meaning in c++11. It means you can't construct from a braced
>>> init
>>> list.
>>
>>
>> IIRC: More specifically, you can't use copy-list-initialization; direct
>> initialization from a braced init list is allowed for an explicit
>> constructor.
>>
>> The essence is that it takes some thought before removing explicit from a
>> constructor, more so than in C++98.
>
>
> Thanks for noting. This may be an interesting argument in whether we should
> remove "explicit" on multiple-argument constructors or not. I'm not sure
> though, how useful the ability to disallow direct initialization from a
> braced init list is. It's rather obvious what harm can an implicit call to a
> single-argument constructor cause, but with braced init lists a mistake is
> much less likely, imo.
>
> Matt, what do you think about this?
I did not know that 'explicit' had an expanded meaning in C++11. I bet
that most cases in our codebase where 'explicit' is present on a
multi-argument ctor are due to arguments being added to a one-argument
ctor, rather than actively trying to avoid copy-list-initialization.
-Matt
More information about the cfe-commits
mailing list