[C++-sig] union in C++ and BPL

Pearu Peterson pearu at cens.ioc.ee
Tue May 28 17:04:33 CEST 2002


On Tue, 28 May 2002, David Abrahams wrote:

> One way to handle this would be with the (undocumented) back_reference<T>
> facility from boost/python/back_reference.hpp. You can wrap a function
> which takes back_reference<int> (or back_reference<double>) as a parameter;
> that will give you a reference to the source python object in addition to
> the converted value.
> 
> void ItemList_push(ItemList& l, back_reference<double> x)
> {
>     ListType element;
> 
>     if (PyInt_Check(x.reference())) // was the source object an Int?
>     {
>         element.ix = PyInt_AsLong(x.reference().get());
>     }
>     else
>     {
>         element.dx = x.get();
>     }
> }
> 
> *** Pearu, I think this might be a way to work around some of your issues
> as well ***

Yes, I see it. However, currently my show stopper is how to insert
wrapped classes into a class inheritance tree in a 'natural' way :-(.
See the end of this message:

http://mail.python.org/pipermail/c++-sig/2002-May/001058.html

Pearu






More information about the Cplusplus-sig mailing list