Search code examples
c++standardsthrow

What is the point of `void func() throw(type)`?


I know this is a valid c++ program. What is the point of the throw in the function declarement? AFAIK it does nothing and isnt used for anything.

#include <exception>
void func() throw(std::exception) { }
int main() { return 0; }

Solution

  • That is an exception specification, and it is almost certainly a bad idea.

    It states that func may throw a std::exception, and any other exception that func emits will result in a call to unexpected().