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.fct]/22 An abbreviated function template is _functionally_ equivalent to a function template #5495
Comments
The first "equivalent" means we can use the abbreviate function template in most respects as an ordinary function template. Such as explicitly specifying the specialization The invented function template is used to depict what the synthesized declaration of the abbreviated function template looks like, such that we can explicitly specialize it or do anything identical to what can be done on a function template, without copying [temp] for it. If they were functionally equivalent, these points are not guaranteed. I agree we do not have a formal rule specifying what the comment says(i.e. functionally equivalent to the grammatical function template). We might just append a rule:
void g1(const auto*);
template<class T>
int g1(const T*); such two function templates are neither equivalent nor functionally equivalent. As a contrast void g1(const auto*);
template<class T>
void g1(const T*); they are functionally equivalent, the program is ill-formed; no diagnostic required. |
Is "what you can do with" a function template declared as an abbreviated function template really something that needs to be covered under "equivalence"? Will it not be suffice with "functional equivalence", whilst then reserving [temp.over.link]/7 and IFNDR for the case of conflicting declarations?
With the current normative wording this program is not IFNDR (although I think it was intended to be), and we see compiler variance here where Clang seems to accept (although NDR...) abbreviated function template declarations as equivalent to (matching) function template declarations, whereas GCC does not (DEMO). |
Not sufficient. We expect the "synthesized" declaration for the abbreviated function template is identical to what we said in the rule. Consider this example: template<int N>
struct C{};
template<int N>
void fun(auto *, C<N>);
/*
template<int N, class T>
void fun(T*, C<N>); // #2
*/ we expect the synthesized declaration of the abbreviated function template like the one at template<int N, class T>
void fun(T*, C<N + 1 - 1>); // #2 you can never explicitly specialize it like
This means the document impose no requirement on the implementations, in other words, they can do whatever they want. See [temp.over.link] p8. |
This issue seems a duplicate of #4121. |
I think this can be fixed as an editorial issue, but please advice me otherwise.
I believe that [dcl.fct]/22, when describing the equivalence relation between an abbreviated function template and a function template [emphasis mine]
should in fact be
and that this is the intended meaning of the specification:
The text was updated successfully, but these errors were encountered: