[C++-sig] Extracting inherited class instances
Johann Borck
johann.borck at densedata.com
Wed Sep 12 13:50:41 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Furkan Kuru wrote:
> Hello,
>
> I have a class exposed to python and extract it like this; ..
>
> int
>
> len=boost::python::len(xList); for(int i=0;i<len;i++) {
>
> boost::python::object cur = xList.pop();
>
> try {
>
> Y& xins = boost::python::extract<Y&> (cur);
>
> YHandler(Y);
>
> }
>
> catch(...) {
>
Is there a reason why you don't use check()?
like
bp::extract<Y&> x (cur);
if (x.check()){ YHandler(x()); }
it at least seems to reduce the ugliness of the nested structure.
Johann
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG59KRTaz+euYGsRERAsojAKCLrL6EEqXUPYe7BH3dR0zeWJFJYACfQND1
vOzP8qvGTWSZU5HEbSYP4s8=
=d5Rx
-----END PGP SIGNATURE-----
More information about the Cplusplus-sig
mailing list