The following code will compile with any specific type as the content of the
list parent class, but will not compile when the content is a template
parameter of the subclass.

My goal was to get an iterator to the parent class and I've not found a way to
do that.

This behavior also exists with gcc 4.1.1 and gcc 3.4.3.

gcc (GCC) 4.2.0 20060723 (experimental)
-----------
bad.cpp:
--------
#include <list>
using namespace std;
template <class C> class D1 : public list<C> {
public:
        D1( void ) { list<C>::iterator it; }
};
struct T { };
class D2 : public list<T> {
public:
        D2( void ) { list<T>::iterator it; }

};
-----------
bad.cpp: In constructor 'D1<C>::D1()':
bad.cpp:5: error: expected `;' before 'it'


-- 
           Summary: subclass of a STL class such as list cannot itself be a
                    template class
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sesquized at sbcglobal dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28487

Reply via email to