This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/6284: iterator type definitions not accessible in derived template classes
- From: joerg at eyematic dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 12 Apr 2002 21:43:02 -0000
- Subject: c++/6284: iterator type definitions not accessible in derived template classes
- Reply-to: joerg at eyematic dot com
>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: