"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2m************@uni-berlin.de...
std::queue is just a wrapper around a STL sequence. It will have the
same reallocation strategy as the underlying sequence does.
If you want a particular reallocation strategy and none of the
standard STL sequences provide it, then you must code your own sequence that
reallocates in the way that you want, and then use that as a parameter to
std::queue.
The second template argument? How would I do that? Can you give an
example?
std::queue<int> my_queue; // std::deque is the default
std::queue<int, std::vector<int> > my_queue_2; // use std::vector instead
std::queue<int, MyContainer<int> > my_queue_3; // user defined class
instead
In each case std::queue is just a wrapper around another class, you can
specify which class by using the second template argument.
I forget exactly what methods MyContainer would have to have in order to be
successfully wrapped by std::queue, but it's the usual stuff, push_back,
pop_front, size, empty etc. etc. The point is that you can use whatever
reallocation strategy you like in MyContainer.
john