Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dcl.type.auto.deduct] Use "immediately-declared constraint of" #2477

Closed
hubert-reinterpretcast opened this issue Nov 16, 2018 · 6 comments · Fixed by #2905
Closed

[dcl.type.auto.deduct] Use "immediately-declared constraint of" #2477

hubert-reinterpretcast opened this issue Nov 16, 2018 · 6 comments · Fixed by #2905
Assignees

Comments

@hubert-reinterpretcast
Copy link
Contributor

hubert-reinterpretcast commented Nov 16, 2018

draft/source/declarations.tex

Lines 1894 to 1897 in 65a4bac

For a \grammarterm{placeholder-type-specifier} with
a \grammarterm{type-constraint},
if the type deduced for the placeholder does not satisfy its
immediately-declared constraint\iref{temp}, the program is ill-formed.

This is an instance where the antecedent of "its" is not entirely clear on first reading in relation to "immediately-declared constraint", which is a new term. An immediately-declared constraint is always one "of" a type; therefore, we are talking about the immediately-declared constraint of the type deduced for the placeholder.

Suggested wording:

For a placeholder-type-specifier with a type-constraint, the immediately-declared constraint is that of the type deduced for the placeholder. This constraint shall be satisfied.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Jan 24, 2019
@jensmaurer
Copy link
Member

jensmaurer commented Jan 24, 2019

I'm reading the "immediately-declared constraint" construction in clause 12 p6 as syntactic; we often talk about "type" in the syntax analysis when we also mean "placeholder-type-specifier". So, clause 12 tells us what the immediately-declared constraints of the placeholder-type-specifier are, "its" in the quote above obviously refers to the placeholder, and the normative text says that whatever we deduce for the placeholder has to then satisfy the constraint.

The proposed new wording sounds as if we're defining "immediately-declared constraint" for a placeholder-type-specifier, in addition to the "of a type" in clause 12. That seems suboptimal.

[temp.param] p10 supports the "syntactic" interpretation by talking about the "invented type" corresponding to the placeholder. (After the placeholder is deduced, there is a real type, not an invented one.)

@hubert-reinterpretcast
Copy link
Contributor Author

The immediately-declared constraint of any type uses that type in the constraint-expression. Clause 12 defines what the immediately-declared constraint of a type is only when given a type by other wording elsewhere. The proposed wording specifies that in auto-type deduction contexts, the type to plug in is the type deduced for the placeholder. As for [temp.param] p10, it does not talk about the deduced type; the "invented type" is the notional dependent type that is still to be deduced.

@jensmaurer
Copy link
Member

Regarding [temp.param] p10, the text reads "introduces the immediately-declared constraint of the invented type corresponding to the placeholder." So, we're still talking about what I call the syntactic level: it's the notional type "auto" that gets an immediately-declared constraint.
Back to the original question on [dcl.type.auto.deduct]: I still think the "its" refers to the "invented type" = placeholder (we might want to copy the phrasing from [temp.param] p10), we syntax-parse the rest of the declaration and remember the constraint, and when we get to the instantiation, we check the constraint. There is no specific "deduced type" at the time of parsing, so there can't be any constraints attached to it.

@hubert-reinterpretcast
Copy link
Contributor Author

The definition of an "immediately-declared constraint" does not "give" anything to a type, so nothing "gets an immediately-declared constraint" in [temp.param] p10. The immediately-declared constraint is an expression; the application of the expression is determined by the text elsewhere. The operative word in [temp.param] p10 is "introduces". The [decl.type.auto.deduct] wording applies the constraint-expression by requiring it to be satisfied--it does not redefine the term "immediately-declared constraint".

For me, the difference between the two cases is that the [temp.param] case does attach constraints prior to instantiation (relevant for partial ordering), and the [dcl.type.auto.deduct] case does not.

template <typename T> concept C = true;

template <auto x, typename U> struct A { };
template <C T, T x, C U> struct A<x, U> { struct Happy; };
template <C auto x, typename U> struct A<x, U> { };

typename A<0, int>::Happy *p = 0; // okay

We only apply the constraint after the deduction in [dcl.type.auto.deduct], so I see not issue with asking for the constraint-expression written in terms of the deduced type. The immediately-declared constraint of a type T, is a constraint-expression written in terms of T. Saying that T is the placeholder type means, to me, that we have an expression written with a placeholder type in the style of static_cast<auto>(0).

@jensmaurer
Copy link
Member

Editorial meeting:

  • phrase is: "The immediately-declared constraint of type-constraint for type..."

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 22, 2019
@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 22, 2019

Example: The defining sentence will become:

This constraint-expression E is called the immediately-declared constraint of Q for T.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants