Search code examples
c++performancevectorcontainersdoubly-linked-list

Should std::list be deprecated?


According to Bjarne Stroustrup's slides from his Going Native 2012 keynote, insertion and deletion in a std::list are terribly inefficient on modern hardware:

vector vs list

Vector beats list massively for insertion and deletion

If this is indeed true, what use cases are left for std::list? Shouldn't it be deprecated then?


Solution

  • Vector and list solve different problems. List provides the guarantee that iterators never become invalidated as you insert and remove other elements. Vector doesn't make that guarantee.

    It's not all about performance. So the answer is no. List should not be deprecated.

    Edit

    Beyond this, C++ isn't designed to work solely on "modern hardware." It is intended to be useful across a much wider range of hardware than that. I'm a programmer in the financial industries and I use C++, but other domains such as embedded devices, programmable controllers, heart-lung machines and myriad others are just as important. The C++ language should not be designed solely with the needs of certain domains and the performance of certain classes of hardware in mind. Just because I might not use a list doesn't mean it should be deprecated from the language.