c++/6284: iterator type definitions not accessible in derived template classes

joerg@eyematic.com joerg@eyematic.com
Fri Apr 12 14:47:00 GMT 2002


>Number:         6284
>Category:       c++
>Synopsis:       iterator type definitions not accessible in derived template classes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 12 14:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     joerg@eyematic.com
>Release:        g++-3.0.3
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
The following code does not compile. The problem is the 
iterator used in the print() function. After close 
examination, we noticed that if we explicitely define
the iterator with a typedef as is done in std_list.h
for the list template definition, the problem goes
away.

Here the example:
========================================================

#include <iostream>
#include <list>
using namespace std;

template <class type>
class my_list : public list<type>
{
public:
	void print() const;
};

template <class type>
void my_list<type>::print() const
{
	list<type>::const_iterator i;
	for( i = begin(); i != end(); i++ )
	{
		cout << *i;
	}
}


/**/

int main()
{
	my_list<int> l;
	l.push_back( 1 );
	l.print();
}

>How-To-Repeat:
To reproduce the problem, compile with 
    g++ -pedantic t.cpp -o t
where t.cpp contains the example code above.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list