Why won't this list remove_if code compile

A

Angus

Hi

I have a class CRequest with a function:
bool IsFinished() const;

I have a list of these CRequests - list<CRequest> mylist.

I create a function object to find if a CRequest is finished:
class is_finished : public std::unary_function<CRequest, bool>
{
public:
bool operator() (CRequest req) { return req.IsFinished(); }
};

And I use remove_if like this:
m_RequestList.remove_if(is_finished());

But I get a compile error:
error C2664: 'remove_if' : cannot convert parameter 1 from 'class
is_finished' to 'class std::binder2nd<struct std::not_equal_to<class
CRequest> >'
No constructor could take the source type, or constructor overload
resolution was ambiguous

How can I fix this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top