How can I compare two std::function
?
==
only seems to compare to a null pointer:
http://en.cppreference.com/w/cpp/utility/functional/function/operator_cmp
How can I compare two std::function
?
==
only seems to compare to a null pointer:
http://en.cppreference.com/w/cpp/utility/functional/function/operator_cmp
It isn't possible. std::function
can store any copyable and callable object. This includes objects that are not comparable. Since std::function
can contain objects that are not comparable, it cannot provide any comparison operations that will work for all contained objects.
If you want this functionality, you'll have to implement your own type-erased function
template that requires the contained objects to be comparable.