Why can't I have a std::set or std::unordered_set of std::functions?Is there any way to get it to work anyway?
Consider the following data structures and code.The output of the above code is the following.As we might expect, when an object pointed to by the pointer in the set is updated, the set does not automatically re-evaluate the predicate, even though the predicate orders the pointers based on the objects...
I'm using std::set to store unique instances of a class. std::set does not have an overloaded subscript operator so you can't do set for example.
I've read this SO post, and this one too regarding the erasure of elements from a std::set during iteration. However, it seems that a simpler solution exists in C++17: