You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For any two declarations of an entity E:
— <...>
— If one declares E to be a function template or a (partial specialization of a) variable template, the other shall declare E to be one with an equivalent template-head and type.
Those two bullets don't seem to take into account that in order for [basic.link]/11 to apply, declaration matching ([basic.link]/8) has to establish that two declaration indeed declare the same entity, which involves establishing whether those two declarations correspond ([basic.scope.scope]/4), which relies on the definition of corresponding overloads. The latter puts much more precise and strict requirements on function template declarations ([basic.scope.scope]/4):
Two function or function template declarations declare corresponding overloads if
— both declare functions <...>, or
— both declare function templates with corresponding signatures and equivalent template-heads and trailing requires-clauses (if any).
So I think there's no way to arrive at [basic.link]/11.6 with two declarations of function templates that declare the same entity but don't have equivalent template-heads. I think [basic.link]/11 should either stop caring about that, or sync with corresponding overloads on exact details like trailing requires-clause.
We might want to apply a similar change to [basic.link]/11.1, but in this case [basic.link]/11.1 is stricter than corresponding overloads, because the latter doesn't consider return types (maybe it should?).
Also, while we're looking at [basic.link]/11.6: is it correct to talk about type of a function template and variable template?
Suggested resolution:
For any two declarations of an entity E:
— <...>
— If one declared E to be a function template, the other shall do so.
[Note: Two declarations of the same function template are required to have equivalent template-heads ([basic.scope.scope]). — end note]
— If one declares E to be a function template or a (partial specialization of a) variable template, the other shall declare E to be one with an equivalent template-head and type.
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[basic.link] "Two declarations of an entity" vs corresponding overloads
CWG2945 [basic.link] "Two declarations of an entity" vs corresponding overloads
Oct 30, 2024
Full name of submitter: Vlad Serebrennikov
Reference (section label): [basic.link]
[basic.link]/11 reads:
Those two bullets don't seem to take into account that in order for [basic.link]/11 to apply, declaration matching ([basic.link]/8) has to establish that two declaration indeed declare the same entity, which involves establishing whether those two declarations correspond ([basic.scope.scope]/4), which relies on the definition of corresponding overloads. The latter puts much more precise and strict requirements on function template declarations ([basic.scope.scope]/4):
So I think there's no way to arrive at [basic.link]/11.6 with two declarations of function templates that declare the same entity but don't have equivalent template-heads. I think [basic.link]/11 should either stop caring about that, or sync with corresponding overloads on exact details like trailing requires-clause.
We might want to apply a similar change to [basic.link]/11.1, but in this case [basic.link]/11.1 is stricter than corresponding overloads, because the latter doesn't consider return types (maybe it should?).
Also, while we're looking at [basic.link]/11.6: is it correct to talk about type of a function template and variable template?
Suggested resolution:
The text was updated successfully, but these errors were encountered: