I am wrapping a C++ class (PointMatcher.h) for C# using SWIG. I have used the %template
directive to concretise a template class as follows:
%include "../pointmatcher/PointMatcher.h"
%template(PointMatcherFloat) PointMatcher<float>;
However, it turns out the template PointMatcher<T>
contains typedefs and typenames based on <T>
and these are not being included in the SWIG wrapper. (Specifically, I need access to TransformationParameters
below.)
//! The scalar type
typedef T ScalarType;
//! A vector over ScalarType
typedef typename Eigen::Matrix<T, Eigen::Dynamic, 1> Vector;
//! A vector of vector over ScalarType, not a matrix
typedef std::vector<Vector, Eigen::aligned_allocator<Vector> > VectorVector;
//! A quaternion over ScalarType
typedef typename Eigen::Quaternion<T> Quaternion;
//! A vector of quaternions over ScalarType
typedef std::vector<Quaternion, Eigen::aligned_allocator<Quaternion> > QuaternionVector;
//! A dense matrix over ScalarType
typedef typename Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> Matrix;
//! A dense integer matrix
typedef typename Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> IntMatrix;
//! A matrix holding the parameters a transformation.
/**
The transformation lies in the special Euclidean group of dimension \f$n\f$, \f$SE(n)\f$, implemented as a dense matrix of size \f$n+1 \times n+1\f$ over ScalarType.
*/
typedef Matrix TransformationParameters;
// alias for scope reasons
typedef PointMatcherSupport::Parametrizable Parametrizable; //!< alias
typedef Parametrizable::Parameters Parameters; //!< alias
typedef Parametrizable::ParameterDoc ParameterDoc; //!< alias
typedef Parametrizable::ParametersDoc ParametersDoc; //!< alias
typedef Parametrizable::InvalidParameter InvalidParameter; //!< alias
I have tried duplicating the declarations above as an %inline
block, using T
and float
. (As described in the SWIG 3.0 documentation on typedef.) In both cases the typedefs are simply included in the .cxx file, but no associated classes or methods are generated.
How do I make sure these types are made available in PointMatcherFloat?
Edit note: I previously thought this was about member templates (like How to instantiate a template method of a template class with swig? and How to get SWIG to apply templates when wrapping a template class containing vectors?) but it's actually about typedefs/typenames within a template.