C
cppsks
We recently figured out that std::queue's constructor throws. I believe it
calls a method on std::deque (the default data structure it uses for the
queue) and that method threw. The method had to do with initialization.
Anyway, the std::queue was allocated on the "stack" - it was an automatic
variable:
std::queue<int> intQ;
Well, I have no problems with queue's constructor throwing but the problem
is that at work, none of the STL containers that are allocated on the stack
have a try/catch block around them. Of course, the insert or push_back
methods have try/catchs around them.
So the general question is: What STL containers throw in their constructor?
It almost seems like it is implementation dependent, in which case how would
you approach a problem such as this?
Thanks,
sks
calls a method on std::deque (the default data structure it uses for the
queue) and that method threw. The method had to do with initialization.
Anyway, the std::queue was allocated on the "stack" - it was an automatic
variable:
std::queue<int> intQ;
Well, I have no problems with queue's constructor throwing but the problem
is that at work, none of the STL containers that are allocated on the stack
have a try/catch block around them. Of course, the insert or push_back
methods have try/catchs around them.
So the general question is: What STL containers throw in their constructor?
It almost seems like it is implementation dependent, in which case how would
you approach a problem such as this?
Thanks,
sks