【发布时间】:2019-03-10 23:09:10
【问题描述】:
我正在尝试为一些模板化的 C++ 代码编写一个 cython 包装器。我对包装类似 Bar 的东西非常熟悉。即(删除细节)
ctypedef enum enum_t "enum_t":
OPT1 "OPT1",
OPT2 "OPT2",
OPT3 "OPT3"
cdef cppclass Bar[A, B, T, ALLOCATOR=*]
new Bar[OPT1, OPT2, float]
但我无法理解包装下面定义的 Bar<OPT1, OPT2, T> or Bar<OPT3, OPT4, T> 之类的实例的做法是什么。有人能指出我正确的方向吗?我所尝试的在编译时给了我一个“OPT1 is ambiguous”错误。
typedef enum
{
OPT1,
OPT2,
OPT3,
} enum_t;
template<class T, class Allocator = std::allocator<T> >
class BarBase : public Foo<T, Allocator>, public mpi::MPIObject
{
//Generic class methods and variables
}
template<enum_t A, enum_t B, class T, class Allocator = std::allocator<T> >
class Bar : public BarBase<T, Allocator>
{
public:
private:
};
template<typename T>
class Bar<OPT1, OPT2, T> : public BarBase<T>
{
//Specific class methods here
}
template<typename T>
class Bar<OPT3, OPT4, T> : public BarBase<T>
{
//Specific class methods here
}
【问题讨论】:
标签: c++ inheritance cython wrapper templating