Search code examples
c++c++11stdvectorstdarray

c++11 object that can be passed as "double (*)[4]"


I need to call an function in an external library that has a signature:

void fn(double (*values)[4]);

but I would like to pass an object like std::vector<std::array<double, 4>> and it must be c++11 compliant. How would I call this function?


Solution

  • With this:

    std::vector<std::array<double, 4>> my_array;
    ...
    // Function call:
    fn((double(*)[4]) &my_array[array_index][0]);