I have a C++ code that wraps an existing Object with a probability as follows:
template< typename Object > struct Roll
{
Object object;
double probability;
Roll( Object p, double s )
: object( p )
, probability( s )
{ }
}
Later, this will be defined in the same .h file as:
typedef Roll< Color > RollColor;
There's instruction around how to wrap a C++ struct with primitive type in SWIG but this one has something to do with the template also, so I don't know how to wrap it properly in my interface file. Do you have any idea how can I do this ? Thank you very much.
In the
.i
file, use:More info at http://www.swig.org/Doc1.3/Python.html#Python_nn26.
Assuming you have the template defined in
roll.h
andColor
is defined incolor.h
, you will need to use:Update, in response to OP's comment
You can use:
However, you will need to implement a default constructor in
Roll
first. Without that you can't create astd::vector
ofRoll<T>
s.You can use
only if you have a C++ typedef.