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

前端 未结 6 1462
星月不相逢
星月不相逢 2020-12-18 11:59

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 &l         


        
6条回答
  •  忘掉有多难
    2020-12-18 12:38

    This is an exception specification. It says that the only exception that func() can throw is std::exception (or a derivative thereof). Attempting to throw any other exception will give std::unexpected instead.

提交回复
热议问题