Created on 2015-01-20.00:00:00 last changed 27 months ago
Additional notes (September, 2022):
At present, the term "current instantiation" is defined for class templates only, and thus does not apply to function templates.
Moreover, the resolution for this issue should also handle local enums, with particular attention to 9.7.2 [enum.udecl] paragraph 1:
The elaborated-enum-specifier shall not name a dependent type and...
This rule, without amendment, would disallow the following reasonable example if local enums were made dependent types:
template <class T> void f() { enum class E { e1, e2 }; using enum E; }
According to 13.8.3.2 [temp.dep.type] paragraph 9, a local class in a function template is dependent if and only if it contains a subobject of a dependent type. However, given an example like
template<typename T> void f() {
struct X {
typedef int type;
#ifdef DEPENDENT
T x;
#endif
};
X::type y; // #1
}
void g() { f<int>(); }
there is implementation variance in the treatment of #1, but whether or not DEPENDENT is defined appears to make no difference.
In a related question, should a value-dependent alignas specifier cause a type to be dependent? Given
template<int N> struct Y { typedef int type; };
template<int N> void h() {
struct alignas(N) X {};
Y<alignof(X)>::type z; // #2
}
void i() { h<4>(); }
Most/all implementations issue an error for a missing typename in #2.
Perhaps the right answer is that the types should be dependent but a member of the current instantiation, permitting name lookup without typename.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-09-02 21:21:15 | admin | set | messages: + msg6923 |
2015-01-20 00:00:00 | admin | create |