I have a coworker who routinely does an explicit cast to bool in conditionals, as in:
SomeType *ptr = /* some value */;
if (static_cast<bool>(ptr)) {
// do something
}
But I haven't been able to find a good reason for such verbosity. Any ideas?
Edit: The coworker says it’s about clarity and being explicit, but I don’t find this explanation to be very compelling. I brought the question here to see if other C++ experts recommend this, and if so, perhaps a more compelling argument would emerge.