'copy array of vectors

What is the best way to copy a std::array of vectors?

I have an array like this:

std::array< std::vector<std::vector<IK::Point_3>>, 2> m0;
std::array< std::vector<std::vector<IK::Point_3>>, 2> m1;

I see that the code works by simply writing m1=m0;

Before I was writing all the time the copy operation, which for sure long to write down and is much more slower.

for (int i = 0; i < m0.size(); i++) {
    for (int j = 0; j < m0[i].size(); j++) {
        m1[i].emplace_back(std::vector<IK:Point_3>());
        m1[i].back().reserve(m0[i].size());
        for (auto& p : m0[i][j])
            m1.back().emplace_back(p);
    }
}

Is there any case where I should not use equals sign, and copy data like the one in the for loop? And is there a better way for copying?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source