Created on 2010-08-03.00:00:00 last changed 141 months ago
[Voted into the WP at the November, 2010 meeting.]
Proposed resolution (August, 2010):
Add the following as a new paragraph at the end of 13.7.8 [temp.alias]:
[Note: this wording assumes the change from “template alias” to “alias template” requested by comment FI 11 on FCD N3092.]The type-id in an alias template declaration shall not refer to the alias template being declared. The type produced by an alias template specialization shall not directly or indirectly make use of that specialization. [Example:
template <class T> struct A; template <class T> using B = typename A<T>::U; template <class T> struct A { typedef B<T> U; }; B<short> b; // Error: instantiation of B<short> uses own type via A<short>::U.—end example]
The current wording of 9.2.4 [dcl.typedef] paragraph 2 requires that the identifier in an alias-declaration “...shall not appear in the type-id.” With template aliases, however, the name of the alias can be used indirectly:
template<typename T> struct A;
template<typename T> using B=typename A<T>::U;
template<typename T> struct A {
typedef B<T> U;
};
B<short> b;
Here the instantiation of B<short> causes the instantiation of A<short>, and the typedef in A<short> ends up attempting to use B<short>, which is still in the process of being instantiated.
There should be an explicit prohibition of such uses.
| 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 | status: dr -> fdis |
| 2010-11-29 00:00:00 | admin | set | messages: + msg3201 |
| 2010-11-29 00:00:00 | admin | set | status: ready -> dr |
| 2010-08-23 00:00:00 | admin | set | messages: + msg2807 |
| 2010-08-03 00:00:00 | admin | create | |