The correct answer is: when inserting to the beginning. The vector performs other operations faster due to the fact that
std::list
more often allocates memory; iterating through
std::list
takes much longer than the vector.
Read more:
C++ benchmark – std::vector VS std::list VS std::deque
Login in to like
Login in to comment