Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ SWIG%忽略不';无法将模板与typedef匹配_C++_Templates_Swig_Ignore - Fatal编程技术网

C++ SWIG%忽略不';无法将模板与typedef匹配

C++ SWIG%忽略不';无法将模板与typedef匹配,c++,templates,swig,ignore,C++,Templates,Swig,Ignore,我有一个模板化的向量(如数学向量,而不是std::Vector)类,可以用2到4之间的大小进行实例化。定义如下: template <uint32_t Size, typename StorageType> class Vector { public: Vector(StorageType x, StorageType y); Vector(StorageType x, StorageType y, StorageType z); Vector(StorageType x

我有一个模板化的向量(如数学向量,而不是std::Vector)类,可以用2到4之间的大小进行实例化。定义如下:

template <uint32_t Size, typename StorageType>
class Vector
{
public:
  Vector(StorageType x, StorageType y);
  Vector(StorageType x, StorageType y, StorageType z);
  Vector(StorageType x, StorageType y, StorageType z, StorageType w);
  ...
};
但是它无法忽略请求的构造函数

似乎在
%模板
宏中的SWIG会自动从模板参数中“剥离”typedef,因此
%模板(Vector3DInt8)PolyVox::Vector实际转换为
%模板(Vector3DInt8)PolyVox::Vector。因此,
%ignore
不匹配,因为
无符号字符
int8\t
不匹配

如果我在想要忽略的函数中添加一个
static\u assert()
,我会得到:

source/Vector.inl: In constructor ‘Vector<Size, StorageType>::Vector(StorageType, StorageType) [with unsigned int Size = 3u, StorageType = signed char]’:
build/PolyVoxCorePYTHON_wrap.cxx:6446:100:   instantiated from here
source/Vector.inl:56:3: error: static assertion failed: "This constructor should only be used for vectors with two elements."
source/Vector.inl:在构造函数“Vector::Vector(StorageType,StorageType)[无符号int Size=3u,StorageType=signed char]中]:
build/PolyVoxCorePYTHON_wrap.cxx:6446:100:从此处实例化
source/Vector.inl:56:3:错误:静态断言失败:“此构造函数应仅用于包含两个元素的向量。”
我也尝试过使用
-notemplatereduce
,但似乎没有效果

有没有办法让SWIG正确地忽略不需要的构造函数

编辑:我正在使用GCC4.5和SWIG 2.0.8


编辑2:添加了
stdint.i
.i
文件,因为它是Python类型映射所需要的。如果没有
stdint.i
,则
%ignore
可以正常工作,但需要实际使用Python中的绑定。

您使用的是哪个版本的SWIG?这完全符合您在my system.SWIG 2.0.8和GCC 4.5上使用2.0.4所希望的效果。如果它对你有效,我会继续调查。你说得对,添加stdint。我停止工作。我会进一步挖掘。(通常在问题中,我的目标是提供再现问题的最小完整示例,以避免像改变结果那样的愚蠢行为)
source/Vector.inl: In constructor ‘Vector<Size, StorageType>::Vector(StorageType, StorageType) [with unsigned int Size = 3u, StorageType = signed char]’:
build/PolyVoxCorePYTHON_wrap.cxx:6446:100:   instantiated from here
source/Vector.inl:56:3: error: static assertion failed: "This constructor should only be used for vectors with two elements."