Use deque : performance is great.
The standard says: " deque is data sampling when most attachments and exceptions occur at the beginning or end of a sequence" (23.1.1). In your case, all insertions and deletions are done at the end, satisfying the criteria for using deque .
http://www.gotw.ca/gotw/054.htm contains some tips on how you can measure performance, although presumably you have a specific use case, so what you should measure.
Edit: OK, if your objection to deque is not really there, "I'm not sure how fast deque " but "the type of an element cannot be an element in a standard container," then we can exclude any standard container. No, such a beast does not exist. deque "never copies elements", but it copies them from other objects.
The next best thing is probably to create arrays of elements built by default and create a container of pointers to these elements. Something like that, although it can probably be significantly changed.
template <typename T> struct C { vector<shared_array<T> > blocks; vector<T*> elements;
As additional functions and operators are added, it will approach deque , but avoiding anything that requires a copy of type T.
Edit: think about it, my “reader exercise” cannot be done quite right in cases where someone does resize(10); resize(20); resize(15); resize(10); resize(20); resize(15); . You cannot delete half of the array. Therefore, if you want to correctly reproduce the semantics of the resize() container, immediately destroying the excess elements, you will have to select the elements separately (or familiarize yourself with the placement of a new one):
template <typename T> struct C { deque<shared_ptr<T> > elements;
Cleaner code not really keen on memory access patterns (but then I don't understand if performance is a problem or not since you were worried about deque speed.)