[C++-sig] operator in return false while operator == return true
Simon W
simwarg at gmail.com
Fri Sep 24 16:08:50 CEST 2010
Hi,
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:
*class
{
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:
*class::callPythonFunctions()
{
boost::python::get_override("callbackFunction")(boost::python::object(boost::python::ptr(gameobject)));
// 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("Checking")
print(gameobj == self.mydict)
print(gameobj in self.mydict)*
The above will print something like:
*....
Checking
True
False
...*
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