I know there have been similar questions asked, but I haven't been able to see anything that addresses my problem specifically.
I have some C++ code that looks something like this:
template< uint S, typename T = double, bool G = false >
class Point {};
template< typename T >
class Point< 3, T, true >
{
public:
/// Constructor to copy the elements from an array of size 4.
template< typename T2 >
Point( const T2 array[ 4 ] )
: x( static_cast< T >( array[X] ) ),
y( static_cast< T >( array[Y] ) ),
z( static_cast< T >( array[Z] ) ),
w( static_cast< T >( array[ W3D ] ) )
{
}
/// Constructor to set the Point components with explicit values. Note
/// that T2 must be able to be safely cast to type T.
template< typename T2, typename T3, typename T4, typename T5 >
Point( const T2& x, const T3& y, const T4& z, const T5& w )
: x( static_cast< T >( x ) ),
y( static_cast< T >( y ) ),
z( static_cast< T >( z ) ),
w( static_cast< T >( w ) )
{
}
// About 20 more methods...
};
typedef Point< 3, double, true > Point3d;
My goal is to be able to use the Point3d typedef from python (in fact, the C++ code only uses that typedef when dealing with that particular template: Point< 3, double, true>).
If there is an easy way to expose this typedef to python via cython? If so, that would be great. If not, how would I write my own wrapper for the Point class with the template <3, double, true>?
Previous questions, as well as parts of the cython documentation, deal with very simple C++ templates; this one isn't quite as straightforward.
I realize this question may not be well-developed, but if anyone things they might be able to help me out, let me know what other information you need and I would be happy to give it to you.
Thanks,
Spencer