W
weatherman
Dear all,
When porting some code from g++ 2.95/3.2 to g++ 4.01 we
encountered some difficulties with the following construction.
The code is known to compile on g++ 2.95 and g++ 3.2.2.
This is a condensed test case based on our code.
We believe this is a general c++ standard compliance problem,
and not a g++ problem or bug.
However, we have been unable to find out how this should be done!
The compilation stops at the definition of current_item_,
the compiler does not manage to resolve that line.
(Ideally the code is going to be used to make a slightly specialized
list class from the standard c++ list class)
If anyone can point us in the right directions, we would be
immensely grateful.
- Gunnar
----------------------------------------------------------
MeListTest.h:
----------------------------------------------------------
#ifndef MELISTTEST_H
#define MELISTTEST_H
#include <list>
using namespace std;
template <typename Item>
class ListTest : public list<Item>
{
protected:
list<Item>::iterator current_item_;
public:
ListTest() {}
ListTest(const ListTest& src) : list<Item>(src),
current_item_(src.current_item_) {}
virtual ~ListTest() {}
list<Item>::iterator getIterator(int index)
{ return current_item; }
};
#endif
-----------------------------------------------------
main.cpp
-----------------------------------------------------
#include "MeListTest.h"
int main()
{
ListTest<int> mylist;
}
When porting some code from g++ 2.95/3.2 to g++ 4.01 we
encountered some difficulties with the following construction.
The code is known to compile on g++ 2.95 and g++ 3.2.2.
This is a condensed test case based on our code.
We believe this is a general c++ standard compliance problem,
and not a g++ problem or bug.
However, we have been unable to find out how this should be done!
The compilation stops at the definition of current_item_,
the compiler does not manage to resolve that line.
(Ideally the code is going to be used to make a slightly specialized
list class from the standard c++ list class)
If anyone can point us in the right directions, we would be
immensely grateful.
- Gunnar
----------------------------------------------------------
MeListTest.h:
----------------------------------------------------------
#ifndef MELISTTEST_H
#define MELISTTEST_H
#include <list>
using namespace std;
template <typename Item>
class ListTest : public list<Item>
{
protected:
list<Item>::iterator current_item_;
public:
ListTest() {}
ListTest(const ListTest& src) : list<Item>(src),
current_item_(src.current_item_) {}
virtual ~ListTest() {}
list<Item>::iterator getIterator(int index)
{ return current_item; }
};
#endif
-----------------------------------------------------
main.cpp
-----------------------------------------------------
#include "MeListTest.h"
int main()
{
ListTest<int> mylist;
}