I have a vector filled with callback functions, and I would like to check if the function callback already exists before adding it. I do not know if it will work even until it even compiles.
vector<std::function<void(void*)>> _callbacks; void Event::RegisterCallback(std::function<void(void*)> callback) { if (callback == NULL) return; vector<std::function<void(void*)>>::iterator it = std::find(_callbacks.begin(), _callbacks.end(), callback); if (it == _callbacks.end()) { _callbacks.push_back(callback); } else {
This gives a compilation error: "Overload resolution selected by the remote operator" == "in alorithm (805). This is due to the call to the search function.
How do I get this to work, and will it really properly compare function calls with the same method?
thanks
c ++ c ++ 11
Mikhail Naumov
source share