I'm trying to wrap some C++ Code with Cython. I have a class that utilizes a template method, but is not a template itself.
class SomeClass {
template <class T> SomeClass(T& spam);
};
As the class is not a template but only the Constructor, I cannot declare the class as a template in Cython like this.
# wrong!
cdef extern from "SomeClass.h":
cppclass SomeClass [T]:
SomeClass(T& spam)
For a non-constructor template method, using the following non-template class:
class SomeClass {
template <class T> void other(T& spam);
};
I was able to get this to work:
cdef extern from "someclass.h":
cppclass SomeClass:
void other[T](T &spam)
That may not help you if you specifically need a constructor template method, but it does appear that Cython's support for template methods has improved at least slightly since the time when this question was originally asked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With