All the documentation I can find on the STL containers (both queue and list) say that for any of the remove functions the removed object’s destructor is called. This means that I can’t use std::queue any time I want a queue that’s simply a list of objects needing some operation performed on them.
I want to be able to add objects to the queue when they are waiting in line for me to do something to them. Then I want to remove them from it when I’ve finished with them, without destroying the object in question. This doesn’t appear to be possible from the documentation I’ve read. Am I misreading the documentation? Is there another type of queue in the STL other than the basic “queue” that doesn’t call the removed object’s destructor on a call to pop_front?
Edit to clarify: In my case I’m using a list of pointers. Something like this:
dbObject *someObject;
queue<dbObject *> inputQueue;
inputQueue.push_back(someObject);
...
dbObject *objectWithInput = inputQueue.front();
//handle object's input...
inputQueue.pop_front(); // Remove from queue... destroyed now?
If you put pointers to objects in the queue (and any other STL container), the pointers won’t get deleted when you remove them.
To elaborate: when you use std::queue and remove an object the destructor of some_obj* is called. But the destructor for plain pointer (or any POD type – int, char, etc) is empty, no-op. The fine line here is that the destructor for some_obj* is very different from the destructor for some_obj.