S
Shane Groff
I'm sorry if this is a FAQ, but I've been unable to find exactly what
I'm looking for.
Does the STL make the no-throw guarantee for any of the STL
containers?
E.g. If I have a std::vector<int> on the stack, using my current STL
implementation, as far as I can see, there is no chance for an
exception to occur, because the default constructor for a vector does
not need to do any extra allocations.
On the other hand a std::list<int> will allocate a head node, so it
may throw (obviously if the container is allocated from the free
store, the call to 'new' may throw, but I'm concerned about the
behavior when the container is on the stack).
Is this behavior determined by the standard, and if so, where can I
find out which constructors will not throw?
As a generalization, is there an on-line reference that lists what
exceptions, if any, each of the container member functions are allowed
to throw?
I'm looking for.
Does the STL make the no-throw guarantee for any of the STL
containers?
E.g. If I have a std::vector<int> on the stack, using my current STL
implementation, as far as I can see, there is no chance for an
exception to occur, because the default constructor for a vector does
not need to do any extra allocations.
On the other hand a std::list<int> will allocate a head node, so it
may throw (obviously if the container is allocated from the free
store, the call to 'new' may throw, but I'm concerned about the
behavior when the container is on the stack).
Is this behavior determined by the standard, and if so, where can I
find out which constructors will not throw?
As a generalization, is there an on-line reference that lists what
exceptions, if any, each of the container member functions are allowed
to throw?