typedef scoping within templates
Gabriel Dos_Reis
Gabriel.Dos_Reis@sophia.inria.fr
Wed Jun 30 23:07:00 GMT 1999
Frank Swenton <fswenton@math.Princeton.EDU> writes:
| References to typedef'ed class names from within a template don't
| compile, although this does work _outside_ of templates. This appears to
| be the case in both the official-release egcs and 2.95 as well. Example
| below--the first "::" definitely compiles; the second, I haven't tried
| yet; the third does not compile (doesn't recognize T::DataType).
|
| =====
| struct A { typedef int DataType; };
|
| A::DataType d; // Compiles
|
| class Boo { A::DataType d; }; // Compiles (I presume--should, anyway)
|
| template<class T> class Bleah {
| T::DataType d; // Does not compile
ISO C++ requires the use of the celebrated keyword 'typename' to
denote dependent typename. That is, you should say:
template<class T> class Bleah {
typename T::DataType d;
};
-- Gaby
More information about the Gcc-bugs
mailing list