What is the memory layout of vector of arrays?
问题 can anybody explaine the memory layout of std::vector<std::array<int, 5>> vec(2) does it provide contiguous memory block of a 2D array with 2 rows of 5 elements? To my understanding, the vector of vectors std::vector<std::vector<int>> vec(2, std::vector<int>(5)) provide the memory layout of two contiguous arrays of length 5 element s in different locations in memory. Will it be the same for the vector of arrays? 回答1: Arrays do not have any indirection, but just store their data "directly".