[C++-sig] operator in return false while operator == return true

Simon W simwarg at gmail.com
Fri Sep 24 16:08:50 CEST 2010


Im really scared because I fear a fundamental issue concerning the script
system in my game engine.

In C++, I have a class. In my class I map data to GameObject like:

    map<GameObject*, Data> .....

As you see, I use the pointer as key.

When I from c++, in the same class, call a python function I pass the key
like this:


// the variable gameobj is of type GameObject*
When I recieve the call in python I do some checks like this:

*def callbackFunction(self, gameobj):
   for x in self.mydict.keys():
     print(gameobj == self.mydict)
     print(gameobj in self.mydict)*

The above will print something like:

I do have a overloaded == operator. But how can I fix so that python checks
for my pointer and not the PyObject* pointer ?

// Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100924/ee590388/attachment.html>

More information about the Cplusplus-sig mailing list