exception specifications work not as you thought.
You can still throw any exception, but if you actually allow anything unlisted to escape you will get a call to unexpected()
and terminate()
.
It's common mistake to think exception spec is similar to java one, it is not. Most guidelines state to not use them, maybe beyond throw(). Some compilers are specified to not implement them (check MSVC dox if you use that one). They are deprecated in the current standard (C++11). __noexcept(true/false) carries ahead the sensible use case.