C++ Logo


Advanced search

Re: [std-proposals] Split decltype 's functionality: declaration type or expression type

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 8 Jan 2023 21:18:31 -0500
On Sun, Jan 8, 2023 at 8:28 PM Julien Villemure-Fr├ęchette via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> > That `decltype(args)` uses behavior 1. And it is *really important*
> that it uses behavior 1.
> This gets really close to the rationale behind the OP. Since it is behavior 1 that is intended here, and only behavior 1, it is unfortunate that we don't have the syntactic means of enforcing behavior 1 by having a specific keyword, and which would fail compilation if `args` is not an id expr (or parameter pack in this case).

But the literal text "args" cannot *not* be an id-expression. That's
what the token is. The only way it could result in different behavior
is if you *change* the literal text to no longer being "args".

That's my point: the behavior of the text "decltype(args)" is fixed.
The behavior of "decltype(some_func())" is fixed. The behavior is
*different* to be sure, but the behavior of the two different token
sequences is well-defined by those pieces of text. There is no
ambiguity about what processes these two pieces of text will engage

Received on 2023-01-09 02:18:38