[C++-sig] Something like boost::any ... custom conversions?

Alex Mohr amohr at pixar.com
Wed Nov 2 23:22:23 CET 2005


Suppose I have a type that is much like boost::any.  If I have an 
instance of this in python (say holding an int), then I want to be able 
to call wrapped c++ code which takes arguments of held types (say 
foo(int)) by passing my any-like object directly.

That is, I want my any-like object to try to convert to the desired c++ 
type by checking to see if it's holding the desired c++ type.

Can anyone point me in a general direction of where to look to do this 
sort of thing?  I've tried looking at the conversion information in the 
reference manual, and I've looked at container_conversions.h, but I have 
to admit that things are still muddy for me.

The lvalue_from_pytype stuff seems like it might be in the right 
direction, but I don't really want lvalue conversion.  I only care about 
passing these things as rvalues.

Thanks a lot,

Alex



More information about the Cplusplus-sig mailing list