Problem with gcc C++ library
llewelly@xmission.com
llewelly@xmission.com
Mon May 31 12:26:00 GMT 2004
"Luu Vo" <vtluu@tma.com.vn> writes:
[snip]
> template<class T> class C {
> public:
> class A {
> int x;
> } ;
> vector<A> v1; //this line compiles OK
> vector<T> v2; //this line compiles OK
> vector<A>::iterator it1; //this line doesn't compile
> vector<T>::iterator it2; //this line doesn't compile
C++ allows members of template specializations to be types, data
members, or objects. Since wether vector<A>::iterator is a type or
an object, depends on 'T', the compiler cannot determine wether it
is a type or an object. Therefor, the standard says that
'typename' is required to indicate that it is a type:
typename vector<T>::iterator it2;
Some compilers (like VC++, and also older gcc) assume it is always a
type, and thus do the wrong thing if it is not, but that is
non-conforming behavior.
> };
[snip]
More information about the Gcc-help
mailing list