E
Evan
Is the following code legal C++?
template <class T >
class C {
class Nested {
C<T>::Nested *n; // typename???
};
};
My understanding was that C<T>::Nested should be considered a dependent
name so should have typename before it. Both MSVC and GCC fail with
errors like "missing ; before *" which seems to confirm my suspicions.
However, Comeau's online C++ compiler lets it pass successfully, which
makes me question the correctness considering Comeau's reputation as
being compliant.
So is this a quirk of Comeau that they let this through because it's
commonly (mis-)used idiom, or is this GCC and MSVC failing to let
through something they should? Or is the standard ambiguous and they
are just interpreting it differently?
(Comeau also lets through the code with a typename. But I also thought
that in all cases typename was either required or prohibited (so never
optional), which would seem to say that Comeau has to be wrong one way
or the other.)
template <class T >
class C {
class Nested {
C<T>::Nested *n; // typename???
};
};
My understanding was that C<T>::Nested should be considered a dependent
name so should have typename before it. Both MSVC and GCC fail with
errors like "missing ; before *" which seems to confirm my suspicions.
However, Comeau's online C++ compiler lets it pass successfully, which
makes me question the correctness considering Comeau's reputation as
being compliant.
So is this a quirk of Comeau that they let this through because it's
commonly (mis-)used idiom, or is this GCC and MSVC failing to let
through something they should? Or is the standard ambiguous and they
are just interpreting it differently?
(Comeau also lets through the code with a typename. But I also thought
that in all cases typename was either required or prohibited (so never
optional), which would seem to say that Comeau has to be wrong one way
or the other.)