Using std::copy to make 1D array a 3D matrix

I'm trying to copy my array 'block' to a 'dummy' 3D matrix so I can take out some arbitrary smaller matrix.

Shouldn't this be possible with std::copy, where I'm certain the number of elements in the 1D array are equivalent to those in the dummy?


  int dummy[210][210][1000];
  std::copy(&block[0], &block[block.size()], &dummy);
You don't need to do this - you can use the same math the compiler uses to calculate indicies and wrap it in a function for convenience if you want. Making a copy like this will be terribly inefficient for simple direct memory access.
LB is right, but if you still need to do it, use &dummy[0][0][0] instead of &dummy as the third argument of copy(). It expects an output iterator where it can write an int: a pointer to int works, a pointer to a a 3D array doesn't.
Topic archived. No new replies allowed.