This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with gcc C++ library
- From: llewelly at xmission dot com
- To: "Luu Vo" <vtluu at tma dot com dot vn>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 31 May 2004 06:26:33 -0600
- Subject: Re: Problem with gcc C++ library
- References: <003001c446f6$4b527210$cc62a8c0@LuuVo>
"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]