C++ API runtime type selection
显示 更早的评论
Hello, this is just a question for understanding :-)
I have a c++ mex function that takes in a real scalar. In the function code I have the assignment
double x=inputs[0][0];
This does the right conversion even when the MATLAB input type is not double, e.g. single or uint8.
As I understand it, the way this works is that input[0] is a TypedArray<T>. Depending on T, the assignment double x=input[0][0]; figures out at compile time how the bits in the input are converted to the bits of a double. And the internal c++ code of the MATLAB c++ api would need to look like
"If the MATLAB input is of type uint8, create a TypedArray<uint8_t>.
if the MATLAB input type is single, create TypedArray<float>.
etc."
But templates are a compile time construct, so how is that even possible?
2 个评论
James Tursa
2022-8-14
Please post a minimum working example of code that runs and then we can comment on how it works or doesn't work.
Klaus Ebenhauer
2022-9-15
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Data API for C++ 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!