-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): temp.arg.general
Link to reflector thread (if any): N/A
Issue description:
https://wg21.link/temp.arg.general#3 says that the type-id interpretation is preferred over any "expression" interpretation of a template-argument. Template template-arguments are supposed to be id-expressions (https://wg21.link/temp.arg.template#1). Following the introduction of https://wg21.link/p0091r3 (class template argument deduction), most template template-arguments are ill-formed type-ids. See https://wg21.link/dcl.type.simple#3 and https://wg21.link/dcl.type.class.deduct. Even without P0091R3, the disambiguation rule also affects the usage of the usage of the injected-class-name of a class template as a template template-argument.
Consider:
void g();
template <typename T>
struct A {
static void f() {
g<A>((A *)0);
g<A>((A *)0, 0); // Clang, GCC, EDG accept; MSVC rejects
}
};
template <typename T> void g(void *);
template <template <typename> class> void g(void *, int);
void h() { A<int>::f(); }
Suggested resolution:
Template arguments that are in the form a of (possibly dependent) "name" can perhaps be parsed as a new, preferred-by-disambiguation, grammar production for template-argument. The (semantic) forms of template argument can be updated to accept appropriate instances of the new grammar production. Not requiring typename
for a name that is used as the template-argument for a type template parameter would be consistent with the class template injected-class-name behaviour of Clang, GCC, EDG, and MSVC.