How would I insert a 2D array into a std::vector?

The reason I'm using a std::vector of 2D arrays instead of a 3D vector is that the 2D array is a grid of short ints with a set size, while the amount of those grids that must be stored is not a set amount.

I get errors when doing this:

1
2
3
4
5
6
7
8
9
10
#include <vector>

int main()
{
    std::vector <short[1][1]> grids;

    short grid[1][1] = {{0}};

    grids.insert(grids.end(), 1, grid);
}


The errors are in .h files from the standard library; two are about invalid array assignment. I guess this isn't how you assign arrays to vectors?

Thanks in advance,
Pyrius.
Last edited on
1
2
3
4
5
6
struct Element{
   short e[10][10];
};
...
std::vector<Element> grids;
...
No better way. Not that this is bad in any way...
Hm, too bad there isn't an easier way. At least it's possible, though. Thanks for answering.
Topic archived. No new replies allowed.