Created on 2021-02-11.00:00:00 last changed 4 days ago
CWG 2025-09-12
Instantiating a nested class is not supported with the syntax restriction in the resolution above. Instead, restrict on the naming of the injected-class-name.
Possible resolution (September, 2025):
Change in 13.9.3 [temp.explicit] paragraph 4 as follows:
If the declaration in an explicit instantiation is an elaborated-type-specifier, the explicit instantiation is for a classor member class,(possibly a nested class) and the elaborated-type-specifierin the declarationshallinclude a simple-template-idnot name an injected-class-name; 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 variable template specialization, the unqualified-id in the declarator shall be a simple-template-id. ...
Consider:
template<typename T> struct X { }; extern template struct X<int>; // OK extern template struct X<int>::X; // well-formed explicit instantiation of X<int> ?
At issue is the phrasing "shall include" in 13.9.3 [temp.explicit] paragraph 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. ...
Possible resolution (March, 2025) [SUPERSEDED]:
Change in 13.9.3 [temp.explicit] paragraph 4 as follows:
If the declaration in an explicit instantiation is an elaborated-type-specifier, it shall be of the formclass-key nested-name-specifieropt templateopt simple-template-idand the explicit instantiation is for a class templateor 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. ...
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-09-14 05:51:33 | admin | set | messages: + msg8105 |
2025-09-14 05:51:33 | admin | set | status: open -> review |
2021-02-11 00:00:00 | admin | create |