This is what mentioned in the book The C++ Standard Library, section 6.3 Deques,
In summary, you should prefer a deque if the following is true:
You don't refer to elements of the container.
It is important that the container frees memory when it is no longer used (however, the standard does not guarantee that this happens).
1. What means "refer to elements of the container"? We should not do that? Why -- we always refer to elements in the container? When we use iterator of deque to acccess elements in deque container, we always refer to elements of container, right? What does the author mean?
2. I think whether deque container implementation actually free the memory when we do erase or pop or just mark it as freed to reserve for future use (e.g. insert or push) is up to implementation details, does this point to be a reason why we use deque? Confused.
thanks in advance,