With exception specifications you have to be very careful to make sure that the function call's child function, the registered callback function, does not violate the Convention. It is more difficult to ensure that exceptions are inside the design template.
When designing a callback mechanism, if the caller prescribes a non-throwing exception, you must ensure that the registered function does not throw an exception, as shown in the book:
void (*callbackptr) ( int eventxlocation, int eventylocation, void *datatopassback throw();
and registers the function with the callbackptr type. SM greatly mentions that the standard does not allow exception specifications within a TypeDef, which is a tacit practice for many compilers.
VC + + approach is this: VC + + has such a extended attribute syntax called __declspec, declaring the function with __declspec (nothrow) can have and throw () the same effect. The example given on MSDN https://msdn.microsoft.com/en-us/library/49147z04.aspx:
#define WINAPI __declspec (nothrow) __stdcall
The paper also points out that it is convenient to declare functions extensively.
The compiler is not responsible for exception specifications! Give a warning, and the rest is the run-time thing.
When the runtime throws an exception that is not in the exception specifications, the unexpected function is called, and one of the recommended practices in clause 14 is to use set_unexpected redefine unexpected to throw a custom "unknown exception" And join this thing in all the exception specifications. But the set_unexpected of the pro-test VS2015 will not behave correctly.
Another way is to write the new unexpected function as a direct throw, go out, this will instead throw std::bad_exception, and then add this to exception specifications. And so the high-level may have done a lot of preparation for the exception will be the bottom of the "kindness" and waste, which requires the unification of engineering.
More effective C + + ITEM14: Using exception wisely specifications