I have a vector of objects :
std::vector<QueuedMessage> _messages;
And trying to remove all objects with erase-remove idiom:
void MessageQueue::removeFromQueue(){
_messages.erase(std::remove_if(_messages.begin(),_messages.end(),wasMessageSend),_messages.end());
}
My compare function:
bool MessageQueue::wasMessageSend(const QueuedMessage& mess){
return mess.canSendMessage();
}
And compare function inside the objects class:
bool QueuedMessage::canSendMessage() const{
return (SDL_GetTicks() >= startTick);
}
However, I receive this error:
error: must use '.*' or '->*' to call pointer-to-member function in '((__gnu_cxx::__ops::_Iter_pred<bool (MessageQueue::*)(const QueuedMessage&)>*)this)->__gnu_cxx::__ops::_Iter_pred<bool (MessageQueue::*)(const QueuedMessage&)>::_M_pred (...)', e.g. '(... ->* ((__gnu_cxx::__ops::_Iter_pred<bool (MessageQueue::*)(const QueuedMessage&)>*)this)->__gnu_cxx::__ops::_Iter_pred<bool (MessageQueue::*)(const QueuedMessage&)>::_M_pred) (...)'|
Is it a problem that I´m not using a vector of pointers? Or am I missing something? Thanks.
wasMessageSendis not a function. It's a member function.wasMessageSendin theremove_if()call is a pointer to a member function.wasMessageSendstatic.