Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[temp.explicit] Note disallows explicit instantiation of non-template member functions of a class template specialization #5110

Copy link
Copy link
Open
@zygoloid

Description

@zygoloid
Issue body actions

[temp.explicit]/4:

[...] If the explicit instantiation is for a function or member function, the unqualified-id in the declarator shall be either a template-id or, where all template arguments can be deduced, a template-name or operator-function-id.
[Note 1: The declaration can declare a qualified-id, in which case the unqualified-id of the qualified-id must be a template-id. —end note]

I don't know what this note is trying to say, but it appears to flat-out contract the previous normative sentence that allows the unqualified-id to be a template-name or operator-function-id.

But I think both the note and the normative sentence here are nonsense. Consider the immediately following sentence:

If the explicit instantiation is for a member function, a member class or a static data member of a class template specialization, the name of the class template specialization in the qualified-id for the member name shall be a simple-template-id.

So if the explicit instantiation is for a member function of a class template specialization, then we are required to have Class<args>::Function<more args>, even if the function is a non-template member function? What?

I think we meant something more like:

[temp.explicit]/4:

If the explicit instantiation is for a class or member class, the elaborated-type-specifier in the declaration shall include a simple-template-id; otherwise, the declaration shall be a simple-declaration whose init-declarator-list comprises a single init-declarator that does not have an initializer. If the explicit instantiation is for a function or member function template specialization, the unqualified-id in the declarator shall be either a template-id or, where all template arguments can be deduced, a template-name or operator-function-id.
[Note 1: The declaration can declare a qualified-id, in which case the unqualified-id of the qualified-id must be a template-id. —end note]
If the explicit instantiation is for a member function, a member class or a static data member of a class template specialization, the name of the class template specialization in the qualified-id for the member name shall be a simple-template-id. If the explicit instantiation is for a variable template specialization, the unqualified-id in the declarator shall be a simple-template-id. An explicit instantiation shall appear in an enclosing namespace of its template. If the name declared in the explicit instantiation is an unqualified name, the explicit instantiation shall appear in the namespace where its template is declared or, if that namespace is inline (9.8.2), any namespace from its enclosing namespace set.

... but this is still wrong, given that it doesn't properly handle a member of a member of a class template specialization. (The above also loses the restriction that you can't explicitly instantiate an untemplated function.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.Issue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.Issue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.