A
Abubakar
Hi,
I'm using stl's list class. For iterating it I'm using its const_iterator.
Lets say I have a:
list<char* >::const_iterator m_myitr;
Now:
void proc1()
{
if (some_condition_true)
mylist.remove ( m_myitr );
}
void proc2()
{
// here we have to use m_myitr assuming that
// its pointing to a valid data in the list which hasnt been removed
char * tmp = * m_myitr;
}
void useall()
{
// lets initialize m_myitr .....
m_myitr = mylist.begin();
proc1();
proc2();
}
The problem is at proc2(). If m_myitr has been removed in proc1() I'm going
to get an exception here which of course I want to avoid. There should be
some *if* check which is what I'm not able to write cuz I dont know how
iterator class is behaving/working.
Please tell me that *if* condition that i should write before assigning its
value to char * tmp;. so that I know that it was removed or not .
Regards,
-ab.
I'm using stl's list class. For iterating it I'm using its const_iterator.
Lets say I have a:
list<char* >::const_iterator m_myitr;
Now:
void proc1()
{
if (some_condition_true)
mylist.remove ( m_myitr );
}
void proc2()
{
// here we have to use m_myitr assuming that
// its pointing to a valid data in the list which hasnt been removed
char * tmp = * m_myitr;
}
void useall()
{
// lets initialize m_myitr .....
m_myitr = mylist.begin();
proc1();
proc2();
}
The problem is at proc2(). If m_myitr has been removed in proc1() I'm going
to get an exception here which of course I want to avoid. There should be
some *if* check which is what I'm not able to write cuz I dont know how
iterator class is behaving/working.
Please tell me that *if* condition that i should write before assigning its
value to char * tmp;. so that I know that it was removed or not .
Regards,
-ab.