vendredi 27 janvier 2017

is there a size limit on the length of an std::array?

const size_t size = 10000;
const size_t col = 100;
const size_t nstep = 10000;

array< array<int, col>, size> arr;

for (unsigned int step = 0; step < nstep; step++) {
    for (unsigned int i = 0; i < size; i++) {
        array<int, col> & line = arr[i];
        for (unsigned int j = 0; j < col; j++) {
            line[j] = 12;
        }
    }
}

I wanted to compare the performance of std::array to std::vector and raw pointer for two-dimensional arrays, I created three large datasets and tested the data access in each case. When I increase the size of array "size" to 100000, I get the following error for std::array, vector and raw pointers work fine.

Segmentation fault (core dumped)

Aucun commentaire:

Enregistrer un commentaire