I have a C++ class which accepts a std::function, and I want to wrap this class for use in python, using cython.
template<typename F>
class A{
public:
A(const F& func):_f{boost::make_shared<F>(func)}{}
boost::shared_ptr<F> _f;
}
typedef A<std::function<double(const double&)>> AInstance;
Now I want to wrap this AInstance function to python usage. The compilation went through, but when I tried to initialize a AInstance object in python using a simple function
def func(a):
return 1.0
A_instance = AInstance(func)
Error comes out: raise TypeError('GaussHermiteInstance construction failed!')
My question is, what is the correct type in python corresponding to the std::function in C++? How to wrap a std::function in cython from c++ to python? Thanks!