Problem with unique and a binary predicate?

B

BCC

What the heck am I doing wrong?

void MyClass::JoinIdenticalFingerprints(CFPrintList& list)
{
CFPrintList unique_list = list;
unique(unique_list.begin(), unique_list.end(), UniquePredicate);
}

bool MyClass::UniquePredicate(const CFPrint& x, const CFPrint& y)
{
return x == y;
}

I get an error:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\algorithm(547): error C2064: term does not evaluate to
a function taking 2 arguments

The example I followed was the help file from MSDN, looks pretty much
the same to me.

It must be something really simple... is there anything obviously wrong
with they way I create and call unique with a predicate??

Thanks
 
V

Victor Bazarov

BCC said:
What the heck am I doing wrong?

void MyClass::JoinIdenticalFingerprints(CFPrintList& list)
{
CFPrintList unique_list = list;
unique(unique_list.begin(), unique_list.end(), UniquePredicate);
}

bool MyClass::UniquePredicate(const CFPrint& x, const CFPrint& y)
{
return x == y;
}

I get an error:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\algorithm(547): error C2064: term does not evaluate to
a function taking 2 arguments

The example I followed was the help file from MSDN, looks pretty much
the same to me.

It must be something really simple... is there anything obviously wrong
with they way I create and call unique with a predicate??

Your "predicate" is probably a non-static member, which requires one
additional argument, "this", to perform its actions. Since the function
does not seem to do anything 'MyClass'-related, you could declare it
static (if you didn't). If my guess is not right, post more code (the
'MyClass' definition is one important piece missing here.

Victor
 
B

BCC

Your "predicate" is probably a non-static member, which requires one
additional argument, "this", to perform its actions. Since the function
does not seem to do anything 'MyClass'-related, you could declare it
static (if you didn't). If my guess is not right, post more code (the
'MyClass' definition is one important piece missing here.

Victor

Good guess! :)

Declaring it static worked.

Thanks!
B
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top