exception-specification

Is it possible to provide exceptions in C++ virtual(pure) class member?

If so how? I know how to provide exception specifications for members such as class SOMEClass { public: void method(void) throw (SOMEException); virtual void pure_method(void) = 0; }; So that the method throws only SOMEException. If I want to ensure that sub-classes of SOMEClass throw SOMEException for pure_method, is it p...

C++\CLI exception specification not allowed

I'm an experienced unmanaged C++ developer, new to C++\CLI. How come managed C++ doesnt allow exception specification? Example link What's the best practice for specifying exceptions my methods throw then? ...

Is there a generally accepted idiom for indicating C++ code can throw exceptions?

I have seen problems when using C++ code that, unexpectedly to the caller, throws an exception. It's not always possible or practical to read every line of a module that you are using to see if it throws exceptions and if so, what type of exception. Are there established idioms or "best practices" that exist for dealing with this proble...

Revert exception specifications behavior under VC++ 9.0

Hello everyone, I'm working on old code that relies heavily on the exception specifications behavior described in the language standard. Namely, calls to std::unexpected() on exception specification violations of the form described below. foo() throw(T) { /*...*/ } Nothrow specifications are indeed guaranteed to not throw, but throw(...

Exception specification when overriding a virtual function

Consider the following code: class A { public: virtual void f() throw ( int ) { } }; class B: public A { public: void f() throw ( int, double ) { } }; When compiled, it says that derived class B has a looser throw specifier compared to A. What is the importance of this? If we try to exchange their exception specification, su...

Exception Specification

I know that this feature will be deprecated in C++0x, but for me as a total novice it seems like a good idea to have it. Could anyone explain to me why isn't a good idea? ...

How to get rid of "C++ exception specification ignored" warning

Hi, I recently got a dll that has been implemented by others. I have to use it in my application. In the header file of their class they have the function declaration void func1() throw (CCustomException); Now when i compile it am getting the warning, C++ exception specification ignored except to indicate a function is not _...

How does an exception specification affect virtual destructor overriding?

The C++ Standard states the following about virtual functions that have exception specifications: If a virtual function has an exception-specification, all declarations, including the definition, of any function that overrides that virtual function in any derived class shall only allow exceptions that are allowed by the exception-spe...

C++ Misfeatures Based on Experience

Recently a colleague asked my opinion on the use of exception specifications in C++ code, and I was able to dredge up this article by Herb Sutter: A Pragmatic Look at Exception Specifications. The article, like most by Herb Sutter, is an educational read, but the short answer is "don't do that." In the summary, he makes reference to a p...