I have a library that exposes a C++ API that only allows for a double array and a callback function. The callback function accepts the double array. For example
typedef (double)FUN(const double *);
double api(const double *arr, FUN callback){
return FUN(arr);
}
However, for my use case, my data is better stored in a custom class and I want to pass an instance of the class to C++ API so that the callback function will operate on this class instance. Is there any way to convert a C++ class instance to double array and then convert it back in the callback function?
api
does not acceptstd::vector
. I have no control over the library.string::c_str