🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2683

Re: ubiquitous exception specs?

#2683
From: Pulkkinen Esa
Date: Thu, 23 Nov 1995 22:44
36 lines
2305 bytes
In article <9532600.2461@mulga.cs.mu.OZ.AU>,
Fergus Henderson <fjh@munta.cs.mu.OZ.AU> wrote:
>Part of the problem is that the C++ language is not powerful enough to
>express the right exception specifications for even simple templates.
>For example, what should the exception specification for the following
>template be?
>
>	template <class T> T add3 (T a, T b, T c) { return a + b + c; }
>
I think you could in principle declare the exception specification as
typedefs, and then refer to the new types in the exception specification.
For example: (assuming all functions have a corresponding function object)

template <class Function> class exception_specification;
template <class T> class exception_specification<add3_function<T,T,T,T> >
{ // Here add3_function<> is a function object for add3
  typedef exception_specification<plus<T> >::spec spec;
};

template <class T> T add3(T a, T b, T c) 
throw (exception_specification<add3_function<T,T,T,T> >::spec)
{ return a + b + c; }

But this is very verbose, requires every user function to have a corresponding
exception specification specialization (in addition to a function object) 
and does get ugly when declaring multiple exception specifications for
a single function.
-- 
   Esa Pulkkinen                        | C++ programmers do it virtually
   E-Mail:  esap@cs.tut.fi              | everywhere with a class, resulting
   WWW   :  http://www.cs.tut.fi/~esap/ | in multiple inheritance.


[ 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: <492g7e$cap@peippo.cs.tut.fi>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <Pine.A32.3.91.951115085701.21991A-100000@zorglub.cae.ca> <9532600.2461@mulga.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: esap@cs.tut.fi (Pulkkinen Esa)
Newsgroups: comp.std.c++
Subject: Re: ubiquitous exception specs?
Date: 23 Nov 1995 22:44:47 GMT
Organization: Tampere University of Technology
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <492g7e$cap@peippo.cs.tut.fi>
References: <Pine.A32.3.91.951115085701.21991A-100000@zorglub.cae.ca> <9532600.2461@mulga.cs.mu.OZ.AU>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: korppi.cs.tut.fi
Nntp-Posting-User: esap
Content-Length: 1454
Originator: clamage@taumet