J
John Smith
Hello,
I'm trying to port some code from Windows to Mac OSX with gcc.
Assume we have a class list which works like this:
template<class T>
class List
{
protected:
vector <T> m_List;
public:
typedef typename vector<T>::iterator iterator;
iterator begin() {return m_List.begin();}
iterator end() {return m_List.end();}
}
Now I have a derived class which extends this one:
template<class T>
class ServerList
{
void Func();
}
template<class T>
void ServerList<T>::Func()
{
// Here is the problematic part
iterator it;
vector<iterator> ItVector;
....
}
}
Gcc doesn't accept "iterator" whereas microsoft compiler does. I'm honestly
not sure which is correct or if it's "undefined behavior" in this case, but
what I want is the ServerList::iterator (from List).
So I tried to fix it by manually explicitly declaring it like this:
typename ServerList<T>::iterator it;
vector<ServerList<T>::iterator> ItVector;
Is this the correct way?
Thanks in advance.
-- John
I'm trying to port some code from Windows to Mac OSX with gcc.
Assume we have a class list which works like this:
template<class T>
class List
{
protected:
vector <T> m_List;
public:
typedef typename vector<T>::iterator iterator;
iterator begin() {return m_List.begin();}
iterator end() {return m_List.end();}
}
Now I have a derived class which extends this one:
template<class T>
class ServerList
{
void Func();
}
template<class T>
void ServerList<T>::Func()
{
// Here is the problematic part
iterator it;
vector<iterator> ItVector;
....
}
}
Gcc doesn't accept "iterator" whereas microsoft compiler does. I'm honestly
not sure which is correct or if it's "undefined behavior" in this case, but
what I want is the ServerList::iterator (from List).
So I tried to fix it by manually explicitly declaring it like this:
typename ServerList<T>::iterator it;
vector<ServerList<T>::iterator> ItVector;
Is this the correct way?
Thanks in advance.
-- John