Check if two std :: functions are equal

If I have two std::function s, how can I check if both of these functions are stored or not?

Additional information: I have a function vector std::vector<std::function<void()>> and before adding another function to the vector, I want to check if it is already contained.

+8
c ++ function operators equals std
source share
2 answers

I do not think that both of them can be compared. Below is an example to explain some points of std :: function comparison

+4
source share

In general, std::function and boost::function not comparable, because they need their stored object, which will be comparable, but not all function objects, as well as lambdas, have operator== , so std or boost functions are not able to compare them

-one
source share

All Articles