It's safe to call find
(and count
), as long as whatever ordering you've defined doesn't rely on the pointer being non-empty. The only thing that find
(and count
) will do with the argument is use it as an argument for the comparator.
However, it's not safe to use weak_ptr
as a key in an associative container. If it expires, then the container's order is broken, and trying to use the container afterwards will give undefined behaviour.