Containers

The goal of this exercise is to appreciate the importance of manipulating data structures that are contiguous in memory.

  • Starting from containers.cpp, fill a std::array, a std::vector and a std::list with 1’000’000’000 numbers, measuring the time it takes for each
  • For std::vector try with and without calling reserve()
  • For std::vector and std::list try with a container already constructed with the right size
  • For std::array the operation can fail badly. Why?