Edit: Updating with new request, as my original code was incorrect.
I'd like to first say thank you for this library. It's very useful.
I was trying to extend MxArray with conversions to/from std::array and was running into problems with deducing the type/size of the array. If I make the from function not a member of MxArray, then I can implement the conversion:
template <typename T, size_t N>
mxArray* from(const std::array<T, N>& value) {
MxArray result(MxArray::Numeric<T>(N, 1));
result.set(value);
return result.release();
}
If I change from to MxArray::from, then it won't compile.
A similar attempt to implement the to function does not compile in either case:
template <typename T, size_t N>
void MxArray::to(const mxArray* array, std::array<T, N>* value) {
MxArray input(array);
for (auto i = 0u; i < N; ++i) {
(*value)[i] = input.at<T>(i);
}
}
This would be a great feature to have for extending to templated data types.
Edit: Updating with new request, as my original code was incorrect.
I'd like to first say thank you for this library. It's very useful.
I was trying to extend MxArray with conversions to/from std::array and was running into problems with deducing the type/size of the array. If I make the
fromfunction not a member of MxArray, then I can implement the conversion:If I change
fromtoMxArray::from, then it won't compile.A similar attempt to implement the
tofunction does not compile in either case:This would be a great feature to have for extending to templated data types.