Paul Caseley
March 26th, 2002, 08:45 AM
ok basically I'm trying to rewrite CPtrList so that I can recompile some code on UNIX (sounds nice doesn't it). I've written a class which uses std::list, but all the calls to this my class are the same as the calls to CPtrList (make sense?).
anyway, The problem is I've created a POSITION class so that I can traverse my list, this again holds a std::list<void*>::const_iterator, which is used to traverse the std::list in my CPtrList class.
Now on my PC in Visual Studio, I can intilise this as NULL, which helps a lot because when I overload the operator bool(), I can just test it for NULL.
my class looks a little like this:
class POSTION
{
public:
POSITION()
{
m_POSITION = NULL;
}
operator int()
{
if(m_POSITION == NULL)
return 1;
else
return 0;
}
//etc......
private:
std::list<void*>::iterator m_POSITION;
}
the reason I have done it this way is so that i can do:
POSITION pos;
pos = list.GetHeadPosition()
while(pos) //uses the operator int
{
}
now, as I said this all works fine on a PC, but on UNIX it will not allow me to set m_POSITION = NULL, and it won't allow me to do if(m_POSITION == NULL)...
I'm now stuck, I haven't got a clue what to do, basically with out using my class I need to be able to do the following on UNIX
std::list<void*>::const_iterator x;
x = NULL
if(x == NULL)
printf("stuff");
can anyone help, or understand what I've just posted?
anyway, The problem is I've created a POSITION class so that I can traverse my list, this again holds a std::list<void*>::const_iterator, which is used to traverse the std::list in my CPtrList class.
Now on my PC in Visual Studio, I can intilise this as NULL, which helps a lot because when I overload the operator bool(), I can just test it for NULL.
my class looks a little like this:
class POSTION
{
public:
POSITION()
{
m_POSITION = NULL;
}
operator int()
{
if(m_POSITION == NULL)
return 1;
else
return 0;
}
//etc......
private:
std::list<void*>::iterator m_POSITION;
}
the reason I have done it this way is so that i can do:
POSITION pos;
pos = list.GetHeadPosition()
while(pos) //uses the operator int
{
}
now, as I said this all works fine on a PC, but on UNIX it will not allow me to set m_POSITION = NULL, and it won't allow me to do if(m_POSITION == NULL)...
I'm now stuck, I haven't got a clue what to do, basically with out using my class I need to be able to do the following on UNIX
std::list<void*>::const_iterator x;
x = NULL
if(x == NULL)
printf("stuff");
can anyone help, or understand what I've just posted?