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

[intro.defs] Should the definition of 'signature' explicitly exclude default template arguments? #1702

Open
cpplearner opened this issue Aug 10, 2017 · 4 comments · May be fixed by #1916
Open
Assignees

Comments

@cpplearner
Copy link
Contributor

The definition of 'signature' for function template in N4687 [defns.signature.templ] says:

signature
〈function template〉 name, parameter type list (11.3.5), enclosing namespace (if any), return type, template-head, and requires-clause (17.4.2) (if any)

It could be read to mean that default template arguments, which are declared in the template-head, are part of the signature.

Should the standard somehow clarify that default template arguments are not included in the signature?

@jwakely
Copy link
Member

jwakely commented Aug 10, 2017

template<typename> void foo();
template<typename = T> void foo();
template<typename> void foo() { }

Since the default template argument isn't always present (and may not even be declared in some translation units where the function template is declared) it would not make sense for it to be part of the signature. Otherwise the signature for the same function template would be different in different translation units.

@jensmaurer
Copy link
Member

jensmaurer commented Aug 11, 2017

@jwakely , you seem to agree we need to be more precise than just saying template-head in the definition of signature?.

@zygoloid
Copy link
Member

Since the default template argument isn't always present (and may not even be declared in some translation units where the function template is declared) it would not make sense for it to be part of the signature.

It's not clear to me how intentional that is. For function templates, we have [dcl.fct.default]p4:

"For a given inline function defined in different translation units, the accumulated sets of default arguments at the end of the translation units shall be the same; see 6.2."

... which seems to suggest that someone at some point thought that the ODR implied this requirement. (And if so, presumably it would also imply a similar requirement on default template arguments.)

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Oct 18, 2017
@jensmaurer
Copy link
Member

jensmaurer commented Nov 7, 2017

Editorial meeting consensus: Add "excluding default template arguments" in parens everywhere we refer to template-head in a definition of signature would be fine.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 7, 2017
@jensmaurer jensmaurer changed the title Should the definition of 'signature' explicitly exclude default template arguments? [intro.defs] Should the definition of 'signature' explicitly exclude default template arguments? Feb 13, 2018
@jensmaurer jensmaurer self-assigned this Feb 13, 2018
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.

4 participants