Search code examples
c++c++11stdarray

C++11 std::array slice


I have a matrix like this:

array<array<double, DISMAX>, DISMAX> Md;

and a vector like this:

array<double, DISMAX> matrixLine;

DISMAX is a constant. My question: How can I copy that vector to one line of the matrix without using a for loop? Is it possible?


Solution

  • The simplest method is to do the obvious:

    Md[0] = matrixLine;
    

    There is still a loop but the std::array hides the details.