[C++-sig] How to check if object is of specific type?

Marcus Jannes jannes80 at hotmail.de
Tue Feb 19 14:33:57 CET 2008


I want to do something similar to the PyObject_TypeCheck() in boost.python. How can i check the type of an object that is passed to a function?

I tried:

myClass dummy;
bp::object py_dummy(dummy);
PyTypeObject* myType = (PyTypeObject*)py_dummy.ptr();
PyObject_TypeCheck(objToCheck, myType); //objToCheck is a PyObject*

but it always returns false.

Windows Live Fotogalerie: So einfach organisieren Sie Ihre Fotos!

More information about the Cplusplus-sig mailing list