Thread View: comp.std.c++
2 messages
2 total messages
Started by Marian Hellema
Wed, 06 Dec 1995 18:51
Containers and exceptions
Author: Marian Hellema
Date: Wed, 06 Dec 1995 18:51
Date: Wed, 06 Dec 1995 18:51
31 lines
1505 bytes
1505 bytes
Hello, I am wondering if any of the containers in the standard library can throw exceptions. In the working paper the only container for which exceptions are specified is bitset. This suggests that none of the other containers throws exceptions. If this is correct: why not? It would seem reasonable to me, for example: vector's operator[] throws an exception if you use an index greater than the size() of the vector. (Similar to the class string, whose memberfunction at() can throw out_of_range). Or: a length_error exception if you try to resize a container to a size which exceeds max_size(). (Again: similar to class string). Thanks, Marian -- ---------------------------------------------------------------------- Marian Hellema AT Computing, UNIX training and consultancy email: marian@atcmp.nl P.O. Box 1428, 6501 BK Nijmegen phone: +31 24 3527225 the Netherlands --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Containers and exceptions
Author: Steve Clamage
Date: Thu, 07 Dec 1995 18:38
Date: Thu, 07 Dec 1995 18:38
28 lines
1427 bytes
1427 bytes
In article ke0@info.uci.kun.nl, Marian Hellema <marian@atcmp.nl> writes: > >I am wondering if any of the containers in the standard library >can throw exceptions. >In the working paper the only container for which exceptions >are specified is bitset. >This suggests that none of the other containers throws exceptions. No, it's the reverse. If the specification of a function in the standard library has no throw-specification, the function is allowed to throw any exception. (That is true for any function, of course, standard or user-defined.) A function in a container class could potentially throw any exception, depending on the characteristics of user-defined classes provided as template arguments. --- Steve Clamage, stephen.clamage@eng.sun.com --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads