list in C++

Lists are sequence containers that allow constant time insert and erase operations anywhere within the sequence, and iteration in both directions.
Lists are implemented as doubly-linked lists; Doubly linked lists can store elements in different and unrelated locations. The ordering is kept internally by a link to the element preceding it and a link to the element following it.
They are very similar to forward_list: The main difference being that forward_list objects are single-linked lists, and thus they can only be iterated forwards, in exchange for being somewhat smaller and more efficient.
Compared to other sequential containers (array, vector and deque), lists perform generally better in inserting, extracting and moving elements in any position for which an iterator has already been obtained, and therefore also in algorithms that make intensive use of these, like sorting algorithms.
The main drawback of lists and forward_lists compared to these other sequence containers is that they lack direct access to the elements by their position; For example, to access the sixth element in a list, one has to iterate from the beginning or the end to that position, which takes linear time. They also consume some extra memory to keep the linking information associated to each element.