3

I am writing a class that acts as a go-between for c++ classes and legacy c code. I have been using boost multi_array's to simplify a lot of the code. This mult_array is declared as such:

using Array = boost::multi_array<float,2>

However, I have run into a problem where I need to pass my multi_array to a legacy function that has a signature similar to

void function(float param[ROWS][COLS]);

My multi_array is of size ROWS and COLS, but I do not know of any easy way to convert the mutli_array to an array. Is there any way to do so?

1

1 Answer 1

2

Since the storage order of boost::multi_array is well defined, you can actually call it safely like that:

function((float (*)[COLS])array.data());

c_storage_order is the default, make sure to not use anything else upon construction of the object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.