1from libcpp.functional cimport function 2 3cdef extern from "cpp_function_lib.cpp": 4 # CPP is include here so that it doesn't need to be compiled externally 5 pass 6 7cdef extern from "cpp_function_lib.h": 8 double add_one(double, int) 9 double add_two(double a, int b) 10 11 cdef cppclass AddAnotherFunctor: 12 AddAnotherFunctor(double to_add) 13 double call "operator()"(double a, int b) 14 15 cdef cppclass FunctionKeeper: 16 FunctionKeeper(function[double(double, int)] user_function) 17 void set_function(function[double(double, int)] user_function) 18 function[double(double, int)] get_function() 19 double call_function(double a, int b) except + 20