NULL in C ++ is an integer constant. Pointer conversion is implied in appropriate contexts, but it is not one. You need to explicitly specify:
std::find(dependent_events.begin(), dependent_events.end(), static_cast<P>(0));
Where P is the corresponding type of pointers in the collection. As an alternative, Eddie correctly identified a C ++ 11 solution that should work in modern compilers (if C ++ 11 is enabled).
The reason plain NULL does not work is as follows: C ++ prohibits the implicit conversion of an integer to a pointer. Only one exception, the literal value 0 treated as a null pointer in initialization and assignment to pointers (the literal 0 acts as a βnull pointer constantβ, Β§4.10), and NULL is just 0 (Β§18.1.4).
But when used in creating an instance of a template (for example, in the find call above), C ++ should infer the type of the template for each of its parameters, and the type output for 0 is always the same: int . Therefore, find is called with an int argument (which inside the function is no longer a literal), and, as mentioned above, there is no implicit conversion between the int and the pointer.
source share