I want to know if the following check is necessary:
std::list<int> myList;
.....
for (std::list<int>::iterator itr = myList.begin(); itr != myList.end(); ++itr)
{
if (itr != NULL) // Is This Check Necessary?
{
// DO SOMTHING.
}
}
I have seen this check in some places and I'm wondering if that is a necessary check. Maybe this check is necessary if the list is an input to a function?
Thanks, Ofer.
No, it is an unnecessary check.
You might want to check *itr != nullptr, if the list held some kind of pointers.
No, it's not necessary. I am not sure it's even valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With