473,790 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with unique and a binary predicate?

BCC
What the heck am I doing wrong?

void MyClass::JoinId enticalFingerpr ints(CFPrintLis t& list)
{
CFPrintList unique_list = list;
unique(unique_l ist.begin(), unique_list.end (), UniquePredicate );
}

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

I get an error:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\includ e\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
Jul 22 '05 #1
2 1629
BCC wrote:
What the heck am I doing wrong?

void MyClass::JoinId enticalFingerpr ints(CFPrintLis t& list)
{
CFPrintList unique_list = list;
unique(unique_l ist.begin(), unique_list.end (), UniquePredicate );
}

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

I get an error:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\includ e\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
Jul 22 '05 #2
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
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3625
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the data. It takes about 4 minutes to get the data. In previous versions it was instantaneous. What do I need to do to increase the performance?
15
3838
by: Andrew Maclean | last post by:
I guess this problem can be distilled down to: How do I search through a string, find the first matching substring, replace it, and continue through the string doing this. Can replace_if() be used to do this? Here is a concrete example: If I have a string with sequences of CRLF and possibly just CR's, is there a simple way of replacing the CRLF characters with a LF? If you look at the function below is it possible to use a replace_if...
2
5624
by: Suma | last post by:
A newbie question : I have a vector of objects(pointers) . I have a function which overloads the less than operator . I can sort the objects without a problem. However when I pass the same function as an arg to the unique function, I still see the duplicate objects. Shouldnt unique be aple to operate with just the less_than overload- since if both the predicates constant1 < constant2 and constan2 < constant1 return false implies...
5
2624
by: Peter Olcott | last post by:
I created an object that requires access to another objects data, yet have found no good way to pass this data as a parameter because the member function that requires this data must be a binary predicate for std::sort. The only way that I got it to work so far is to make the other object global. Are there any better ways than this? Thanks, Peter Olcott
18
1801
by: jslowery | last post by:
I am not completely knowledgable about the status of lexical scoping in Python, but it was my understanding that this was added in a long time ago around python2.1-python2.2 I am using python2.4 and the following code throws a "status variable" not found in the inner-most function, even when I try to "global" it. def collect(fields, reducer): def rule(record): status = True
4
7881
by: mpietrzyk | last post by:
Hi guys I'm having a nasty problem with bulk copying into a table that has unique identifier column. I'm coding on C++, using ODBC driver. I'm coping from a file containing UID description like this: {43B5B3DE-5280-4CBF-B357-D9E57651F0D1} (I also tried a non-bracket version) and in the DB table I get:
16
5089
by: Cory Nelson | last post by:
Does anyone know how std::set prevents duplicates using only std::less? I've tried looking through a couple of the STL implementations and their code is pretty unreadable (to allow for different compilers, I guess).
4
2171
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any help on this, Benny
16
1740
by: shapper | last post by:
Hello, I have a generic list as follows: Dim rows As New Generic.List(Of row) Now I have a row: Dim myRow As row I tried to check, further in my code, if the row is nothing: If myRow Is Nothing Then
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.