Created on 2010-03-17.00:00:00 last changed 130 months ago
[Voted into the WP at the March, 2011 meeting as part of paper N3262.]
Proposed resolution (November, 2010) [SUPERSEDED]:
Change 13.8.3.2 [temp.dep.type] paragraph 1 as follows:
In the definition of a class template, a nested class of a class template, a member of a class template, or a member of a nested class of a class template, a name refers to the current instantiation if it is
the injected-class-name (Clause 11 [class]) of the class template or nested class,
in the definition of a primary class template, the name of the class template followed by the template argument list of the primary template (as described below) enclosed in <> (or a template alias specialization equivalent to same),
in the definition of a nested class of a class template, the name of the nested class referenced as a member of the current instantiation, or
in the definition of a partial specialization, the name of the class template followed by the template argument list of the partial specialization enclosed in <> (or a template alias specialization equivalent to same). If the nth template parameter is a parameter pack, the nth template argument is a pack expansion (13.7.4 [temp.variadic]) whose pattern is the name of the parameter pack.
Change 13.8.3.2 [temp.dep.type] paragraph 3 as follows:
A template argument that is equivalent to a template parameter (i.e., has the same constant value or the same type as the template parameter) can be used in place of that template parameter in a reference to the current instantiation, except that a decltype-specifier that denotes a dependent type is always considered non-equivalent. In the case of a non-type template argument, the argument must have been given the value of the template parameter and not an expression in which the template parameter appears as a subexpression. [Example:...This resolution also resolves issue 1057.
Notes from the November, 2010 meeting:
The CWG disagreed with the suggested direction, feeling that aliases should work like typedefs and that the examples should be accepted.
According to 13.8.3.2 [temp.dep.type] paragraph 1, in a primary class template a name refers to the current instantiation if it is the injected-class-name or the name of the class template followed by the template argument list of the template. Although a template-id referring to a specialization of a template alias is described as “equivalent to” the associated type, a specialization of a template alias is neither of the things that qualifies as naming the current instantiation, so presumably the typename keyword in the following example is required:
template <class T> struct A; template <class T> using B = A<T>; template <class T> struct A { struct C {}; typename B<T>::C bc; // typename needed };
(However, the list in 13.8.3.2 [temp.dep.type] may not be exactly what we want; it doesn't allow use of a typedef denoting the type of the current instantiation, either, but that presumably should be accepted.)
For analogous reasons, it should not be permitted to use a template alias as a nested-name-specifier when defining the members of a class template:
template <class T> struct A { void g(); }; template <class T> using B = A<T>; template <class T> void B<T>::g() {} // error
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | messages: + msg3389 |
2011-04-10 00:00:00 | admin | set | status: review -> fdis |
2010-11-29 00:00:00 | admin | set | messages: + msg3104 |
2010-11-29 00:00:00 | admin | set | messages: + msg3103 |
2010-11-29 00:00:00 | admin | set | status: open -> review |
2010-03-17 00:00:00 | admin | create |