This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with gcc C++ library


"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]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]