Article View: comp.std.c++
Article #1825Re: Exceptions specifications for function templates
From: Harald M. Mueller
Date: Wed, 23 Aug 1995 15:24
Date: Wed, 23 Aug 1995 15:24
57 lines
2953 bytes
2953 bytes
In article <fjh-950822-173307@cs.mu.oz.au>, fjh@cs.mu.oz.au (Fergus Henderson) writes:
|>mueller@garwein.hai.siemens.co.at (Harald M. Mueller) writes:
|>
...
|>
|>> (c) Do not use exception specifications if unknown exceptions
|>> might be thrown:
|>>
|>> template <class T>
|>> void swap(T& a, T& b)
|>> { T tmp = a; a = b; b = tmp;
|>> }
|>>
|>> The disadvantage of this is, of course, that no
|>> automatic run-time check of the thrown exceptions is
|>> possible.
|>
|>Why is that a disadvantage?
Why, then, were exception specifications invented in the first place?
I thought they should be used to document and have automatically checked
exceptions thrown in some function whose implementation is not accessible
to its user.
But maybe ... they are deliberately designed as a "half-hearted" way to
document and automatically check for exception consistency (i.e. that
only exceptions excplicitly made known in the header get thrown)?
- the idea being: Let us document and check exceptions where it is easily
done, but forget about a complicated mechanism for each and every case,
such as templates.
The problem with this is, IMO, that templates are getting a main concept
of C++ programming rapidly - complete libraries (such as STL) almost
exclusively consist of templates, sometimes very complicated ones. For
most functions (actually function templates) declared therein, exception
specifications are thus useless.
Therefore, I fear that exception specifications might be a "dead" feature
right from the beginning ... but maybe I'm wrong here, and they will be
actually be used usefully.
HMM
--
== -------------------------------------------------------------------
== Dr. Harald M. Mueller PSE EZE TNA1
== email: mueller@garwein.hai.siemens.co.at Siemens AG Austria
== tel: +43-1-71711-5336 Erdberger Laende 26
== fax: +43-1-71711-5425 A-1030 Vienna/Austria
== -------------------------------------------------------------------
[ 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. ]
Technical Details
Message-ID:
<41ef79$5fd@siemens.co.at>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<fjh-950822-173307@cs.mu.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: mueller@garwein.hai.siemens.co.at (Harald M. Mueller) Newsgroups: comp.std.c++ Subject: Re: Exceptions specifications for function templates Date: 23 Aug 1995 15:24:58 GMT Organization: Siemens Austria PSE EZE TNA1 Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <41ef79$5fd@siemens.co.at> References: <fjh-950822-173307@cs.mu.oz.au> Reply-To: mueller@garwein.hai.siemens.co.at NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: garwein.hai.siemens-austria Content-Length: 2059 X-Lines: 53 Originator: clamage@taumet