H
highegg
hello,
I'm wondering whether it is legal to explicitly instantiate a member
(nested) class prior to explicit instantiation of the enclosing class.
Example:
template <class T>
class A
{
public:
class X
{
public:
T x() { return T(0); }
};
T a () { return T(1); }
};
template class A<int>::X;
template class A<int>;
I'm fairly sure that if I reverse the two explicit instantiations, it
will become illegal, but I have doubts about this form. It is accepted
by GCC and MSVC (at least it was contributed by a MSVC user), but
rejected by Intel C++.
The C++ standard apparently says that a specialization would be OK,
but doesn't seem to say anything explicit about this case. Does an
explicit instantiation count as specialization?
thanks a lot
Jaroslav Hajek, GNU Octave developer
I'm wondering whether it is legal to explicitly instantiate a member
(nested) class prior to explicit instantiation of the enclosing class.
Example:
template <class T>
class A
{
public:
class X
{
public:
T x() { return T(0); }
};
T a () { return T(1); }
};
template class A<int>::X;
template class A<int>;
I'm fairly sure that if I reverse the two explicit instantiations, it
will become illegal, but I have doubts about this form. It is accepted
by GCC and MSVC (at least it was contributed by a MSVC user), but
rejected by Intel C++.
The C++ standard apparently says that a specialization would be OK,
but doesn't seem to say anything explicit about this case. Does an
explicit instantiation count as specialization?
thanks a lot
Jaroslav Hajek, GNU Octave developer