where do exception specifications go?

A

ab2305

according to standard it should be part of the declation


class A{

T somefunc()throw (SomeException);
};

yet I found it useful when it is also part of the definition

template<typename T>
T A<T>::someFunc()throw(SomeException){}

what is the usual style?
 
I

Ian

according to standard it should be part of the declation


class A{

T somefunc()throw (SomeException);
};

yet I found it useful when it is also part of the definition

template<typename T>
T A<T>::someFunc()throw(SomeException){}

what is the usual style?
Yes, they are required in both declaration and definition. But in most
cases they are more trouble than they are worth.

Ian
 
G

Greg

according to standard it should be part of the declation


class A{

T somefunc()throw (SomeException);
};

yet I found it useful when it is also part of the definition

You are probably the first C++ programmer ever to find exception
specifications useful.
template<typename T>
T A<T>::someFunc()throw(SomeException){}

what is the usual style?

There is no usual style. No else uses them.

Greg
 
D

Dave Rahardja

You are probably the first C++ programmer ever to find exception
specifications useful.

:-D

I dunno. I kinda like the way that exceptions are enforced as part of the
function type, as in Java.

Actually, never mind.

-dr
 
R

Richard Herring

Dave Rahardja said:
:-D

I dunno. I kinda like the way that exceptions are enforced as part of the
function type, as in Java.
"Enforced". I like that. The Mafia overtones have just the right ring.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top