Why is
std::function
not equality comparable?
std::function
is a wrapper for arbitrary callable types, so in order to implement equality comparison at all, you’d have to require that all callable types be equality-comparible, placing a burden on anyone implementing a function object. Even then, you’d get a narrow concept of equality, as equivalent functions would compare unequal if (for example) they were constructed by binding arguments in a different order. I believe it’s impossible to test for equivalence in the general case.
What is the “possible hole in the type system?”
I would guess this means it’s easier to delete the operators, and know for certain that using them will never give valid code, than to prove there’s no possibility of unwanted implicit conversions occurring in some previously undiscovered corner case.
How is it different from
std::shared_ptr
?
std::shared_ptr
has well-defined equality semantics; two pointers are equal if and only if they are either both empty, or both non-empty and pointing to the same object.