I have a weird typedef statement in a C++ program, generated by Py++.
double radius(int); // function to be wrapped
typedef double (*radius_function_type)(int);
// bp::def is a function for wrapping
bp::def("radius", radius_function_type(&radius));
I have figured out that the typedef
statement above is not of the familiar form:
typedef complex_type simple_alias;
Rather it is a way to declare pointer to a function which takes int
as argument and returns double
(same as the prototype).
So how can this pointer to a function (without dereferencing) be called with the address of a function as an argument? This also doesn't match with the prototype. Somebody please explain!
Your question is confusing. Are you asking what this does:
radius_function_type(&radius)"
This is just a C++ typecast, a bit like:
radius (int (42));
but since radius is already of type radius_function_type then you can just as easily do:
bp::def("radius", radius);
but as this is code generated by Py++, it's probably being extra careful with the output.