When is it preferable to use std::list over std::vector while working with fairly small objects (no more than 32 bits)?
Explanation
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

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes