C++ Logo

std-discussion

Advanced search

Re: placeholder type in trailing return type

From: Brian Bi <bbi5291_at_[hidden]>
Date: Thu, 21 Nov 2024 23:43:04 +0100
>
> I totally agree on the connection of the words "declared return type"
> with the conversion-function-id.
> That's why I originally expressed that type-specifier-seq already includes
> the case of conversion-function-id.
>

I'm not sure what your remaining question is, then. Can you give an example?


>
> About p2, thank you to highlight its context.
> However, I wonder two details, that likely biased my attention in missing
> to focus on the correct context:
>
> a) how a trailing-return-type may be persent in one of those context ?
> Currently, I interpret "The type of a parameter-declaration of" (one
> of three cases),
> because all three cases include parameter-declaration clause in their
> syntax,
> but another possible interpretation might be "The type of" (one of the
> three cases),
> that is, applying parameter declaration only to the function
> declaration.
> Do you believe the text may be clarified to avoid such ambiguity ?
>

Well, the alternative interpretation is absurd, because you don't get to
declare the type of a lambda. But, ideally, it should be possible to parse
the sentence without needing semantic knowledge about C++, so, yes, I think
this should be clarified. I think this would be an editorial-level change,
so please submit an issue here: https://github.com/cplusplus/draft/issues
And attach a pull request, if you can.


> Does it affect the way a trailing-return-type may be in place ?
>

I'm not understanding the question.


>
> b) do you believe that the words 'see below' in the p2 statement
> "... in a trailing-return-type that specifies the type that replaces
> such a decl-specifier (see below)"
> are still applicable ?
> The only interpretation I see for them is about type replacement,
> which is already well discussed in [dcl.fct]-p(1.3)
> In the old text of C++20, there was a p3 (corresponding to
> p3 and p4 of the current new draft) that read
> "... that trailing-return-type specifies the declared return type of
> the function."
> which was redundant compared to [dcl.fct]-p(1.3).
> Should the redundancy be removed also in p2 about the words 'see
> below' ?
> Is it possible that 'see below' refers §9.3.4.6 [dcl.fct]
> from §9.2.9.7.1 [decl.spec.auto.general] ? A reference may be better ?
>
>
The "see below" in p2 refers to p3. To understand what it means, notice
that we have the same language in p5, except without "see below" since it's
not a forward reference from p5. We have this example:

auto (*fp)() -> auto = f; // OK

The second `auto` is in "the trailing-return-type that specifies the type
that replaces" the first `auto`.

You can have this in a parameter declaration too:



>
> will also wait for a comment on the original third point:
> trailing return type -> trailing-return-type
> in [class.conv.fct]-p3
>
>
> as well as about the topic in
>
> https://stackoverflow.com/questions/79208177/multiple-occurrences-of-placeholder-type-auto-in-a-type
> related to [dcl.type.auto.deduct]-p3.
>


-- 
*Brian Bi*

Received on 2024-11-21 22:43:20