Skip to content Skip to sidebar Skip to footer

Swig_shared_ptr Macro With Templated Class

I'm using SWIG with boost shared pointers to create python extensions. My current issue is that the SWIG_SHARED_PTR macro seems to work differently with templated classes. I'll g

Solution 1:

SWIG can be very touchy about the order in which objects are exposed to it, with its internal type system.

Try moving your %template statements so that they come before your SWIG_SHARED_PTR statements.

Solution 2:

In example2.i the lines

SWIG_SHARED_PTR(base_int_sptr, base_int) 
SWIG_SHARED_PTR_DERIVED(derived_int_sptr, base_int, derived_int)

should be replaced by

SWIG_SHARED_PTR(base_int_sptr, Base<int>)                              
SWIG_SHARED_PTR_DERIVED(derived_int_sptr, Base<int>, Derived<int>)

Post a Comment for "Swig_shared_ptr Macro With Templated Class"