STL: which functions can throw exceptions

B

Bruno van Dooren

Hi,

i am using some STL containers in a library of mine.
how can i see which exceptions can occur when doing something
with those containers (adding an elemnt for example)

i have looked in the MSDN collection, but class members lists nothing, and
the specific functions also don't mention anything.

am i looking in the wrong place or doi have to find my way through the STL
sources?

kind regards,
Bruno.
 
T

Tom Widmer

Hi,

i am using some STL containers in a library of mine.
how can i see which exceptions can occur when doing something
with those containers (adding an elemnt for example)

Generally anything that might allocate memory might throw
std::bad_alloc.
i have looked in the MSDN collection, but class members lists nothing, and
the specific functions also don't mention anything.

Generally the exceptions they throw depend on the exceptions that the
held types throw. If you have a vector<MyType> and the MyType copy
constructor throws, then lots of vector's methods may throw that
exception.
am i looking in the wrong place or doi have to find my way through the STL
sources?

There's a good .pdf on library exception safety here:

http://www.research.att.com/~bs/3rd_safe0.html

(or buy the book).

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top