I've read that std::list is terrible. Could someone compare it to .Net's List<> type? I'm coming to C++ from C#

.net, c#, c++, c++11, generics

Solution

`std::list` is actually more like .NET's `LinkedList<T>`. `std::vector` is very similar to `List<T>`.

Both containers have their place, but the "array like" semantics you get with `std::vector` and `System.Collections.Generic.List<T>` are the ones that are most commonly required and provide the expected performance in more cases.

Problem

I read recently that std::list is horrible compared to "intrusive" lists for a host of reasons having to do with constant time lookups and reallocating with operator new...which I think that I'm following. Could one of you guys compare it to the .Net generic list? Is Bjarne's statement that vector should be used unless you have a really good reason kind of like using .Net generic list for any homogenous group of stuff?

Original source