This is the mail archive of the gcc-prs@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]

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



>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:


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