Gauthier Boaglio
Gauthier Boaglio

Reputation: 10262

Where are the limits of cython's templates?

I've got this class but cannot figure out how to extern define with cython. The inner typedef is bugging me :

public:

 typedef ReturnType (*Method)(Parameter);

Here is the full class :

#ifndef LABCALLBACK2_H_
#define LABCALLBACK2_H_


namespace elps {


template < typename ReturnType, typename Parameter >
class LabCallBack2
{
public:

 typedef ReturnType (*Method)(Parameter);

 LabCallBack2(Method _method)
 {
    method         = _method;
 };

 ReturnType operator()(Parameter parameter)
 {
    return (*method)(parameter);
 };

 ReturnType execute(Parameter parameter)
 {
    return operator()(parameter);
 };

private:

 Method  method;

};


}  // namespace elps

#endif /* LABCALLBACK2_H_ */

I started with this, but what next ? Does cython provides a way to do this ?

cdef extern from "../inc/LabCallBack2.h" namespace "elps" :
    cdef cppclass LabCallBack2[ReturnType, Parameter]:
        LabCallBack2(?????????  _method)

Thanks for helping me

Upvotes: 0

Views: 208

Answers (1)

Javier
Javier

Reputation: 26

Please try the next:

LabCallBack2(**void ***_method)

I had used this trick in other cases and it works fine with cython

Upvotes: 1

Related Questions