There is no way to test if an iterator is uninitialized, but you can initialize it to the end() of your container as a default invalid value:

Code:

std::list<entanim_s>::iterator iterAnim = my_list.end();

Code:

if (iterAmin != my_list.end())
{
iterAnim->ePriority = priority;
}

05-28-2011

tabstop

An iterator cannot be empty. The list could be empty, or iterAnim could be invalid.

The official position seems to be that it's your job to make sure iterAnim is always valid. Always initialize your iterators, and if you do something destructive that might invalidate your iterator, make sure you set it to something known good.

05-28-2011

Helder Lopes

so this code

Code:

if(iterAnim != NULL)
{
iterAnim->ePriority = priority;
}

is impossible to be valid??

05-28-2011

tabstop

That can't really work, correct. iterAnim is not really a pointer and can't be NULL.