diff options
author | Tadeu Manoel <e.tadeu@gmail.com> | 2017-01-23 13:34:14 -0200 |
---|---|---|
committer | Tadeu Manoel <e.tadeu@gmail.com> | 2017-01-26 17:11:29 -0200 |
commit | 954f0ecd3f57c587a0cf6672e42e2f010c5ef642 (patch) | |
tree | 6485b3e051a8b4068ce8367992c48aa4d85f229f /tests/run/cpp_function_lib.h | |
parent | 3d4f7a1978f4c03a941a2dcff8136b10638476cd (diff) | |
download | cython-954f0ecd3f57c587a0cf6672e42e2f010c5ef642.tar.gz |
Add basic support for std::function
Diffstat (limited to 'tests/run/cpp_function_lib.h')
-rw-r--r-- | tests/run/cpp_function_lib.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/run/cpp_function_lib.h b/tests/run/cpp_function_lib.h new file mode 100644 index 000000000..9ee260140 --- /dev/null +++ b/tests/run/cpp_function_lib.h @@ -0,0 +1,35 @@ +#ifndef CPP_FUNCTION_LIB_H +#define CPP_FUNCTION_LIB_H + +#include <functional> + +// Functions, functor and a holder of std::function used by cpp_stl_function.pyx tests. + +double add_one(double a, int b); +double add_two(double a, int b); + +class AddAnotherFunctor +{ + double to_add; + +public: + AddAnotherFunctor(double to_add); + double operator()(double a, int b) const; +}; + + +class FunctionKeeper +{ + std::function<double(double, int)> my_function; + +public: + FunctionKeeper(std::function<double(double, int)> user_function); + virtual ~FunctionKeeper(); + + void set_function(std::function<double(double, int)> user_function); + std::function<double(double, int)> get_function() const; + + double call_function(double a, int b) const; +}; + +#endif |