如何确保模板中的typedef也被调用?

时间:2015-09-01 15:02:51

标签: c++ templates typedef swig typename

我正在使用SWIG为C#包装一个C ++类(PointMatcher.h)。我使用%template指令将模板类具体化,如下所示:

%include "../pointmatcher/PointMatcher.h"

%template(PointMatcherFloat) PointMatcher<float>;

但是,事实证明模板PointMatcher<T>包含基于<T>的typedef和typenames,并且这些模板不包含在SWIG包装器中。 (具体来说,我需要访问以下TransformationParameters。)

//! 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

我尝试使用%inlineT将上述声明复制为float块。 (如SWIG 3.0 documentation on typedef中所述。)在这两种情况下,typedef只包含在.cxx文件中,但不会生成任何关联的类或方法。

如何确保PointMatcherFloat中提供这些类型?

编辑注释:我以前认为这是关于成员模板(例如How to instantiate a template method of a template class with swig?How to get SWIG to apply templates when wrapping a template class containing vectors?),但它实际上是关于模板中的typedef / typenames。

0 个答案:

没有答案
相关问题