C++ Logo

std-proposals

Advanced search

Re: Argument deduction for non-static class members

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 20 Mar 2021 17:19:06 -0400
On Sat, Mar 20, 2021 at 12:26 PM Phil Bouchard via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
>
> On 3/20/21 12:13 PM, Ville Voutilainen wrote:
>
> On Sat, 20 Mar 2021 at 17:54, Phil Bouchard via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> And that's why deduction probably shouldn't happen with class members
> like that. It's not a matter of whether it's possible to specify in
> the standard; it's a matter of whether it's a good idea to permit it.
>
> And there are good arguments why it shouldn't be.
>
> So it's better to be stricter than stuck down the road with an allowance you can't revert...
>
> See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3897.html
>
> But my take is we should enable it for clarity because decltype(...) is quite ugly.

Did you read the paper and take note of all of the other reasons why
it's not a good idea? Like for example the fact that not only is
`decltype(...)` ugly, it's actually *semantically different* from the
expression "..." when used as a default member initializer.

Nobody's *forcing* anybody to use `decltype`. Not unless the
initialization expression is exceedingly complicated, and the one in
your example is decidedly not that. Avoiding typing `<int>` is not a
good reason to do this.

I'm not saying that there aren't places where using `auto` wouldn't be
justifiable. But you don't seem to be considering all of the other
problems that the feature creates.

Received on 2021-03-20 16:19:19